Source-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc mk/check/check-portability: fix error message when no ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/4c2163458291
branches:  trunk
changeset: 430845:4c2163458291
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon May 04 21:48:18 2020 +0000

description:
mk/check/check-portability: fix error message when no patches are found

diffstat:

 mk/check/check-portability.sh                |  13 +++++++++++--
 regress/infra-unittests/check-portability.sh |  20 +++++++++++++++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diffs (59 lines):

diff -r 48d2618c56a7 -r 4c2163458291 mk/check/check-portability.sh
--- a/mk/check/check-portability.sh     Mon May 04 21:33:08 2020 +0000
+++ b/mk/check/check-portability.sh     Mon May 04 21:48:18 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-portability.sh,v 1.20 2020/05/04 21:32:48 rillig Exp $
+# $NetBSD: check-portability.sh,v 1.21 2020/05/04 21:48:18 rillig Exp $
 #
 # This program checks all files in the current directory and any
 # subdirectories for portability issues that are likely to result in
@@ -34,7 +34,16 @@
        fi
 }
 
-patched_files=",$(awk 'BEGIN { ORS = "," } /^\+\+\+ / { print $2 }' "$PATCHDIR"/patch-*),"
+patched_files=",$(awk '
+       BEGIN {
+               if (ARGV[1] ~ /\/patch-\*$/)
+                       exit;
+               ORS = ","
+       }
+       /^\+\+\+ / {
+               print $2
+       }' \
+       "$PATCHDIR"/patch-*),"
 
 find ./* -type f -print 2>/dev/null \
 | sed 's,$,_,' \
diff -r 48d2618c56a7 -r 4c2163458291 regress/infra-unittests/check-portability.sh
--- a/regress/infra-unittests/check-portability.sh      Mon May 04 21:33:08 2020 +0000
+++ b/regress/infra-unittests/check-portability.sh      Mon May 04 21:48:18 2020 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: check-portability.sh,v 1.1 2020/05/04 21:32:48 rillig Exp $
+# $NetBSD: check-portability.sh,v 1.2 2020/05/04 21:48:18 rillig Exp $
 #
 # Test cases for mk/check/check-portability.*.
 #
@@ -175,3 +175,21 @@
 
        test_case_end
 fi
+
+
+if test_case_begin 'no patches'; then
+
+       # Ensure that no error message is printed when there are no
+       # patch files.
+
+       create_file_lines 'file' \
+               '#! /bin/sh' \
+               'test a = b'
+
+       check_portability_sh
+
+       assert_that 'out' --file-is-empty
+       assert_that $exitcode --equals 0
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index