Skip to content

Commit c54b643

Browse files
committed
Added unit test scripts to CI GitHub workflow.
1 parent 04ec3c7 commit c54b643

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on: push
2+
3+
jobs:
4+
Scripts:
5+
name: "Unit Test Scripts"
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- name: Install Lua
10+
run: |
11+
sudo apt-get update
12+
sudo apt-get install -y lua5.4
13+
14+
- uses: actions/checkout@v4
15+
16+
- name: Run script unit tests
17+
run: |
18+
find test -name test.sh -executable -print -execdir ./{} \;

test/DIFF/test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ test_case() {
99
cp "case$1"/* result
1010
cd "result" || die
1111
$INTERP $SCRIPT a.txt b.txt > "diff"
12-
patch -s --batch -p0 < "diff"
12+
patch -s --posix --batch -p0 < "diff"
1313
if cmp -s a.txt b.txt; then
14-
echo "CASE $1: PASS"
14+
printf "\tCASE %s: PASS\n" "$1"
1515
else
16-
echo "CASE $1: FAIL"
16+
printf "\tCASE %s: FAIL\n" "$1"
1717
FAIL=$((FAIL + 1))
1818
fi
1919
cd .. || die
2020
rm -R result
2121
}
22-
22+
echo "DIFF:"
2323
for i in $(seq -w 1 16); do test_case "$i"; done
2424
echo ""
25-
if [ $FAIL -gt 0 ]; then echo "$FAIL FAIL" exit 1; fi
26-
echo "ALL PASS"
25+
if [ $FAIL -gt 0 ]; then echo "DIFF: $FAIL FAIL" exit 1; fi
26+
echo "DIFF: ALL PASS"

test/MD5SUM/test.sh

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ GNU=$(md5sum $SCRIPT)
88
LUA=$($INTERP $SCRIPT $SCRIPT)
99

1010
if [ "$GNU" = "$LUA" ]; then
11-
echo "$TEST PASS"
11+
echo "$TEST: PASS"
1212
exit 0
1313
else
14-
echo "$TEST FAIL"
14+
echo "$TEST: FAIL"
1515
exit 1
1616
fi

test/S256SUM/test.sh

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ GNU=$(sha256sum $SCRIPT)
88
LUA=$($INTERP $SCRIPT $SCRIPT)
99

1010
if [ "$GNU" = "$LUA" ]; then
11-
echo "$TEST PASS"
11+
echo "$TEST: PASS"
1212
exit 0
1313
else
14-
echo "$TEST FAIL"
14+
echo "$TEST: FAIL"
1515
exit 1
1616
fi

0 commit comments

Comments
 (0)