summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-08-23 22:48:19 +0200
committerLudovic Courtès <ludo@gnu.org>2020-08-23 23:05:16 +0200
commitd10474c38d58bdc676e64336769dc2e00cdfa8ed (patch)
tree9cf8d02f2a892d2e6ad4087cf9e296f9804d3326 /tests
parent68193624d1428836b18e93306f96e78706e082c3 (diff)
downloadguix-d10474c38d58bdc676e64336769dc2e00cdfa8ed.tar.gz
lint: formatting: Gracefully handle relative file names.
Fixes <https://bugs.gnu.org/42543>.
Reported by Jack Hill <jackhill@jackhill.us>.

* guix/lint.scm (check-formatting): Always return a list (previously we
would return #f when 'search-path' returns #f).  Check whether
LOCATION's file is a relative file name.  Return a warning if not.
* tests/guix-lint.sh: Add test.
Diffstat (limited to 'tests')
-rw-r--r--tests/guix-lint.sh13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/guix-lint.sh b/tests/guix-lint.sh
index f0df1fda3a..ebe79efb84 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
 
 
@@ -87,3 +90,9 @@ then false; else true; fi
 
 # 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 <https://bugs.gnu.org/42543>.
+(cd "$module_dir"/.. ; guix lint -c formatting -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out"
+test -z "$(cat "$module_dir/out")"