Open Ericson2314 opened 1 month ago
Is there a way to run individual tests? I have a bash script that automates away the happy path where we can use shellcheck to auto-apply fixes. Would be cool to run a n individual tests instead of running the full test suite n times.
#!/usr/bin/env bash
# this file was made by manually editing the list of the shcellcheck exluded files.
#
# Use some vim/emacs magic from the output of
#
# $ cat $_NIX_PRE_COMMIT_HOOKS_CONFIG | yq -y .repos[0].hooks[1].exclude
#
# e.g.
# tests/functional/gc.sh
# tests/functional/add.sh
# tests/functional/fmt.sh
FILES=$(cat /tmp/excluded-files.txt)
MAINT="./maintainers/flake-module.nix"
for file in $FILES
do
shellcheck -f diff "$file" | git apply
SC=$?
# if shellcheck/git patch fails.... manually fix
if [ $SC -ne 0 ]; then
echo "$file failed to be formatted manual intervention required"
nvim $file
else
# Remove the processed file from the list
#
# we need to escape the nested directories for our regex.
escaped_file=$(echo "$file" | sed -e 's/[]\/$*.^[]/\\&/g')
sed -i "/$escaped_file/d" $MAINT
# Do git stuffs
git add "$file" "$MAINT"
git commit -m "housekeeping: shellcheck for $file"
fi
done
@SkamDart Yes there is! See https://nixos.org/manual/nix/unstable/contributing/testing and ./mk/debug-test.sh tests/functional/${testName}.sh
.
Since #10787, we are now running shellcheck on scripts.
Just like with C/C++ formatting, we are excluding almost all existing files by default. However, the reason for doing that is different than for formatting --- fixing shellcheck lint errors does not have the downside of causing merge conflicts churn, but does require manual edits. Thus we're skipping existing files not because it would be potentially bad to get them passing, but because it is more work than is appropriate for a single PR.
Scripts can one-by-one be made passing, which is a great issue to share between new contributors!