diff options
author | Igor Ostapenko <igoro@FreeBSD.org> | 2024-10-05 10:19:31 +0000 |
---|---|---|
committer | Igor Ostapenko <igoro@FreeBSD.org> | 2024-10-05 10:22:22 +0000 |
commit | 99689201a1eb7bcd503987c5220b79330dc058b7 (patch) | |
tree | 6c05c3ab71e46b6babe3c5daad0ca9ff2fe9902e /contrib/kyua/model | |
parent | 9f146a81d2b33cfed0d5a494e798100c4e4f2a72 (diff) |
kyua: Do not count skipped as passed in test cmd
It changes output of 'kyua test' CLI command only. Hence, other outputs
like junit are kept intact for CI and other use cases. It's meant to
improve UX of attended use cases.
The issue is that the following can be tricky to interpret:
222/222 passed (0 failed)
It can be read as all tests are passed, but it might be a summary line
of all tests skipped due to some requirement is not met.
It's reworked to easily distinguish such cases:
222/222 passed (0 broken, 0 failed, 0 skipped)
0/222 passed (0 broken, 0 failed, 222 skipped)
The overall formula is:
<actually passed>/<total> (<details about not actually passed ones>)
Suggested by: kp
Reviewed by: ngie, markj
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D46653
Diffstat (limited to 'contrib/kyua/model')
-rw-r--r-- | contrib/kyua/model/test_result.cpp | 48 | ||||
-rw-r--r-- | contrib/kyua/model/test_result.hpp | 15 |
2 files changed, 52 insertions, 11 deletions
diff --git a/contrib/kyua/model/test_result.cpp b/contrib/kyua/model/test_result.cpp index 7392e77f5561..f3e1b66f260b 100644 --- a/contrib/kyua/model/test_result.cpp +++ b/contrib/kyua/model/test_result.cpp @@ -35,6 +35,42 @@ namespace text = utils::text; +const std::map<enum model::test_result_type, + const struct model::test_result_type_desc> + model::test_result_types = +{ + { test_result_broken, + { .id = test_result_broken, + .name = "broken", + .is_run = true, + .is_good = false, } }, + + { test_result_expected_failure, + { .id = test_result_expected_failure, + .name = "xfail", + .is_run = true, + .is_good = true, } }, + + { test_result_failed, + { .id = test_result_failed, + .name = "failed", + .is_run = true, + .is_good = false, } }, + + { test_result_passed, + { .id = test_result_passed, + .name = "passed", + .is_run = true, + .is_good = true, } }, + + { test_result_skipped, + { .id = test_result_skipped, + .name = "skipped", + .is_run = false, + .is_good = true, } }, +}; + + /// Constructs a base result. /// /// \param type_ The type of the result. @@ -74,17 +110,7 @@ model::test_result::reason(void) const bool model::test_result::good(void) const { - switch (_type) { - case test_result_expected_failure: - case test_result_passed: - case test_result_skipped: - return true; - - case test_result_broken: - case test_result_failed: - return false; - } - UNREACHABLE; + return test_result_types.at(_type).is_good; } diff --git a/contrib/kyua/model/test_result.hpp b/contrib/kyua/model/test_result.hpp index b9c439ce789a..33c76124550f 100644 --- a/contrib/kyua/model/test_result.hpp +++ b/contrib/kyua/model/test_result.hpp @@ -34,12 +34,27 @@ #include "model/test_result_fwd.hpp" +#include <map> #include <ostream> #include <string> namespace model { +/// Test result type metadata. +struct test_result_type_desc { + enum test_result_type id; + std::string name; + bool is_run; + bool is_good; +}; + + +/// Description of each test result type. +extern const std::map<enum test_result_type, + const struct test_result_type_desc> test_result_types; + + /// Representation of a single test result. /// /// A test result is a simple pair of (type, reason). The type indicates the |