~sircmpwn/ctools

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Make test scripts POSIX compliant

Details
Message ID
<20190924141245.27830-1-christopher.vittal@gmail.com>
DKIM signature
missing
Download raw message
Patch: +38 -20
"." with argument is not POSIX compliant, so it must be removed.
Instead, set tool directly in the test scripts.
---
This was the checkbashims output:

possible bashism in test/cat line 2 (sourced script with arguments):
. "$HARNESS" cat

 test/basename   | 3 ++-
 test/cat        | 3 ++-
 test/chgrp      | 3 ++-
 test/chmod      | 3 ++-
 test/chown      | 3 ++-
 test/cksum      | 3 ++-
 test/cmp        | 3 ++-
 test/comm       | 3 ++-
 test/dirname    | 3 ++-
 test/false      | 3 ++-
 test/harness.sh | 1 -
 test/head       | 3 ++-
 test/link       | 3 ++-
 test/logname    | 3 ++-
 test/nice       | 3 ++-
 test/rmdir      | 3 ++-
 test/true       | 3 ++-
 test/tty        | 3 ++-
 test/uname      | 3 ++-
 test/unlink     | 3 ++-
 20 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/test/basename b/test/basename
index c1d91eb..c69e996 100755
--- a/test/basename
+++ b/test/basename
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" basename
tool="basename"
. "$HARNESS"

should_handle_null_string() (
	bn="$(basename '')"
diff --git a/test/cat b/test/cat
index 65e8e3c..3be0ec1 100755
--- a/test/cat
+++ b/test/cat
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" cat
tool="cat"
. "$HARNESS"

echo "this is a test file" >"$TMPDIR"/test-file-1
echo "this is another test file" >"$TMPDIR"/test-file-2
diff --git a/test/chgrp b/test/chgrp
index 9306ee3..8918628 100755
--- a/test/chgrp
+++ b/test/chgrp
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" chgrp
tool="chgrp"
. "$HARNESS"

auxgroup=${AUXGROUP:-}
maingroup="$(id -gn)"
diff --git a/test/chmod b/test/chmod
index 8082927..d0a3c62 100755
--- a/test/chmod
+++ b/test/chmod
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" chmod
tool="chmod"
. "$HARNESS"

# TODO:
# - setuid/setguid/sticky
diff --git a/test/chown b/test/chown
index 6794db6..24ff0a6 100755
--- a/test/chown
+++ b/test/chown
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" chown
tool="chown"
. "$HARNESS"

auxgroup=${AUXGROUP:-}
mainuser=$(id -un)
diff --git a/test/cksum b/test/cksum
index 26559c3..d7ada82 100755
--- a/test/cksum
+++ b/test/cksum
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" cksum
tool="cksum"
. "$HARNESS"

should_handle_empty_stdin() (
	[ "$(cksum </dev/null)" = "4294967295 0" ]
diff --git a/test/cmp b/test/cmp
index 3d52ac0..37f874c 100755
--- a/test/cmp
+++ b/test/cmp
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" cmp
tool="cmp"
. "$HARNESS"

should_handle_samefile() (
	[ "$(cmp "$HARNESS" "$HARNESS")" = "" ]
diff --git a/test/comm b/test/comm
index 4d59a8b..d9c4c55 100755
--- a/test/comm
+++ b/test/comm
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" comm
tool="comm"
. "$HARNESS"

compare_with_ref() (
	ref=$(cat "$TMPDIR"/"$1")
diff --git a/test/dirname b/test/dirname
index c89b2d5..293bea7 100644
--- a/test/dirname
+++ b/test/dirname
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" dirname
tool="dirname"
. "$HARNESS"

should_handle_null_string() (
	dn="$(dirname '')"
diff --git a/test/false b/test/false
index 1ccd284..897e7f4 100755
--- a/test/false
+++ b/test/false
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" false
tool="false"
. "$HARNESS"

should_return_nonzero() {
	! false
diff --git a/test/harness.sh b/test/harness.sh
index 3541aa0..7854dc8 100644
--- a/test/harness.sh
+++ b/test/harness.sh
@@ -1,5 +1,4 @@
set -eu
tool="$1"

export PATH="$BUILDDIR/..:$PATH"
TMPDIR=${TMPDIR:-/tmp}
diff --git a/test/head b/test/head
index 445360b..954558c 100755
--- a/test/head
+++ b/test/head
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" head
tool="head"
. "$HARNESS"

should_read_from_stdin() (
	[ "$(echo Test Statement | head)" = "Test Statement" ]
diff --git a/test/link b/test/link
index 1d44b2f..bed7b17 100755
--- a/test/link
+++ b/test/link
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" link
tool="link"
. "$HARNESS"

should_make_link() {
	echo "hello world" >"$TMPDIR"/foo
diff --git a/test/logname b/test/logname
index bb5369b..96a4499 100755
--- a/test/logname
+++ b/test/logname
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" logname
tool="logname"
. "$HARNESS"

should_give_logname() {
	# These are not necessarily the same, but are usually so
diff --git a/test/nice b/test/nice
index d53163e..cfde2b0 100755
--- a/test/nice
+++ b/test/nice
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" cmp
tool="cmp"
. "$HARNESS"

should_set_niceness() {
	if [ "$(uname)" != "Linux" ]
diff --git a/test/rmdir b/test/rmdir
index 585a224..00c4a7b 100755
--- a/test/rmdir
+++ b/test/rmdir
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" link
tool="rmdir"
. "$HARNESS"

should_remove_dirs() {
	mkdir foo bar
diff --git a/test/true b/test/true
index aa475c0..57711f1 100755
--- a/test/true
+++ b/test/true
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" false
tool="true"
. "$HARNESS"

should_return_zero() {
	true
diff --git a/test/tty b/test/tty
index 40e417e..bc92d5a 100755
--- a/test/tty
+++ b/test/tty
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" cmp
tool="tty"
. "$HARNESS"

should_print_tty() {
	if [ "$(uname)" != "Linux" ]
diff --git a/test/uname b/test/uname
index b3934e4..40e5bf4 100755
--- a/test/uname
+++ b/test/uname
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" cmp
tool="uname"
. "$HARNESS"

sysname() {
	cat /proc/sys/kernel/ostype
diff --git a/test/unlink b/test/unlink
index ccaf2ae..f0aee22 100755
--- a/test/unlink
+++ b/test/unlink
@@ -1,5 +1,6 @@
#!/bin/sh
. "$HARNESS" unlink
tool="unlink"
. "$HARNESS"

should_remove_link() {
	touch "$TMPDIR"/file
--
2.20.1
Details
Message ID
<BX94ICXHVOPA.3TI39ZBP4I462@homura>
In-Reply-To
<20190924141245.27830-1-christopher.vittal@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Thanks!

To git.sr.ht:~sircmpwn/ctools
   0e9f63c..16cab05  master -> master
Review patch Export thread (mbox)