2014-10-11 23:58:29 +00: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 20:48:19 +00: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-11 23:58:29 +00: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 14:28:29 +00:00
|
|
|
|
(description "dummy package. Only used for testing purposes.")))
|
2014-10-11 23:58:29 +00:00
|
|
|
|
EOF
|
|
|
|
|
|
2014-11-06 17:00:51 +00:00
|
|
|
|
GUIX_PACKAGE_PATH="$module_dir"
|
2014-10-11 23:58:29 +00: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 14:28:29 +00:00
|
|
|
|
# 3) the description has a single space following the end-of-sentence period.
|
2014-10-11 23:58:29 +00:00
|
|
|
|
|
2016-05-24 12:45:18 +00: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 16:00:11 +00:00
|
|
|
|
test `grep_warning "$out"` -eq 3
|
2014-10-11 23:58:29 +00: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 16:00:11 +00:00
|
|
|
|
test `grep_warning "$out"` -eq 2
|
2014-10-11 23:58:29 +00: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 16:00:11 +00:00
|
|
|
|
test `grep_warning "$out"` -eq 1
|
2014-10-11 23:58:29 +00: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 16:00:11 +00:00
|
|
|
|
test `grep_warning "$out"` -eq 3
|
2014-10-11 23:58:29 +00: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 16:00:11 +00:00
|
|
|
|
guix lint -c synopsis,invalid-checker dummy 2>&1 | \
|
2014-10-11 23:58:29 +00:00
|
|
|
|
grep -q 'invalid-checker: invalid checker'
|
2015-01-28 13:00:58 +00:00
|
|
|
|
|
|
|
|
|
# Make sure specifying multiple packages works.
|
2016-02-28 22:11:36 +00:00
|
|
|
|
guix lint -c inputs-should-be-native dummy dummy@42 dummy
|
2019-12-04 18:06:31 +00: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 16:00:11 +00:00
|
|
|
|
test `grep_warning "$out"` -eq 3
|
2019-12-04 18:06:31 +00:00
|
|
|
|
|
|
|
|
|
# Make sure specifying multiple packages works.
|
|
|
|
|
guix lint -L $module_dir -c inputs-should-be-native dummy dummy@42 dummy
|
2020-08-23 20:48:19 +00: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")"
|