Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
Return non-zero exit code on the GUI test failure
Browse files Browse the repository at this point in the history
The main reason to return EXIT_FAILURE if the test was failed is showing
the right status of the test in GitHub CI checks.
  • Loading branch information
thesiv authored and Gregory W. Chicares committed Nov 2, 2020
1 parent 5759e50 commit ca3ce61
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions main_wx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -509,6 +514,8 @@ TestsResults application_test::run()
}
}

exit_code_ = results.failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE;

return results;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ca3ce61

Please sign in to comment.