From 7570271f7e1ede3ef65808f859597001338a7fe6 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Thu, 24 Nov 2016 17:32:00 +0100 Subject: [PATCH] add option to skip tests requiring a display --- .travis.yml | 6 +++--- Makefile | 6 +++++- scripts/docker/exec.bash | 2 +- tst/integration/InvocationTest.cpp | 2 +- tst/integration/StandaloneTest.cpp | 2 +- tst/test.cpp | 20 +++++++++++++++++--- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index f83818b..402b55a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,11 +11,11 @@ services: matrix: include: - env: "IMAGE=archlinux-build TARGETS=codecov" - - env: "IMAGE=debian-build:latest TARGETS=test" - - env: "IMAGE=debian-build:testing TARGETS=test" + - env: "IMAGE=debian-build:latest TARGETS=unittest" + - env: "IMAGE=debian-build:testing TARGETS=unittest" - env: "IMAGE=ubuntu-build:latest TARGETS=test" - env: "IMAGE=ubuntu-build:devel TARGETS=test" - - env: "IMAGE=centos-build:latest TARGETS=test" + - env: "IMAGE=centos-build:latest TARGETS=unittest" script: - bash scripts/docker/exec.bash diff --git a/Makefile b/Makefile index a2e0d37..bb382a7 100644 --- a/Makefile +++ b/Makefile @@ -154,6 +154,10 @@ test: $(TEST_BIN) $(TEST_TEST_BIN) $(ASSET_DEP) @echo run: test.test @./test.test +unittest: $(TEST_BIN) $(TEST_TEST_BIN) $(ASSET_DEP) + @echo run: test.test --headless + @./test.test --headless + coverage: $(COVER_BIN) $(COVER_TEST_BIN) $(ASSET_DEP) @echo run: test.cover @./test.cover @@ -177,7 +181,7 @@ distclean: clean rm -f $(BIN) cachegrind.out.* callgrind.out.* rm -Rf build client-saves saves -.PHONY: all release cover debug profile tests run gdb cachegrind callgrind test coverage codecov lint clean distclean +.PHONY: all release cover debug profile tests run gdb cachegrind callgrind test unittest coverage codecov lint clean distclean -include $(DEP) diff --git a/scripts/docker/exec.bash b/scripts/docker/exec.bash index 3ba2d6f..ea6f97d 100755 --- a/scripts/docker/exec.bash +++ b/scripts/docker/exec.bash @@ -13,7 +13,7 @@ image_path="scripts/docker/${IMAGE//:/-}" xvfb_cmd="xvfb-run -a --server-args='-screen 0 1024x768x24 +extension RANDR +extension GLX'" -build_cmd="git clone /repo /workdir && cd /workdir && make -j\$(nproc) $TARGETS" +build_cmd="cp -R /repo /workdir && cd /workdir && make -j\$(nproc) $TARGETS" if [[ "$KEEP" != "" ]]; then build_cmd="${build_cmd} && cp -Rv $KEEP /repo" diff --git a/tst/integration/InvocationTest.cpp b/tst/integration/InvocationTest.cpp index 0d4c52c..fd9c98f 100644 --- a/tst/integration/InvocationTest.cpp +++ b/tst/integration/InvocationTest.cpp @@ -2,7 +2,7 @@ #include "TestInstance.hpp" -CPPUNIT_TEST_SUITE_REGISTRATION(blank::test::InvocationTest); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(blank::test::InvocationTest, "integration"); namespace blank { diff --git a/tst/integration/StandaloneTest.cpp b/tst/integration/StandaloneTest.cpp index d008ec8..40930a7 100644 --- a/tst/integration/StandaloneTest.cpp +++ b/tst/integration/StandaloneTest.cpp @@ -2,7 +2,7 @@ #include "TestInstance.hpp" -CPPUNIT_TEST_SUITE_REGISTRATION(blank::test::StandaloneTest); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(blank::test::StandaloneTest, "integration"); namespace blank { diff --git a/tst/test.cpp b/tst/test.cpp index f95ead3..0424467 100644 --- a/tst/test.cpp +++ b/tst/test.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -5,10 +6,23 @@ using CppUnit::TestFactoryRegistry; using CppUnit::TextUi::TestRunner; -int main(int, char **) { +int main(int argc, char **argv) { + + bool headless = false; + if (argc > 1 && std::strcmp(argv[1], "--headless") == 0) { + headless = true; + } + TestRunner runner; - TestFactoryRegistry ®istry = TestFactoryRegistry::getRegistry(); - runner.addTest(registry.makeTest()); + { + TestFactoryRegistry ®istry = TestFactoryRegistry::getRegistry(); + runner.addTest(registry.makeTest()); + } + if (!headless) { + TestFactoryRegistry ®istry = TestFactoryRegistry::getRegistry("integration"); + runner.addTest(registry.makeTest()); + } + if (runner.run()) { return 0; } else { -- 2.39.2