Kumo
A hand-rolled game engine.
git clone https://git.sentomk.me/Kumo.git
commit d127e64c75020dd498723de9ee4e93ea2a1bbeca parent 648327d8a864296051e1f7f51e43bf623ce319cb Author: sentomk <sentomk@proton.me> Date: Wed, 14 Oct 2026 16:49:14 +0800 style: draw a rule above every test program and link them before running Each test program is now a block of its own: a rule with its name in it, the cases, the verdict, and a blank line. A heavier rule sets the summary off from the blocks above it. The rules are as wide as the lines of the test cases, 75 columns, and are plain ASCII so that they come out the same everywhere. All the test programs are linked before any of them runs. Before, the link line of each one fell between the blocks of two programs on a cold build; now the lines about building stay together at the top, and a program that does not link stops the run before any test has started. -q keeps the compact output, without rules or blank lines. Diffstat:
| M | kumo_builder.cpp | | | 44 | ++++++++++++++++++++++++++++++++++++++++---- |
| M | tests/check.h | | | 3 | ++- |
2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/kumo_builder.cpp b/kumo_builder.cpp @@ -228,6 +228,24 @@ static void log_step(Style style, const std::string& label, std::printf("%s\n", line.c_str()); } +/// @brief The width of the lines drawn between test programs: that of the +/// longest line a test case takes, see `kNameWidth` in tests/check.h. +constexpr size_t kRuleWidth = 75; + +/// @brief A dimmed line of @p fill characters, kRuleWidth wide, with the +/// @p title set into it if there is one: +/// @code +/// -- unit/raster_test --------------------------------------------------- +/// @endcode +static std::string rule(char fill, const std::string& title = "") { + if (title.empty()) return paint(Style::Dim, std::string(kRuleWidth, fill)); + const std::string lead(2, fill); + const size_t used = lead.size() + 1 + title.size() + 1; + const std::string tail(used < kRuleWidth ? kRuleWidth - used : 2, fill); + return paint(Style::Dim, lead + " ") + paint(Style::Cyan, title) + + paint(Style::Dim, " " + tail); +} + /// @brief Prints an error message on standard error. /// /// Standard output is flushed first, so that the message does not overtake @@ -1560,12 +1578,24 @@ int main(int argc, char** argv) { name_width = std::max(name_width, test_name(cfg, test->src).size()); } - std::vector<std::string> failed; + // First every test program is linked, so that the lines about building stay + // together and none of them falls between the blocks of two programs; a + // program that does not link stops the run before any test has started. + bool built_something = compiled > 0; for (const Unit* test : selected) { std::vector<fs::path> test_objects = {test->obj}; test_objects.insert(test_objects.end(), objects.begin(), objects.end()); + bool linked = false; + if (!link_if_needed(cfg, test_objects, test_exe(cfg, test->src), &linked)) { + return 1; + } + built_something = built_something || linked; + } + if (built_something && !quiet) std::printf("\n"); + + std::vector<std::string> failed; + for (const Unit* test : selected) { const fs::path exe = test_exe(cfg, test->src); - if (!link_if_needed(cfg, test_objects, exe)) return 1; // The test program lists its cases as it runs them. It is told whether it // may color its output and rewrite its current line, which a terminal @@ -1581,7 +1611,7 @@ int main(int argc, char** argv) { if (quiet) { command.push_back("--quiet"); } else { - log_step(Style::Cyan, "test", name); + std::printf("%s\n", rule('-', name).c_str()); } const Clock::time_point test_began = Clock::now(); @@ -1607,10 +1637,16 @@ int main(int argc, char** argv) { pad(name, name_width).c_str(), paint(Style::Dim, pad_left(took, 7)).c_str(), crashed ? (" " + paint(Style::Red, describe(status))).c_str() : ""); + if (!quiet) std::printf("\n"); } + // A heavier rule sets the summary off from the programs above it. const std::string total = " in " + format_duration(Clock::now() - began); - std::printf("\n"); + if (quiet) { + std::printf("\n"); + } else { + std::printf("%s\n", rule('=').c_str()); + } if (failed.empty()) { std::printf( "%s%s\n", diff --git a/tests/check.h b/tests/check.h @@ -159,7 +159,8 @@ int main(int argc, char** argv) { // The names are padded to one width for every program, not to the longest of // each, so that the results line up from one program to the next. A longer - // name only moves the column of its own program. + // name only moves the column of its own program. A line is then 75 columns + // wide, as wide as the rules the builder draws between the programs. constexpr size_t kNameWidth = 60; size_t width = kNameWidth; for (const kumo_test::Case& test : kumo_test::cases()) {
