>From 9e6768d4efe82d1fcbf31a1dbfa7311774e6a3e1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 14 Dec 2014 22:41:06 +0100 Subject: [PATCH] Skip non-distribution tests instead of just not doing anything in them. Mark the tests not executed because they are specific to distribution testing and --distribution command line option was not given as skipped instead of just not doing anything in them. --- main_wx_test.cpp | 8 ++++++++ wx_test_case.hpp | 13 +++++++++++-- wx_test_config_settings.cpp | 5 +---- wx_test_default_input.cpp | 5 +---- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/main_wx_test.cpp b/main_wx_test.cpp index 5acb363..31d8a22 100644 --- a/main_wx_test.cpp +++ b/main_wx_test.cpp @@ -566,6 +566,14 @@ bool wx_base_test_case::is_distribution_test() const return application_test::instance().is_distribution_test(); } +void wx_base_test_case::skip_if_not_distribution() +{ + if(!is_distribution_test()) + { + throw test_skipped_exception("not running distribution tests"); + } +} + // Application to drive the tests class SkeletonTest : public Skeleton { diff --git a/wx_test_case.hpp b/wx_test_case.hpp index 7a6ae9e..71b48b1 100644 --- a/wx_test_case.hpp +++ b/wx_test_case.hpp @@ -80,10 +80,19 @@ class wx_base_test_case /// Return true if running in distribution testing mode. /// - /// This method is used to restrict execution of the tests that are - /// specific to the binary program distribution. + /// This method is used to partially skip execution of the tests that are + /// specific to the binary program distribution. If the entire test should + /// be skipped, prefer to use skip_if_not_distribution() instead. bool is_distribution_test() const; + /// Skip the test if not running in distribution testing mode. + /// + /// This method can be used to skip execution of a test entirely unless + /// --distribution command line option was specified. + /// + /// Throws test_skipped_exception if the distribution option was not given. + void skip_if_not_distribution(); + protected: /// The argument must be a literal, as we just store the pointer. explicit wx_base_test_case(char const* name); diff --git a/wx_test_config_settings.cpp b/wx_test_config_settings.cpp index 4d96e61..2c80161 100644 --- a/wx_test_config_settings.cpp +++ b/wx_test_config_settings.cpp @@ -82,10 +82,7 @@ LMI_WX_TEST_CASE(configurable_settings) { - if(!is_distribution_test()) - { - return; - } + skip_if_not_distribution(); LMI_ASSERT(fs::exists("/etc/opt/lmi/configurable_settings.xml")); diff --git a/wx_test_default_input.cpp b/wx_test_default_input.cpp index 682c1f0..44c5e40 100644 --- a/wx_test_default_input.cpp +++ b/wx_test_default_input.cpp @@ -64,10 +64,7 @@ LMI_WX_TEST_CASE(default_input) { - if(!is_distribution_test()) - { - return; - } + skip_if_not_distribution(); Input const& cell = default_cell(); calendar_date effective_date; -- 1.7.9