bids-standard / bids-validator

Validator for the Brain Imaging Data Structure
https://bids-standard.github.io/bids-validator/
MIT License
182 stars 109 forks source link

Tests for some reason expect `/tmp/$USER` to exist? #1945

Closed yarikoptic closed 2 months ago

yarikoptic commented 5 months ago
❯ deno test --allow-all --coverage=cov/ src/
Check file:///home/yoh/proj/bids/bids-validator/bids-validator/src/files/browser.test.ts
Check file:///home/yoh/proj/bids/bids-validator/bids-validator/src/files/deno.test.ts
...
test missingLabel ... File with underscores and hyphens doesn't error out. => ./src/validators/filenameValidate.test.ts:34:11
error: NotFound: No such file or directory (os error 2): lstat '/tmp/yoh'
        this.#fileInfo = Deno.lstatSync(this._getPath())
                              ^
    at Object.lstatSync (ext:deno_fs/30_fs.js:415:3)
    at new BIDSFileDeno (file:///home/yoh/proj/bids/bids-validator/bids-validator/src/files/deno.ts:39:31)
    at file:///home/yoh/proj/bids/bids-validator/bids-validator/src/validators/filenameValidate.test.ts:41:18
    at innerWrapped (ext:cli/40_test.js:174:11)
    at exitSanitizer (ext:cli/40_test.js:103:33)
    at Object.outerWrapped [as fn] (ext:cli/40_test.js:117:20)
    at TestContext.step (ext:cli/40_test.js:475:37)
    at file:///home/yoh/proj/bids/bids-validator/bids-validator/src/validators/filenameValidate.test.ts:34:11

 FAILURES 

valid_headers dataset ... summary has correct totalFiles => ./src/tests/local/valid_headers.test.ts:32:11
test hasMatch ... No  match => ./src/validators/filenameIdentify.test.ts:77:11
test hasMatch ... 1+ matched, datatype match => ./src/validators/filenameIdentify.test.ts:90:11
test missingLabel ... File with underscore and no hyphens errors out. => ./src/validators/filenameValidate.test.ts:17:11
test missingLabel ... File with underscores and hyphens doesn't error out. => ./src/validators/filenameValidate.test.ts:34:11

FAILED | 26 passed (105 steps) | 3 failed (5 steps) (3s)

error: Test failed

note above that

error: NotFound: No such file or directory (os error 2): lstat '/tmp/yoh'

FWIW nothing should rely on/use some fixed filename under $TMPDIR - security hazard!

effigies commented 5 months ago

I believe this results from not having the submodules checked out.

Agree this shouldn't be happening.

effigies commented 2 months ago

The /tmp/$USER issue is resolved. The tests will still fail if you don't have the submodules initialized, but the errors are clearer:

...
test hasMatch ... 2 matches, no pruning => ./bids-validator/src/validators/filenameIdentify.test.ts:91:11
error: NotFound: No such file or directory (os error 2): lstat 'tests/data/bids-examples/fnirs_automaticity/events.json'
        this.#fileInfo = Deno.lstatSync(this._getPath())
                              ^
    at Object.lstatSync (ext:deno_fs/30_fs.js:415:3)
    at new BIDSFileDeno (file:///home/chris/Projects/bids/tmp-validator/bids-validator/src/files/deno.ts:39:31)
    at file:///home/chris/Projects/bids/tmp-validator/bids-validator/src/validators/filenameIdentify.test.ts:94:18
    at innerWrapped (ext:cli/40_test.js:191:11)
    at exitSanitizer (ext:cli/40_test.js:107:33)
    at Object.outerWrapped [as fn] (ext:cli/40_test.js:134:20)
    at TestContext.step (ext:cli/40_test.js:492:37)
    at file:///home/chris/Projects/bids/tmp-validator/bids-validator/src/validators/filenameIdentify.test.ts:91:11

 FAILURES 

Test loading nifti header ... Load header from compressed 3D file => ./bids-validator/src/files/nifti.test.ts:10:11
Test loading nifti header ... Load header from compressed 4D file => ./bids-validator/src/files/nifti.test.ts:28:11
Test loading nifti header ... Fail on non-nifti file => ./bids-validator/src/files/nifti.test.ts:46:11
validate bids-examples => ./bids-validator/src/tests/local/bids_examples.test.ts:34:6
empty_files dataset ... file tree is read => ./bids-validator/src/tests/local/common.ts:22:11
hed-validator not triggered => ./bids-validator/src/tests/local/hed-integration.test.ts:29:6
hed-validator fails with bad schema version => ./bids-validator/src/tests/local/hed-integration.test.ts:46:6
valid_dataset dataset ... file tree is read => ./bids-validator/src/tests/local/common.ts:22:11
valid_filenames dataset ... file tree is read => ./bids-validator/src/tests/local/common.ts:22:11
valid_headers dataset ... file tree is read => ./bids-validator/src/tests/local/common.ts:22:11
valid_headers dataset ... summary has correct tasks => ./bids-validator/src/tests/local/valid_headers.test.ts:20:11
valid_headers dataset ... summary has correct modalities => ./bids-validator/src/tests/local/valid_headers.test.ts:28:11
valid_headers dataset ... summary has correct totalFiles => ./bids-validator/src/tests/local/valid_headers.test.ts:32:11
valid_headers dataset ... summary has correct subjectMetadata => ./bids-validator/src/tests/local/valid_headers.test.ts:36:11
test _findRuleMatches ... Rule stem matches => ./bids-validator/src/validators/filenameIdentify.test.ts:30:11
test _findRuleMatches ... Non-terminal schema node, should recurse then match => ./bids-validator/src/validators/filenameIdentify.test.ts:39:11
test datatypeFromDirectory => ./bids-validator/src/validators/filenameIdentify.test.ts:51:6
test hasMatch ... hasMatch => ./bids-validator/src/validators/filenameIdentify.test.ts:65:11
test hasMatch ... 2 matches, no pruning => ./bids-validator/src/validators/filenameIdentify.test.ts:91:11

FAILED | 28 passed (261 steps) | 11 failed (15 steps) (2s)

error: Test failed