Skip to content

Commit 0df7b32

Browse files
authored
Raise error if no files are found (#50)
Passing in an invalid path leads validation to unexpectedly pass. This is because when globbing the path, no files are found, meaning validation occurs against no files. This can be quite misleading for developers, as it is unclear why passing in what seems like a proper file path with validation errors yields no validation errors. See nvaccess/addon-datastore#6712 for context
1 parent 93f1866 commit 0df7b32

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.github/workflows/testCode.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ jobs:
3434
shell: cmd
3535
# E2E: test to check the script can be run, no need to actually test the file.
3636
# The internal checks are covered with unit tests.
37-
run: .\runvalidate.bat --dry-run _test/testData/addons/fake/13.0.json tests\testData\nvdaAPIVersions.json
37+
run: .\runvalidate.bat --dry-run tests/testData/addons/fake/13.0.0.json tests/testData/nvdaAPIVersions.json
3838
- name: Get sha256
3939
shell: cmd
4040
# E2E: test to check the script can be run
41-
run: .\runsha.bat tests\testData\fake.nvda-addon
41+
run: .\runsha.bat tests/testData/fake.nvda-addon
4242
- name: Generate json file
4343
shell: cmd
4444
# E2E: test to check the script can be run
45-
run: .\runcreatejson.bat -f tests\testData\fake.nvda-addon --dir tests\testOutput\test_runcreatejson --channel=stable --publisher=fakepublisher --sourceUrl=https://github.com/fake/ --url=https://github.com/fake.nvda-addon --licName="GPL v2" --licUrl="https://www.gnu.org/licenses/gpl-2.0.html"
45+
run: .\runcreatejson.bat -f tests/testData/fake.nvda-addon --dir tests/testOutput/test_runcreatejson --channel=stable --publisher=fakepublisher --sourceUrl=https://github.com/fake/ --url=https://github.com/fake.nvda-addon --licName="GPL v2" --licUrl="https://www.gnu.org/licenses/gpl-2.0.html"

_validate/validate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ def main():
380380
if errorOutputFile and os.path.exists(errorOutputFile):
381381
os.remove(errorOutputFile)
382382

383+
if not addonFiles:
384+
raise ValueError(f"No files found matching: {args.filePathGlob}")
385+
383386
if not args.dry_run:
384387
anyErrors = False
385388
for filename in addonFiles:

0 commit comments

Comments
 (0)