diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-06-22 19:05:08 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-06-26 14:12:12 +0300 |
commit | 105524ed96f162b43c0735a65fea284d07356aa2 (patch) | |
tree | f083c65946faeb3654f9108112143ba46cee3656 /mod/mod-package-version-details.cxx | |
parent | 8e54ae94ce44d57b49b35269f006fe2bf07ec13d (diff) |
Adapt to merging of package external tests, examples, and benchmarks into typed tests
Diffstat (limited to 'mod/mod-package-version-details.cxx')
-rw-r--r-- | mod/mod-package-version-details.cxx | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index bfc08b0..a7682ec 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -397,38 +397,61 @@ handle (request& rq, response& rs) << ~TABLE; } - auto print_dependencies = [&s, &print_dependency] - (const small_vector<dependency, 1>& deps, - const char* heading, - const char* id) + // Print the test dependencies grouped by types as the separate blocks. + // + // Print test dependencies of the specific type. + // + auto print_tests = [&pkg, &s, &print_dependency] (test_dependency_type dt) { - if (!deps.empty ()) - { - s << H3 << heading << ~H3 - << TABLE(CLASS="proplist", ID=id) - << TBODY; + string id; - for (const dependency& d: deps) + bool first (true); + for (const test_dependency& td: pkg->tests) + { + if (td.type == dt) { + // Print the table header if this is a first test dependency. + // + if (first) + { + id = to_string (dt); + + // Capitalize the heading. + // + string heading (id); + heading[0] = ucase (id[0]); + + s << H3 << heading << ~H3 + << TABLE(CLASS="proplist", ID=id) + << TBODY; + + first = false; + } + s << TR(CLASS=id) << TD << SPAN(CLASS="value"); - print_dependency (d); + print_dependency (td); s << ~SPAN << ~TD << ~TR; } + } + // Print the table closing tags if it was printed. + // + if (!first) + { s << ~TBODY << ~TABLE; } }; - print_dependencies (pkg->tests, "Tests", "tests"); - print_dependencies (pkg->examples, "Examples", "examples"); - print_dependencies (pkg->benchmarks, "Benchmarks", "benchmarks"); + print_tests (test_dependency_type::tests); + print_tests (test_dependency_type::examples); + print_tests (test_dependency_type::benchmarks); bool builds (build_db_ != nullptr && pkg->buildable); |