epiphany w/ gtk4 and webkitgtk 2.38
[jackhill/guix/guix.git] / tests / guix-lint.sh
CommitLineData
dd7c013d
CR
1# GNU Guix --- Functional package management for GNU
2# Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
3#
4# This file is part of GNU Guix.
5#
6# GNU Guix is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or (at
9# your option) any later version.
10#
11# GNU Guix is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19#
20# Test the `guix lint' command-line utility.
21#
22
23guix lint --version
24
d10474c3
LC
25# Choose a module directory not below any %LOAD-PATH component. This is
26# necessary when testing '-L' with a relative file name.
27module_dir="$(mktemp -d)"
28
29mkdir -p "$module_dir"
dd7c013d
CR
30trap "rm -rf $module_dir" EXIT
31
32
33cat > "$module_dir/foo.scm"<<EOF
34(define-module (foo)
35 #:use-module (guix packages)
36 #:use-module (gnu packages base))
37
38(define-public dummy
39 (package (inherit hello)
40 (name "dummy")
41 (version "42")
42 (synopsis "dummy package")
791e0126 43 (description "dummy package. Only used for testing purposes.")))
dd7c013d
CR
44EOF
45
c8af8572 46GUIX_PACKAGE_PATH="$module_dir"
dd7c013d
CR
47export GUIX_PACKAGE_PATH
48
49grep_warning ()
50{
51 res=`echo "$1" | grep -E -c "(synopsis|description) should"`
52 echo $res
53}
54
55# Three issues with the dummy package:
56# 1) the synopsis starts with the package name;
57# 2) the synopsis starts with a lower-case letter;
791e0126 58# 3) the description has a single space following the end-of-sentence period.
dd7c013d 59
a61cd1d0 60out=`guix lint -c synopsis,description dummy 2>&1`
d8934360 61test `grep_warning "$out"` -eq 3
dd7c013d
CR
62
63out=`guix lint -c synopsis dummy 2>&1`
d8934360 64test `grep_warning "$out"` -eq 2
dd7c013d
CR
65
66out=`guix lint -c description dummy 2>&1`
d8934360 67test `grep_warning "$out"` -eq 1
dd7c013d
CR
68
69out=`guix lint -c description,synopsis dummy 2>&1`
d8934360 70test `grep_warning "$out"` -eq 3
dd7c013d 71
d8934360 72guix lint -c synopsis,invalid-checker dummy 2>&1 | \
dd7c013d 73 grep -q 'invalid-checker: invalid checker'
8fbf5302
LC
74
75# Make sure specifying multiple packages works.
1b846da8 76guix lint -c inputs-should-be-native dummy dummy@42 dummy
7282f949 77
78
79# Use --load-path instead.
80unset GUIX_PACKAGE_PATH
81
82out=`guix lint -L $module_dir -c synopsis,description dummy 2>&1`
d8934360 83test `grep_warning "$out"` -eq 3
7282f949 84
85# Make sure specifying multiple packages works.
86guix lint -L $module_dir -c inputs-should-be-native dummy dummy@42 dummy
d10474c3
LC
87
88# Test '-L' with a relative file name. 'guix lint' will see "t-xyz/foo.scm"
89# (instead of "foo.scm") and will thus fail to find it in %LOAD-PATH. Check
90# that it does find it anyway. See <https://bugs.gnu.org/42543>.
91(cd "$module_dir"/.. ; guix lint -c formatting -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out"
92test -z "$(cat "$module_dir/out")"
9a38bed2
LC
93
94# Likewise, when there's a warning, 'package-field-location' used to crash
95# because it can't find "t-xyz/foo.scm". See <https://bugs.gnu.org/46390>.
96(cd "$module_dir"/.. ; guix lint -c synopsis -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out"
97grep_warning "`cat "$module_dir/out"`"