Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102067947
D46653.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D46653.diff
View Options
diff --git a/contrib/kyua/cli/cmd_test.cpp b/contrib/kyua/cli/cmd_test.cpp
--- a/contrib/kyua/cli/cmd_test.cpp
+++ b/contrib/kyua/cli/cmd_test.cpp
@@ -64,11 +64,8 @@
bool _parallel;
public:
- /// The amount of positive test results found so far.
- unsigned long good_count;
-
- /// The amount of negative test results found so far.
- unsigned long bad_count;
+ /// The amount of test results per type.
+ std::map<enum model::test_result_type, unsigned long> type_count;
/// Constructor for the hooks.
///
@@ -76,10 +73,10 @@
/// \param parallel_ True if we are executing more than one test at once.
print_hooks(cmdline::ui* ui_, const bool parallel_) :
_ui(ui_),
- _parallel(parallel_),
- good_count(0),
- bad_count(0)
+ _parallel(parallel_)
{
+ for (const auto& pair : model::test_result_types)
+ type_count[pair.first] = 0;
}
/// Called when the processing of a test case begins.
@@ -116,10 +113,8 @@
}
_ui->out(F("%s [%s]") % cli::format_result(result) %
cli::format_delta(duration));
- if (result.good())
- good_count++;
- else
- bad_count++;
+
+ type_count[result.type()]++;
}
};
@@ -159,8 +154,21 @@
kyuafile_path(cmdline), build_root_path(cmdline), results.second,
parse_filters(cmdline.arguments()), user_config, hooks);
+ unsigned long total = 0;
+ unsigned long good = 0;
+ unsigned long bad = 0;
+ for (const auto& pair : model::test_result_types) {
+ const auto& type = pair.second;
+ const auto count = hooks.type_count[type.id];
+ total += count;
+ if (type.is_run && type.is_good)
+ good += count;
+ if (!type.is_good)
+ bad += count;
+ }
+
int exit_code;
- if (hooks.good_count > 0 || hooks.bad_count > 0) {
+ if (total > 0) {
ui->out("");
if (!results.first.empty()) {
ui->out(F("Results file id is %s") % results.first);
@@ -168,10 +176,20 @@
ui->out(F("Results saved to %s") % results.second);
ui->out("");
- ui->out(F("%s/%s passed (%s failed)") % hooks.good_count %
- (hooks.good_count + hooks.bad_count) % hooks.bad_count);
+ ui->out(F("%s/%s passed (") % good % total, false);
+ const auto& types = model::test_result_types;
+ for (auto it = types.begin(); it != types.end(); it++) {
+ const auto& type = it->second;
+ if (!type.is_run || !type.is_good) {
+ if (it != types.begin())
+ ui->out(", ", false);
+ ui->out(F("%s %s") % hooks.type_count[type.id] % type.name,
+ false);
+ }
+ }
+ ui->out(")");
- exit_code = (hooks.bad_count == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit_code = (bad == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
} else {
// TODO(jmmv): Delete created empty file; it's useless!
if (!results.first.empty()) {
diff --git a/contrib/kyua/integration/cmd_test_test.sh b/contrib/kyua/integration/cmd_test_test.sh
--- a/contrib/kyua/integration/cmd_test_test.sh
+++ b/contrib/kyua/integration/cmd_test_test.sh
@@ -44,7 +44,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-2/2 passed (0 failed)
+1/2 passed (0 broken, 0 failed, 1 skipped)
EOF
utils_cp_helper simple_all_pass .
@@ -69,7 +69,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-1/2 passed (1 failed)
+1/2 passed (0 broken, 1 failed, 0 skipped)
EOF
utils_cp_helper simple_some_fail .
@@ -102,7 +102,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-7/7 passed (0 failed)
+3/7 passed (0 broken, 0 failed, 4 skipped)
EOF
utils_cp_helper simple_all_pass first
@@ -138,7 +138,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-4/7 passed (3 failed)
+3/7 passed (0 broken, 3 failed, 1 skipped)
EOF
utils_cp_helper simple_some_fail first
@@ -172,7 +172,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-5/5 passed (0 failed)
+5/5 passed (0 broken, 0 failed, 0 skipped)
EOF
# CHECK_STYLE_ENABLE
@@ -203,7 +203,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-1/6 passed (5 failed)
+1/6 passed (0 broken, 5 failed, 0 skipped)
EOF
# CHECK_STYLE_ENABLE
@@ -231,7 +231,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-1/3 passed (2 failed)
+1/3 passed (2 broken, 0 failed, 0 skipped)
EOF
# CHECK_STYLE_ENABLE
@@ -270,7 +270,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-3/4 passed (1 failed)
+2/4 passed (0 broken, 1 failed, 1 skipped)
EOF
atf_check -s exit:1 -o file:expout -e empty kyua test
}
@@ -302,7 +302,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-2/2 passed (0 failed)
+1/2 passed (0 broken, 0 failed, 1 skipped)
EOF
# CHECK_STYLE_ENABLE
atf_check -s exit:0 -o file:expout -e empty kyua test subdir
@@ -328,7 +328,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-1/1 passed (0 failed)
+0/1 passed (0 broken, 0 failed, 1 skipped)
EOF
atf_check -s exit:0 -o file:expout -e empty kyua test first:skip
}
@@ -354,7 +354,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-1/2 passed (1 failed)
+1/2 passed (0 broken, 1 failed, 0 skipped)
EOF
atf_check -s exit:1 -o file:expout -e empty kyua test second
}
@@ -402,7 +402,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-2/3 passed (1 failed)
+2/3 passed (0 broken, 1 failed, 0 skipped)
EOF
atf_check -s exit:1 -o file:expout -e empty kyua test subdir first:pass
}
@@ -470,7 +470,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-3/4 passed (1 failed)
+2/4 passed (0 broken, 1 failed, 1 skipped)
EOF
cat >experr <<EOF
@@ -515,7 +515,7 @@
Results file id is $(utils_results_id root)
Results saved to $(utils_results_file root)
-2/3 passed (1 failed)
+1/3 passed (0 broken, 1 failed, 1 skipped)
EOF
atf_check -s exit:1 -o file:expout -e empty kyua test \
-k "$(pwd)/root/Kyuafile" first subdir/fourth:fail
@@ -542,7 +542,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-2/2 passed (0 failed)
+1/2 passed (0 broken, 0 failed, 1 skipped)
EOF
CREATE_COOKIE="$(pwd)/cookie"; export CREATE_COOKIE
atf_check -s exit:0 -o file:expout -e empty kyua test first
@@ -612,7 +612,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-1/2 passed (1 failed)
+1/2 passed (0 broken, 1 failed, 0 skipped)
EOF
atf_check -s exit:1 -o file:expout -e empty kyua test
@@ -710,7 +710,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-6/6 passed (0 failed)
+3/6 passed (0 broken, 0 failed, 3 skipped)
EOF
mkdir build
@@ -745,7 +745,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-2/2 passed (0 failed)
+1/2 passed (0 broken, 0 failed, 1 skipped)
EOF
atf_check -s exit:0 -o file:expout -e empty kyua test -k myfile
atf_check -s exit:0 -o file:expout -e empty kyua test --kyuafile=myfile
@@ -774,7 +774,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-2/2 passed (0 failed)
+1/2 passed (0 broken, 0 failed, 1 skipped)
EOF
atf_check -s exit:0 -o file:expout -e empty kyua test -k myfile sometest
cat >expout <<EOF
@@ -784,7 +784,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-2/2 passed (0 failed)
+1/2 passed (0 broken, 0 failed, 1 skipped)
EOF
atf_check -s exit:0 -o file:expout -e empty kyua test --kyuafile=myfile \
sometest
@@ -987,7 +987,7 @@
Results file id is $(utils_results_id)
Results saved to $(utils_results_file)
-0/2 passed (2 failed)
+0/2 passed (2 broken, 0 failed, 0 skipped)
EOF
# CHECK_STYLE_ENABLE
atf_check -s exit:1 -o file:expout -e empty kyua test
diff --git a/contrib/kyua/model/test_result.hpp b/contrib/kyua/model/test_result.hpp
--- 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
diff --git a/contrib/kyua/model/test_result.cpp b/contrib/kyua/model/test_result.cpp
--- 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 @@
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;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 8, 5:30 AM (21 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14513659
Default Alt Text
D46653.diff (10 KB)
Attached To
Mode
D46653: kyua: Do not count skipped as passed in test cmd
Attached
Detach File
Event Timeline
Log In to Comment