X-Git-Url: https://git.hcoop.net/jackhill/guix/guix.git/blobdiff_plain/791e0126ae5844e429347cecd5ba81779237257d..bdc298ecee15283451d3aa20a849dd7bb22c8538:/tests/guix-lint.sh diff --git a/tests/guix-lint.sh b/tests/guix-lint.sh index 4f9d6db64b..97c2ea83fe 100644 --- a/tests/guix-lint.sh +++ b/tests/guix-lint.sh @@ -22,8 +22,11 @@ guix lint --version -module_dir="t-guix-lint-$$" -mkdir "$module_dir" +# Choose a module directory not below any %LOAD-PATH component. This is +# necessary when testing '-L' with a relative file name. +module_dir="$(mktemp -d)" + +mkdir -p "$module_dir" trap "rm -rf $module_dir" EXIT @@ -40,7 +43,7 @@ cat > "$module_dir/foo.scm"<&1` -if [ `grep_warning "$out"` -ne 3 ] -then false; else true; fi +out=`guix lint -c synopsis,description dummy 2>&1` +test `grep_warning "$out"` -eq 3 out=`guix lint -c synopsis dummy 2>&1` -if [ `grep_warning "$out"` -ne 2 ] -then false; else true; fi +test `grep_warning "$out"` -eq 2 out=`guix lint -c description dummy 2>&1` -if [ `grep_warning "$out"` -ne 1 ] -then false; else true; fi +test `grep_warning "$out"` -eq 1 out=`guix lint -c description,synopsis dummy 2>&1` -if [ `grep_warning "$out"` -ne 3 ] -then false; else true; fi +test `grep_warning "$out"` -eq 3 -if guix lint -c synopsis,invalid-checker dummy 2>&1 | \ +guix lint -c synopsis,invalid-checker dummy 2>&1 | \ grep -q 'invalid-checker: invalid checker' -then true; else false; fi + +# Make sure specifying multiple packages works. +guix lint -c inputs-should-be-native dummy dummy@42 dummy + + +# Use --load-path instead. +unset GUIX_PACKAGE_PATH + +out=`guix lint -L $module_dir -c synopsis,description dummy 2>&1` +test `grep_warning "$out"` -eq 3 + +# Make sure specifying multiple packages works. +guix lint -L $module_dir -c inputs-should-be-native dummy dummy@42 dummy + +# Test '-L' with a relative file name. 'guix lint' will see "t-xyz/foo.scm" +# (instead of "foo.scm") and will thus fail to find it in %LOAD-PATH. Check +# that it does find it anyway. See . +(cd "$module_dir"/.. ; guix lint -c formatting -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out" +test -z "$(cat "$module_dir/out")" + +# Likewise, when there's a warning, 'package-field-location' used to crash +# because it can't find "t-xyz/foo.scm". See . +(cd "$module_dir"/.. ; guix lint -c synopsis -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out" +grep_warning "`cat "$module_dir/out"`"