2014-10-12 01:58:29 +02:00
|
|
|
|
# GNU Guix --- Functional package management for GNU
|
|
|
|
|
# Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
|
|
|
|
|
#
|
|
|
|
|
# This file is part of GNU Guix.
|
|
|
|
|
#
|
|
|
|
|
# GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
# your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Test the `guix lint' command-line utility.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
guix lint --version
|
|
|
|
|
|
2020-08-23 22:48:19 +02:00
|
|
|
|
# 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"
|
2014-10-12 01:58:29 +02:00
|
|
|
|
trap "rm -rf $module_dir" EXIT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cat > "$module_dir/foo.scm"<<EOF
|
|
|
|
|
(define-module (foo)
|
|
|
|
|
#:use-module (guix packages)
|
|
|
|
|
#:use-module (gnu packages base))
|
|
|
|
|
|
|
|
|
|
(define-public dummy
|
|
|
|
|
(package (inherit hello)
|
|
|
|
|
(name "dummy")
|
|
|
|
|
(version "42")
|
|
|
|
|
(synopsis "dummy package")
|
2014-10-28 15:28:29 +01:00
|
|
|
|
(description "dummy package. Only used for testing purposes.")))
|
2014-10-12 01:58:29 +02:00
|
|
|
|
EOF
|
|
|
|
|
|
2014-11-06 18:00:51 +01:00
|
|
|
|
GUIX_PACKAGE_PATH="$module_dir"
|
2014-10-12 01:58:29 +02:00
|
|
|
|
export GUIX_PACKAGE_PATH
|
|
|
|
|
|
|
|
|
|
grep_warning ()
|
|
|
|
|
{
|
|
|
|
|
res=`echo "$1" | grep -E -c "(synopsis|description) should"`
|
|
|
|
|
echo $res
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Three issues with the dummy package:
|
|
|
|
|
# 1) the synopsis starts with the package name;
|
|
|
|
|
# 2) the synopsis starts with a lower-case letter;
|
2014-10-28 15:28:29 +01:00
|
|
|
|
# 3) the description has a single space following the end-of-sentence period.
|
2014-10-12 01:58:29 +02:00
|
|
|
|
|
2016-05-24 14:45:18 +02:00
|
|
|
|
out=`guix lint -c synopsis,description dummy 2>&1`
|
tests: Simplify shell exit status negation;
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-lint.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh: Use the shell '!' keyword to negate command exit status
in place of 'if ...; then false; else true; fi'
2020-09-25 18:00:11 +02:00
|
|
|
|
test `grep_warning "$out"` -eq 3
|
2014-10-12 01:58:29 +02:00
|
|
|
|
|
|
|
|
|
out=`guix lint -c synopsis dummy 2>&1`
|
tests: Simplify shell exit status negation;
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-lint.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh: Use the shell '!' keyword to negate command exit status
in place of 'if ...; then false; else true; fi'
2020-09-25 18:00:11 +02:00
|
|
|
|
test `grep_warning "$out"` -eq 2
|
2014-10-12 01:58:29 +02:00
|
|
|
|
|
|
|
|
|
out=`guix lint -c description dummy 2>&1`
|
tests: Simplify shell exit status negation;
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-lint.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh: Use the shell '!' keyword to negate command exit status
in place of 'if ...; then false; else true; fi'
2020-09-25 18:00:11 +02:00
|
|
|
|
test `grep_warning "$out"` -eq 1
|
2014-10-12 01:58:29 +02:00
|
|
|
|
|
|
|
|
|
out=`guix lint -c description,synopsis dummy 2>&1`
|
tests: Simplify shell exit status negation;
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-lint.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh: Use the shell '!' keyword to negate command exit status
in place of 'if ...; then false; else true; fi'
2020-09-25 18:00:11 +02:00
|
|
|
|
test `grep_warning "$out"` -eq 3
|
2014-10-12 01:58:29 +02:00
|
|
|
|
|
tests: Simplify shell exit status negation;
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-lint.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh: Use the shell '!' keyword to negate command exit status
in place of 'if ...; then false; else true; fi'
2020-09-25 18:00:11 +02:00
|
|
|
|
guix lint -c synopsis,invalid-checker dummy 2>&1 | \
|
2014-10-12 01:58:29 +02:00
|
|
|
|
grep -q 'invalid-checker: invalid checker'
|
2015-01-28 14:00:58 +01:00
|
|
|
|
|
|
|
|
|
# Make sure specifying multiple packages works.
|
2016-02-28 23:11:36 +01:00
|
|
|
|
guix lint -c inputs-should-be-native dummy dummy@42 dummy
|
2019-12-04 19:06:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use --load-path instead.
|
|
|
|
|
unset GUIX_PACKAGE_PATH
|
|
|
|
|
|
|
|
|
|
out=`guix lint -L $module_dir -c synopsis,description dummy 2>&1`
|
tests: Simplify shell exit status negation;
* tests/guix-archive.sh, tests/guix-build-branch.sh, tests/guix-build.sh,
tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-environment.sh,
tests/guix-gc.sh, tests/guix-git-authenticate.sh, tests/guix-graph.sh,
tests/guix-hash.sh, tests/guix-lint.sh, tests/guix-pack-relocatable.sh,
tests/guix-pack.sh, tests/guix-package-aliases.sh, tests/guix-package-net.sh,
tests/guix-package.sh: Use the shell '!' keyword to negate command exit status
in place of 'if ...; then false; else true; fi'
2020-09-25 18:00:11 +02:00
|
|
|
|
test `grep_warning "$out"` -eq 3
|
2019-12-04 19:06:31 +01:00
|
|
|
|
|
|
|
|
|
# Make sure specifying multiple packages works.
|
|
|
|
|
guix lint -L $module_dir -c inputs-should-be-native dummy dummy@42 dummy
|
2020-08-23 22:48:19 +02:00
|
|
|
|
|
|
|
|
|
# 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")"
|
2021-02-22 10:52:21 +01:00
|
|
|
|
|
|
|
|
|
# Likewise, when there's a warning, 'package-field-location' used to crash
|
|
|
|
|
# because it can't find "t-xyz/foo.scm". See <https://bugs.gnu.org/46390>.
|
|
|
|
|
(cd "$module_dir"/.. ; guix lint -c synopsis -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out"
|
|
|
|
|
grep_warning "`cat "$module_dir/out"`"
|