aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2021-05-01 10:52:19 +0200
committerJan Sucan <jan@jansucan.com>2021-05-01 10:52:19 +0200
commit7e9034e80ea8ce4dc8a4635a42894e7294ecc85e (patch)
tree9dc99e2d2562c44a41e15a39480b378024f326db
parentf687e29c6e8a41393759bd170e9f94b2a797afe7 (diff)
tests: Add test for invoking with no arguments
-rw-r--r--Makefile7
-rw-r--r--tests/001-no_options_given.sh7
-rw-r--r--tests/Makefile4
3 files changed, 17 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 46a324f..c3ccaeb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
PROGRAM_NAME=diff-dd
PROGRAM_VERSION=1.0
+# Program name is used in the tests to locate the executable file
+export PROGRAM_NAME
CC=gcc
CFLAGS=-Wall
@@ -14,7 +16,10 @@ program_info_header:
echo "#define PROGRAM_NAME_STR \"$(PROGRAM_NAME)\"" >program_info.h
echo "#define PROGRAM_VERSION_STR \"$(PROGRAM_VERSION)\"" >>program_info.h
-.PHONY: clean
+.PHONY: test clean
+
+test: all
+ $(MAKE) -C tests
clean:
rm -f *.o *~ $(PROGRAM_NAME) program_info.h
diff --git a/tests/001-no_options_given.sh b/tests/001-no_options_given.sh
new file mode 100644
index 0000000..baa7af1
--- /dev/null
+++ b/tests/001-no_options_given.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+PROGRAM_EXEC="$1"
+
+$PROGRAM_EXEC 1>/dev/null 2>&1
+
+[ $? -ne 0 ] && exit 0 || exit 1
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..e202c55
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,4 @@
+PROGRAM_EXEC=../$(PROGRAM_NAME)
+
+all:
+ sh ./001-no_options_given.sh $(PROGRAM_EXEC)