From 72ea60bb8d2de8353eb56768afc2ecae1b50a246 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Thu, 31 Mar 2016 19:26:11 +0000 Subject: [PATCH] separate has_shebang_line tests --- tests/Internals/bash | 1 + tests/Internals/empty | 1 + tests/Internals/empty-line | 5 +++++ tests/Internals/env | 1 + tests/Internals/has_shebang_line | 20 -------------------- tests/Internals/setup | 6 ++++++ tests/Internals/sh | 1 + urchin | 2 +- 8 files changed, 16 insertions(+), 21 deletions(-) create mode 100755 tests/Internals/bash create mode 100755 tests/Internals/empty create mode 100755 tests/Internals/empty-line create mode 100755 tests/Internals/env delete mode 100755 tests/Internals/has_shebang_line create mode 100755 tests/Internals/sh diff --git a/tests/Internals/bash b/tests/Internals/bash new file mode 100755 index 0000000..ea2bd0b --- /dev/null +++ b/tests/Internals/bash @@ -0,0 +1 @@ +run '!#/bin/bash' diff --git a/tests/Internals/empty b/tests/Internals/empty new file mode 100755 index 0000000..5486748 --- /dev/null +++ b/tests/Internals/empty @@ -0,0 +1 @@ +! run '' diff --git a/tests/Internals/empty-line b/tests/Internals/empty-line new file mode 100755 index 0000000..db0491e --- /dev/null +++ b/tests/Internals/empty-line @@ -0,0 +1,5 @@ +! run ' + + + +' diff --git a/tests/Internals/env b/tests/Internals/env new file mode 100755 index 0000000..c6f4a9b --- /dev/null +++ b/tests/Internals/env @@ -0,0 +1 @@ +run '!#/usr/bin/env true' diff --git a/tests/Internals/has_shebang_line b/tests/Internals/has_shebang_line deleted file mode 100755 index ad612f4..0000000 --- a/tests/Internals/has_shebang_line +++ /dev/null @@ -1,20 +0,0 @@ -TESTING_URCHIN_INTERNALS=true . ../../urchin - -echo '!#/bin/sh' > $tmp -! has_shebang_line $tmp - -echo '!#/bin/bash' > $tmp -has_shebang_line $tmp - -echo '!#/usr/bin/env true' > $tmp -has_shebang_line $tmp - -echo > $tmp -! has_shebang_line $tmp - -echo ' - - - -' > $tmp -! has_shebang_line $tmp diff --git a/tests/Internals/setup b/tests/Internals/setup index e01b6ff..35878ac 100644 --- a/tests/Internals/setup +++ b/tests/Internals/setup @@ -1 +1,7 @@ export tmp=$(mktemp) + +run() { + TESTING_URCHIN_INTERNALS=true . ../../urchin + echo "$1" > $tmp + has_shebang_line $tmp +} diff --git a/tests/Internals/sh b/tests/Internals/sh new file mode 100755 index 0000000..80fb3de --- /dev/null +++ b/tests/Internals/sh @@ -0,0 +1 @@ +! run '!#/bin/sh' diff --git a/urchin b/urchin index f3dc0d9..e369087 100755 --- a/urchin +++ b/urchin @@ -414,7 +414,7 @@ report_outcome() { } has_shebang_line() { - head -n 1 "${1}" | grep -q -v '^#!/bin/sh' + head -n 1 "${1}" | grep -v '^#!/bin/sh$' | grep -q '^#!' } USAGE="usage: $0 [options]... [test file or directory]..."