pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/regress/infra-unittests regress: add test for portabil...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2b9dca647c93
branches:  trunk
changeset: 444323:2b9dca647c93
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Jan 04 21:07:31 2021 +0000

description:
regress: add test for portability check in configure~ files

diffstat:

 regress/infra-unittests/check-portability.sh |  51 ++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 2 deletions(-)

diffs (70 lines):

diff -r cc6859351cb5 -r 2b9dca647c93 regress/infra-unittests/check-portability.sh
--- a/regress/infra-unittests/check-portability.sh      Mon Jan 04 18:57:47 2021 +0000
+++ b/regress/infra-unittests/check-portability.sh      Mon Jan 04 21:07:31 2021 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: check-portability.sh,v 1.5 2020/05/11 19:13:10 rillig Exp $
+# $NetBSD: check-portability.sh,v 1.6 2021/01/04 21:07:31 rillig Exp $
 #
 # Test cases for mk/check/check-portability.*.
 #
@@ -8,7 +8,7 @@
 
 . "./test.subr"
 
-# Runs the shell program for the given file.
+# Runs the shell program for all files in the current directory.
 check_portability_sh() {
        env     PATCHDIR='patches' \
                PREFIX='/nonexistent' \
@@ -245,3 +245,50 @@
 
        test_case_end
 fi
+
+
+if test_case_begin 'always skip tilde files'; then
+
+
+       # Projects that use GNU autoconf 2.70 are reported to include
+       # backup files like 'configure~' in their distribution, for
+       # whatever reason.  Since these files are not used by pkgsrc,
+       # they should be ignored.
+       #
+       # Since the filename is not one of the well-known ones, the file
+       # must start with a '#!' line to be actually recognized as a shell
+       # program.
+       create_file_lines 'configure~' \
+               '#! /bin/sh' \
+               'test a == b'
+
+       check_portability_sh \
+               'CHECK_PORTABILITY_EXPERIMENTAL=no'
+
+       create_file 'expected' <<'EOF'
+ERROR: [check-portability.awk] => Found test ... == ...:
+ERROR: [check-portability.awk] configure~:2: test a == b
+
+Explanation:
+===========================================================================
+The "test" command, as well as the "[" command, are not required to know
+the "==" operator. Only a few implementations like bash and some
+versions of ksh support it.
+
+When you run "test foo == foo" on a platform that does not support the
+"==" operator, the result will be "false" instead of "true". This can
+lead to unexpected behavior.
+
+There are two ways to fix this error message. If the file that contains
+the "test ==" is needed for building the package, you should create a
+patch for it, replacing the "==" operator with "=". If the file is not
+needed, add its name to the CHECK_PORTABILITY_SKIP variable in the
+package Makefile.
+===========================================================================
+
+EOF
+       assert_that "$tmpdir/out" --file-equals 'expected'
+       assert_that $exitcode --equals 1
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index