Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test target to base makefile and the libs makefile.
This introduces a script called unittests.sh which locates all files matching test_*.pro and then runs the tests those are expected to generate and complains if either the tests fail or it can't find the test executable. This script is run on both make test in the mythtv directory and make test in the mythtv/libs directory. The lib*/test directories have been added to the subdirs that libs.pro compiles and a clean of the test_mythtimer.pro target has been added. This allows a make in mythtv or mythtv/libs to compile the unit test and a make clean to remove it. It would be nice to have these targets work from mythtv/libs/libmythbase, but I don't know how to do that with the current .pro file arrangement. Note: This and the MythTimer unit test are intended as templates for other unit tests. Any suggestions for improvement are welcome.
- Loading branch information
1 parent
a5d37fe
commit 8e0a73d
Showing
7 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include (../../../settings.pro) | ||
|
||
TEMPLATE = subdirs | ||
|
||
SUBDIRS += test_* | ||
|
||
unittest.target = test | ||
unittest.commands = ../../../programs/scripts/unittests.sh | ||
unix:QMAKE_EXTRA_TARGETS += unittest |
File renamed without changes.
File renamed without changes.
8 changes: 5 additions & 3 deletions
8
.../libs/libmythbase/test/test_mythtimer.pro → ...se/test/test_mythtimer/test_mythtimer.pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
include ( ../../../settings.pro ) | ||
include ( ../../../../settings.pro ) | ||
|
||
CONFIG += qtestlib | ||
TEMPLATE = app | ||
TARGET = test_mythtimer | ||
DEPENDPATH += . .. | ||
INCLUDEPATH += . .. | ||
DEPENDPATH += . ../.. | ||
INCLUDEPATH += . ../.. | ||
|
||
# Input | ||
HEADERS += test_mythtimer.h | ||
SOURCES += test_mythtimer.cpp | ||
|
||
HEADERS += mythtimer.h | ||
SOURCES += mythtimer.cpp | ||
|
||
QMAKE_CLEAN += $(TARGET) $(TARGETA) $(TARGETD) $(TARGET0) $(TARGET1) $(TARGET2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
# | ||
# unittests.sh runs all unit tests and returns 0 if all are successful | ||
|
||
DIRNAME=`which dirname` | ||
BASENAME=`which basename` | ||
SED=`which sed` | ||
TEST_FAILED=0 | ||
|
||
|
||
TESTS=`find -name "test_*.pro"` | ||
|
||
for TEST in $TESTS | ||
do | ||
PATH=`$DIRNAME $TEST` | ||
EXEC=`$BASENAME $TEST | $SED -e 's/.pro//'` | ||
RUNNABLE=$PATH/$EXEC | ||
if test -x $RUNNABLE -a -f $RUNNABLE ; then | ||
if ./$RUNNABLE ; then | ||
echo | ||
else | ||
echo "error: A unit test failed." | ||
TEST_FAILED=1 | ||
fi | ||
else | ||
echo "Unable to find test $RUNNABLE, marking as a failed unit test." | ||
TEST_FAILED=1 | ||
fi | ||
done | ||
|
||
if test "x$TEST_FAILED" != "x0" ; then | ||
echo "error: At least one unit test failed, returning 1" | ||
fi | ||
|
||
exit $TEST_FAILED |