[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [6005] Skip tests for document types unsupported in contex
From: |
Greg Chicares |
Subject: |
[lmi-commits] [6005] Skip tests for document types unsupported in context |
Date: |
Tue, 28 Oct 2014 12:17:51 +0000 |
Revision: 6005
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6005
Author: chicares
Date: 2014-10-28 12:17:51 +0000 (Tue, 28 Oct 2014)
Log Message:
-----------
Skip tests for document types unsupported in context
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/main_wx_test.cpp
lmi/trunk/wx_test_case.hpp
lmi/trunk/wx_test_create_open.cpp
lmi/trunk/wx_test_validate_output.cpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2014-10-28 11:51:15 UTC (rev 6004)
+++ lmi/trunk/ChangeLog 2014-10-28 12:17:51 UTC (rev 6005)
@@ -34435,3 +34435,12 @@
Alphabetize headers. See:
http://lists.nongnu.org/archive/html/lmi/2014-10/msg00087.html
+20141028T1217Z <address@hidden> [532]
+
+ main_wx_test.cpp
+ wx_test_case.hpp
+ wx_test_create_open.cpp
+ wx_test_validate_output.cpp
+Skip tests for document types unsupported in context. See:
+ http://lists.nongnu.org/archive/html/lmi/2014-10/msg00087.html
+
Modified: lmi/trunk/main_wx_test.cpp
===================================================================
--- lmi/trunk/main_wx_test.cpp 2014-10-28 11:51:15 UTC (rev 6004)
+++ lmi/trunk/main_wx_test.cpp 2014-10-28 12:17:51 UTC (rev 6005)
@@ -37,6 +37,7 @@
#include "uncopyable_lmi.hpp"
#include "wx_test_case.hpp"
+#include <wx/docview.h>
#include <wx/fileconf.h>
#include <wx/frame.h>
#include <wx/init.h> // wxEntry()
@@ -108,6 +109,20 @@
}
};
+/// Exception thrown if the test needs to be skipped.
+///
+/// This exception doesn't carry any extra information but just needs to have a
+/// distinct type to allow treating it differently in run().
+class test_skipped_exception
+ :public stealth_exception
+{
+ public:
+ test_skipped_exception(std::string const& what)
+ :stealth_exception(what)
+ {
+ }
+};
+
/// Simple struct collecting the statistics about the tests we ran.
///
/// Implicitly-declared special member functions do the right thing.
@@ -115,11 +130,17 @@
{
TestsResults()
:total(0)
+ ,passed(0)
+ ,skipped(0)
,failed(0)
{
}
+ // The sum of passed, skipped and failed is the same as total (except when
+ // a test is in process of execution and its result is yet unknown).
int total,
+ passed,
+ skipped,
failed;
};
@@ -348,7 +369,13 @@
wxStopWatch sw;
i->run_test();
wxLogMessage("%s%s: ok (%ldms)", indent, i->get_name(),
sw.Time());
+ results.passed++;
}
+ catch(test_skipped_exception const& e)
+ {
+ wxLogMessage("%s%s: skipped (%s)", indent, i->get_name(),
e.what());
+ results.skipped++;
+ }
catch(std::exception const& e)
{
error = e.what();
@@ -431,6 +458,20 @@
return application_test::instance().get_config_for(get_name());
}
+void wx_base_test_case::skip_if_not_supported(char const* file)
+{
+ const wxString p(file);
+ if(!wxDocManager::GetDocumentManager()->FindTemplateForPath(p))
+ {
+ throw test_skipped_exception
+ (wxString::Format
+ ("documents with extension \"%s\" not supported"
+ ,p.AfterLast('.')
+ ).ToStdString()
+ );
+ }
+}
+
// Application to drive the tests
class SkeletonTest : public Skeleton
{
@@ -593,24 +634,39 @@
TestsResults const results = application_test::instance().run();
is_running_tests_ = false;
- if (results.total == 0)
+ if(results.failed == 0)
{
- wxLogMessage("WARNING: no tests have been executed.");
+ if(results.passed == 0)
+ {
+ wxLogMessage("WARNING: no tests have been executed.");
+ }
+ else
+ {
+ wxLogMessage
+ ("SUCCESS: %d test%s successfully completed in %ldms."
+ ,results.passed
+ ,results.passed == 1 ? "" : "s"
+ ,sw.Time()
+ );
+ }
}
- else if (results.failed == 0)
+ else
{
wxLogMessage
- ("SUCCESS: %d tests successfully completed in %ldms."
+ ("FAILURE: %d out of %d test%s failed."
+ ,results.failed
,results.total
- ,sw.Time()
+ ,results.total == 1 ? "" : "s"
);
}
- else
+
+ if(results.skipped)
{
wxLogMessage
- ("FAILURE: %d out of %d tests failed."
- ,results.failed
- ,results.total
+ ("(%s skipped)"
+ ,results.skipped == 1
+ ? wxString("1 test was")
+ : wxString::Format("%d tests were", results.skipped)
);
}
Modified: lmi/trunk/wx_test_case.hpp
===================================================================
--- lmi/trunk/wx_test_case.hpp 2014-10-28 11:51:15 UTC (rev 6004)
+++ lmi/trunk/wx_test_case.hpp 2014-10-28 12:17:51 UTC (rev 6005)
@@ -49,6 +49,22 @@
// dtor doesn't really need to be virtual.
virtual ~wx_base_test_case() { }
+ /// Skip the test if the specified file is not supported.
+ ///
+ /// Check if the possibility to open such files is provided by the program
+ /// in its current configuration: some file types are conditionally enabled
+ /// only if special command line arguments are provided, so it is normal
+ /// for them to not be available and this shouldn't result in the test
+ /// errors.
+ ///
+ /// Notice that this method needs to be public to be usable from helpers of
+ /// the tests and not just from the test code itself.
+ ///
+ /// The file doesn't need to exist, but must have the correct extension.
+ ///
+ /// Throws test_skipped_exception if the file is not supported.
+ void skip_if_not_supported(char const* file);
+
protected:
/// The argument must be a literal, as we just store the pointer.
explicit wx_base_test_case(char const* name);
Modified: lmi/trunk/wx_test_create_open.cpp
===================================================================
--- lmi/trunk/wx_test_create_open.cpp 2014-10-28 11:51:15 UTC (rev 6004)
+++ lmi/trunk/wx_test_create_open.cpp 2014-10-28 12:17:51 UTC (rev 6005)
@@ -46,8 +46,14 @@
// ready for this dialog appearing and, second, "File|Save" menu command is
// disabled for the files created in this way and "File|Save as" needs to
// be used instead.
-void do_test_create_open(int key, wxString const& file, bool uses_dialog)
+void do_test_create_open
+ (wx_base_test_case& test
+ ,int key
+ ,wxString const& file
+ ,bool uses_dialog)
{
+ test.skip_if_not_supported(file.c_str());
+
LMI_ASSERT(!wxFileExists(file));
wxUIActionSimulator z;
@@ -100,45 +106,45 @@
LMI_WX_TEST_CASE(create_open_census)
{
- do_test_create_open('c', "testfile.cns", false);
+ do_test_create_open(*this, 'c', "testfile.cns", false);
}
LMI_WX_TEST_CASE(create_open_illustration)
{
- do_test_create_open('i', "testfile.ill", true);
+ do_test_create_open(*this, 'i', "testfile.ill", true);
}
LMI_WX_TEST_CASE(create_open_database)
{
- do_test_create_open('d', "testfile.database", false);
+ do_test_create_open(*this, 'd', "testfile.database", false);
}
LMI_WX_TEST_CASE(create_open_policy)
{
- do_test_create_open('p', "testfile.policy", false);
+ do_test_create_open(*this, 'p', "testfile.policy", false);
}
LMI_WX_TEST_CASE(create_open_rounding)
{
- do_test_create_open('r', "testfile.rounding", false);
+ do_test_create_open(*this, 'r', "testfile.rounding", false);
}
LMI_WX_TEST_CASE(create_open_strata)
{
- do_test_create_open('s', "testfile.strata", false);
+ do_test_create_open(*this, 's', "testfile.strata", false);
}
LMI_WX_TEST_CASE(create_open_mec)
{
- do_test_create_open('m', "testfile.mec", true);
+ do_test_create_open(*this, 'm', "testfile.mec", true);
}
LMI_WX_TEST_CASE(create_open_gpt)
{
- do_test_create_open('g', "testfile.gpt", true);
+ do_test_create_open(*this, 'g', "testfile.gpt", true);
}
LMI_WX_TEST_CASE(create_open_text)
{
- do_test_create_open('x', "testfile.txt", false);
+ do_test_create_open(*this, 'x', "testfile.txt", false);
}
Modified: lmi/trunk/wx_test_validate_output.cpp
===================================================================
--- lmi/trunk/wx_test_validate_output.cpp 2014-10-28 11:51:15 UTC (rev
6004)
+++ lmi/trunk/wx_test_validate_output.cpp 2014-10-28 12:17:51 UTC (rev
6005)
@@ -153,6 +153,8 @@
LMI_WX_TEST_CASE(validate_output_mec)
{
+ skip_if_not_supported("unnamed.mec");
+
std::string const&
ext = configurable_settings::instance().spreadsheet_file_extension();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [6005] Skip tests for document types unsupported in context,
Greg Chicares <=