Repository navigation
Added hed-tests as a submodule #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [submodule "hed-tests"] | ||
| path = spec_tests/hed-tests | ||
| url = https://github.com/hed-standard/hed-tests.git | ||
| branch = main | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,74 @@ | ||
| # HED spec tests | ||
|
|
||
| This directory contains the HED specification-level test suite. | ||
| This directory runs the official HED JSON test suite from the | ||
| [hed-tests](https://github.com/hed-standard/hed-tests) repository against this validator. | ||
|
|
||
| ## Running tests | ||
| ## Getting the test data | ||
|
|
||
| Run the spec tests using the npm script: | ||
| The suite lives in the git submodule `spec_tests/hed-tests`, pinned to a specific hed-tests | ||
| commit. It is empty in a plain clone until you fetch it: | ||
|
|
||
| ```powershell | ||
| npm run testSpecs | ||
| git submodule update --init | ||
| ``` | ||
|
|
||
| This is equivalent to: | ||
| or clone with `git clone --recurse-submodules`. The runner fails with a message pointing here if | ||
| the submodule is missing. | ||
|
|
||
| ## Running the tests | ||
|
|
||
| ```powershell | ||
| npx jest --testPathPatterns='spec_tests/' | ||
| npm run testSpecs | ||
| ``` | ||
|
|
||
| ## Test files | ||
| This is equivalent to `npx jest --testPathPatterns='/spec_tests/'`. | ||
|
|
||
| ## Files | ||
|
|
||
| - **hedTests.spec.js** - the runner. Reads | ||
| `hed-tests/json_test_data/validation_tests.json` and runs every case's string, sidecar, | ||
| events and sidecar+events sub-tests through the BIDS validation entry points. A failing case | ||
| passes when one of its `error_code` or `alt_codes` is among the errors returned (among the | ||
| warnings, with no errors, when the case has `warning: true`). A passing case passes when no | ||
| errors are returned (and no warnings when `warning: true`). | ||
| - **skippedTests.js** - cases this validator does not pass yet, keyed by test case name with a | ||
| one-line reason. Each listed case is reported as skipped in the jest summary. Remove the entry | ||
| once the case passes. | ||
| - **hed-tests/** - the submodule. Do not edit files inside it; changes to the test suite go to | ||
| the hed-tests repository. | ||
|
|
||
| ## Schema loading | ||
|
|
||
| Cases name schemas by version string (`8.4.0`, `ts:testconflict_2.1.0`, ...). Following the | ||
| convention in `hed-tests/json_test_data/test_schemas/README.md`, the runner resolves each version | ||
| string against `hed-tests/json_test_data/test_schemas/hedxml/` by cache-convention file name | ||
| (`HED<version>.xml` or `HED_<library>_<version>.xml`) when such a file exists, and otherwise | ||
| against the schemas bundled in `src/data/schemas/`. The test-only libraries (`testconflict`, | ||
| `testclash`, `testminimal`, `testaux`) and the vendored 8.5.0 prerelease therefore need no | ||
| network access. When building the schemas for a case throws, that issue is the result of every | ||
| sub-test of the case, which is how the SCHEMA_LOAD_FAILED cases are checked. | ||
|
|
||
| - **jsonTests.spec.js** — The main spec test suite that runs HED validation tests against test cases defined in `javascriptTests.json`. It validates parser behavior, BIDS support, and schema compliance using a comprehensive set of test vectors. | ||
| ## Schema tests are not run | ||
|
|
||
| hed-tests also ships `schema_tests.json`, which checks that validators detect errors in HED | ||
| schema files themselves (the cases are mediawiki schema source text). hed-javascript assumes the | ||
| schemas it loads are valid and does not implement schema validation, so that file is skipped as a | ||
| block in `hedTests.spec.js` and is not part of this validator's conformance target. | ||
|
|
||
| ## Updating the pin | ||
|
|
||
| ```powershell | ||
| git -C spec_tests/hed-tests fetch origin | ||
| git -C spec_tests/hed-tests checkout <commit-or-origin/main> | ||
| npm run testSpecs | ||
| ``` | ||
|
|
||
| - **javascriptTests.json** — Data file containing the test cases used by `jsonTests.spec.js`. Includes test scenarios for tag parsing, definition validation, BIDS file validation, and error handling. | ||
| Add any newly failing case to `skippedTests.js` with a reason (or fix it), then commit the | ||
| submodule pointer together with the skip-list change. | ||
|
|
||
| ## About spec tests | ||
| ## Debugging one case | ||
|
|
||
| Spec tests validate the validator against the HED specification and ensure that all validator behavior is correct according to the spec. These are distinct from unit tests in `tests/` which test individual modules and functions. | ||
| At the top of `hedTests.spec.js`, set `runAll` to `false` and put the error code and case names | ||
| in `runMap`, or keep `runAll` and list cases in `skipMap`. `runOnly` restricts the sub-test kinds | ||
| (`stringPass`, `stringFail`, `sidecarPass`, `sidecarFail`, `eventsPass`, `eventsFail`, | ||
| `comboPass`, `comboFail`). |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.