[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master ca3ce61 2/5: Return non-zero exit code on the
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master ca3ce61 2/5: Return non-zero exit code on the GUI test failure |
Date: |
Mon, 2 Nov 2020 17:01:13 -0500 (EST) |
branch: master
commit ca3ce61efcc497dee415a8ac3f184dc953deb5f6
Author: Ilya Sinitsyn <isinitsyn@tt-solutions.com>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Return non-zero exit code on the GUI test failure
The main reason to return EXIT_FAILURE if the test was failed is showing
the right status of the test in GitHub CI checks.
---
main_wx_test.cpp | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/main_wx_test.cpp b/main_wx_test.cpp
index 1fd33c4..293f22e 100644
--- a/main_wx_test.cpp
+++ b/main_wx_test.cpp
@@ -175,6 +175,9 @@ class application_test final
// Used to check if distribution tests should be enabled.
bool is_distribution_test() const { return is_distribution_test_; }
+ // Returns the exit code based of tests results.
+ int get_exit_code() const { return exit_code_; }
+
private:
application_test() = default;
application_test(application_test const&) = delete;
@@ -231,6 +234,8 @@ class application_test final
bool run_all_ {true};
bool is_distribution_test_ {false};
+
+ int exit_code_ {EXIT_FAILURE};
};
application_test& application_test::instance()
@@ -509,6 +514,8 @@ TestsResults application_test::run()
}
}
+ exit_code_ = results.failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+
return results;
}
@@ -645,6 +652,7 @@ class SkeletonTest final : public Skeleton
// wxApp overrides.
bool OnInit () override;
+ int OnRun () override;
bool OnExceptionInMainLoop () override;
bool StoreCurrentException () override;
void RethrowStoredException () override;
@@ -711,6 +719,20 @@ bool SkeletonTest::OnInit()
return true;
}
+int SkeletonTest::OnRun()
+{
+ int exit_code = Skeleton::OnRun();
+
+ // If the application exited successfully then return the exit code
+ // based on test results.
+ if(exit_code == 0)
+ {
+ exit_code = application_test::instance().get_exit_code();
+ }
+
+ return exit_code;
+}
+
bool SkeletonTest::StoreCurrentException()
{
// We store all the exceptions that are expected to be caught by the tests