aboutsummaryrefslogtreecommitdiff
# 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

# 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


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")
    (description "dummy package. Only used for testing purposes.")))
EOF

GUIX_PACKAGE_PATH="$module_dir"
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;
# 3) the description has a single space following the end-of-sentence period.

out=`guix lint -c synopsis,description dummy 2>&1`
test `grep_warning "$out"` -eq 3

out=`guix lint -c synopsis dummy 2>&1`
test `grep_warning "$out"` -eq 2

out=`guix lint -c description dummy 2>&1`
test `grep_warning "$out"` -eq 1

out=`guix lint -c description,synopsis dummy 2>&1`
test `grep_warning "$out"` -eq 3

guix lint -c synopsis,invalid-checker dummy 2>&1 | \
   grep -q 'invalid-checker: invalid checker'

# 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 <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")"

# 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"`"
td>Ludovic Courtès 2020-04-11linux-boot: 'make-essential-device-nodes' root parameter is optional....Ludovic Courtès 2020-04-11vm: Preserve file permissions on /dev....Ludovic Courtès 2020-04-11vm: 'qemu-image' can pass options to the 'mkfs' command....Ludovic Courtès 2020-04-11vm: 'qemu-image' accepts a list of extra populate directives....Ludovic Courtès 2020-04-10vm: Transparently compress iso9660 images....Tobias Geerinckx-Rice 2020-03-26vm: Distinguish between success and failure of the guest code....Ludovic Courtès 2019-12-18gnu: Remove uses of deprecated Qemu network configuration....Marius Bakke 2019-12-01build: vm: Fix qemu-command procedure....Mathieu Othacehe 2019-11-22system: vm: Add arm64 support....Mathieu Othacehe 2019-11-22build: vm: Fix arm32 support....Mathieu Othacehe 2019-05-18vm: Create installation media with MBR and HFS only, no GPT....Danny Milosavljevic 2019-04-29vm: Pass -smp to QEMU to allow use of multiple cores....Christopher Baines 2019-04-25vm: Adjust FAT serial number code to 32-bit Guile....Ludovic Courtès 2019-04-21vm: Use a fixed FAT serial number for 'efi.img' in ISO images....Ludovic Courtès 2019-04-21vm: Reset file timestamps of the EFI image in ISO images....Ludovic Courtès 2019-04-21vm: Reset file timestamps in ISO images....Ludovic Courtès 2019-04-14vm: Remove Xorriso "-padding" option....Ludovic Courtès 2019-03-13Remove traces of "GuixSD"....Ludovic Courtès 2018-12-19vm: Re-enable KVM on i386....Ludovic Courtès 2018-12-06vm: Add padding in the ISO image....Ludovic Courtès 2018-11-06pack: Import (guix store database) only when '--localstatedir' is passed....Ludovic Courtès 2018-07-04vm: Disable KVM on i386....Ludovic Courtès 2018-06-26vm: 'make-iso9660-image' makes 'grub.cfg' a GC root....Ludovic Courtès 2018-06-26vm: 'make-iso9660-image' no longer includes unreferenced store items....Ludovic Courtès 2018-06-26vm: Don't try to modify the bind-mounted store....Ludovic Courtès 2018-06-14Remove 'guix-register' and its traces....Ludovic Courtès 2018-06-14install: Use 'reset-timestamps' from (guix store database)....Ludovic Courtès 2018-06-14install: Use (guix store database) instead of 'guix-register'....Ludovic Courtès 2018-05-25vm: Pass "panic=1" to Linux....Ludovic Courtès 2018-05-23vm: Print the label and UUID of partitions....Ludovic Courtès 2018-03-24gnu: When building in a VM, share a temporary directory....Chris Marusich 2018-03-24vm: Allow control of deduplication in root-partition-initializer....Chris Marusich 2018-03-16vm: Pass "-append ..." only once....Danny Milosavljevic 2018-03-15vm: Use 'invoke' instead of 'system*'....Ludovic Courtès 2018-01-19gnu: Consistently Write ‘file system(s)’....Tobias Geerinckx-Rice 2017-12-18vm: Pass the host's /dev/urandom to the guest at /dev/hwrng....Leo Famulari 2017-12-15vm: Adapt qemu command to ARM....Mathieu Othacehe 2017-12-13vm: Use qemu drive device parameter....Mathieu Othacehe