Skip to content

Commit

Permalink
Support validation using new deno validator while manually skipping E…
Browse files Browse the repository at this point in the history
…MPTY_FILE errors.

Also adjusted output to make it more concise and easier to identify what errors belong to etc
  • Loading branch information
yarikoptic committed Apr 19, 2024
1 parent f5c53f7 commit 560bd03
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

rc=0;

if bids-validator --version | grep -q 'alpha$'; then
VALIDATOR_SUPPORTS_CONFIG=no
else
which bids-validator
if bids-validator --help | grep -q -e '--config'; then
VALIDATOR_SUPPORTS_CONFIG=yes
else
VALIDATOR_SUPPORTS_CONFIG=
fi

for i in $(ls -d */ | grep -v node_modules); do
echo "Validating dataset" $i
echo -n "Validating dataset $i: "

if [ -f ${i%%/}/.SKIP_VALIDATION ]; then
echo "Skipping validation for ${i%%/}"
echo "skipping validation"
continue
fi

Expand All @@ -21,18 +22,37 @@ for i in $(ls -d */ | grep -v node_modules); do
CMD="bids-validator ${i%%/} $VALIDATOR_ARGS"

# Use default configuration unless overridden
if [ "$VALIDATOR_SUPPORTS_CONFIG" = "yes" ] && [ ! -f ${i%%/}/.bids-validator-config.json ]; then
CMD="$CMD -c $PWD/bidsconfig.json"
if [ -n "$VALIDATOR_SUPPORTS_CONFIG" ]; then
if [ ! -f ${i%%/}/.bids-validator-config.json ]; then
CMD="$CMD -c $PWD/bidsconfig.json"
fi
else
# with new one we do not have config so let's get --json and exclude some using jq
CMD="$CMD --json"
fi

# Ignore NIfTI headers except for synthetic dataset
if [ $i != "synthetic/" ]; then
CMD="$CMD --ignoreNiftiHeaders"
else
echo "Validating NIfTI headers for dataset" $i
echo "validating NIfTI headers. "
fi

echo $CMD
$CMD || rc=$?
echo "Running " $CMD

if [ -n "$VALIDATOR_SUPPORTS_CONFIG" ]; then
$CMD || rc=$?
else
# rc is not returned correctly anyways and for the best since we need to ignore
# ref: https://github.com/bids-standard/bids-validator/issues/1909
# NOTE: limit to 1 file per error to not flood screen!
errors=$($CMD 2>/dev/null \
| jq '(.issues | map(select(.severity == "error" and .key != "EMPTY_FILE"))) | map(.files_1 = (.files | if length > 0 then .[0:1] else empty end) | del(.files)) | if length > 0 then . else empty end' \
)
if [ -n "$errors" ]; then
echo -e "$errors" | sed -e 's,^, ,g'
rc=1
fi
fi
done
exit $rc;

0 comments on commit 560bd03

Please sign in to comment.