Skip to content

Commit

Permalink
Add test Makefile target
Browse files Browse the repository at this point in the history
  • Loading branch information
weisslj committed Dec 19, 2015
1 parent bd80a1d commit e158728
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*.o
/test
/testprog
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ CXX = g++
WARN_FLAGS = -O3 -g -Wall -Wextra -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wstrict-null-sentinel -Woverloaded-virtual -Wshadow -Wcast-align -Wpointer-arith -Wwrite-strings -Wundef -Wredundant-decls -Werror # -Weffc++
endif

BIN = test
OBJECTS = OptionParser.o test.o
BIN = testprog
OBJECTS = OptionParser.o testprog.o

$(BIN): $(OBJECTS)
$(CXX) -o $@ $(OBJECTS) $(WARN_FLAGS) $(LINKFLAGS)

%.o: %.cpp OptionParser.h
$(CXX) $(WARN_FLAGS) $(CXXFLAGS) -c $< -o $@

.PHONY: clean
.PHONY: clean test

test: testprog
./test.sh

clean:
rm -f *.o $(BIN)
File renamed without changes.
6 changes: 3 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# vim: set filetype=sh fileencoding=utf-8 expandtab sw=4 sts=4:

c () {
echo "$(printf "%q " ./test "$@")"
echo "$(printf "%q " ./testprog "$@")"
local t_stdout_cpp=$(mktemp --tmpdir cpp-stdout-optparse.XXXXXXXXXX)
local t_stderr_cpp=$(mktemp --tmpdir cpp-stderr-optparse.XXXXXXXXXX)
local t_stdout_pyt=$(mktemp --tmpdir pyt-stdout-optparse.XXXXXXXXXX)
local t_stderr_pyt=$(mktemp --tmpdir pyt-stderr-optparse.XXXXXXXXXX)
./test "$@" >"$t_stdout_cpp" 2>"$t_stderr_cpp"
./testprog "$@" >"$t_stdout_cpp" 2>"$t_stderr_cpp"
status_cpp=$?
./t/test "$@" >"$t_stdout_pyt" 2>"$t_stderr_pyt"
./t/testprog "$@" >"$t_stdout_pyt" 2>"$t_stderr_pyt"
status_pyt=$?
if ! cmp -s "$t_stderr_cpp" "$t_stderr_pyt" ; then
diff -u "$t_stderr_cpp" "$t_stderr_pyt"
Expand Down
File renamed without changes.

0 comments on commit e158728

Please sign in to comment.