aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rwxr-xr-xsrc/tests/framework.sh41
-rwxr-xr-xsrc/tests/run-tests4
-rwxr-xr-xsrc/tests/test1.sh19
3 files changed, 9 insertions, 55 deletions
diff --git a/src/tests/framework.sh b/src/tests/framework.sh
deleted file mode 100755
index d6b7854..0000000
--- a/src/tests/framework.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-
-# $1 is the number of total tests
-function plan {
- TESTS=$1
- FAILED=0
- CUR_TEST=1
-
- echo "1..$TESTS"
-}
-
-function conclude {
- if [ $FAILED -ne 0 ]; then
- exit 1
- fi
-}
-
-# $1 is the value to be tested
-function ok {
- if [ $1 -eq 0 ]; then
- echo "ok $CUR_TEST"
- else
- echo "not ok $CUR_TEST"
- FAILED=$((FAILED + 1))
- fi
-
- CUR_TEST=$((CUR_TEST + 1))
-}
-
-# $1 is the expected value
-# $2 is the actual value
-function is {
- if [ "$1" = "$2" ]; then
- echo "ok $CUR_TEST"
- else
- echo "not ok $CUR_TEST - expected '$1', but got '$2'"
- FAILED=$((FAILED + 1))
- fi
-
- CUR_TEST=$((CUR_TEST + 1))
-}
diff --git a/src/tests/run-tests b/src/tests/run-tests
deleted file mode 100755
index f109b8c..0000000
--- a/src/tests/run-tests
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-echo "Test 1"
-./test1.sh
diff --git a/src/tests/test1.sh b/src/tests/test1.sh
index 52c2ba3..a432e5f 100755
--- a/src/tests/test1.sh
+++ b/src/tests/test1.sh
@@ -1,12 +1,11 @@
#!/bin/sh
-
-. ./framework.sh
-
-plan 2
-
-is "$(cat /proc/_test_module)" "You have no previous messages"
-
-echo kek > /proc/_test_module
-is "$(cat /proc/_test_module)" "Your last message was: kek"
-
+. libs/testing-library
+
+description "Test _test_module"
+plan 5
+is "$(cat /proc/_test_module)" "You have no previous messages" "No message read"
+ok $(echo kek > /proc/_test_module; echo "$?") "Successful write"
+is "$(cat /proc/_test_module)" "Your last message was: kek" "Message read"
+ok $(echo something > /proc/_test_module; echo "$?") "Successful write"
+is "$(cat /proc/_test_module)" "Your last message was: kek" "Message read"
conclude