Skip to content

Commit 28db877

Browse files
committed
Improve vix tests output and filtering
1 parent dcd6b10 commit 28db877

5 files changed

Lines changed: 673 additions & 15 deletions

File tree

include/vix/cli/build/BuildStyle.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,23 @@ namespace vix::cli::build
146146
const std::string &message,
147147
long long milliseconds);
148148

149+
void print_task_header_full(
150+
std::ostream &out,
151+
const std::string &action,
152+
const std::string &target,
153+
const std::string &preset,
154+
const std::vector<std::pair<std::string, std::string>> &meta);
155+
156+
void print_task_success_timed(
157+
std::ostream &out,
158+
const std::string &message,
159+
long long milliseconds);
160+
161+
void print_task_failure_timed(
162+
std::ostream &out,
163+
const std::string &message,
164+
long long milliseconds);
165+
149166
} // namespace vix::cli::build
150167

151168
#endif

include/vix/cli/commands/tests/TestsDetail.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ namespace vix::commands::TestsCommand::detail
2727
bool list = false;
2828
bool failFast = false;
2929
bool runAfter = false; // --run (tests + runtime)
30+
bool raw = false;
31+
std::string testPattern;
3032

31-
fs::path projectDir; // resolved path (or cwd)
32-
std::vector<std::string> forwarded; // args forwarded to `vix check`
33-
std::vector<std::string> ctestArgs; // args forwarded to `ctest` (after `--`)
33+
fs::path projectDir;
34+
std::vector<std::string> forwarded;
35+
std::vector<std::string> ctestArgs;
3436
};
3537

3638
Options parse(const std::vector<std::string> &args);

src/build/BuildStyle.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <sstream>
2424
#include <system_error>
2525
#include <vector>
26+
#include <iomanip>
2627

2728
#include <vix/cli/Style.hpp>
2829

@@ -508,4 +509,83 @@ namespace vix::cli::build
508509
return location;
509510
}
510511

512+
void print_task_header_full(
513+
std::ostream &out,
514+
const std::string &action,
515+
const std::string &target,
516+
const std::string &preset,
517+
const std::vector<std::pair<std::string, std::string>> &meta)
518+
{
519+
out << style::CYAN
520+
<< style::BOLD
521+
<< action
522+
<< style::RESET;
523+
524+
if (!target.empty())
525+
{
526+
out << " "
527+
<< style::CYAN
528+
<< style::BOLD
529+
<< target
530+
<< style::RESET;
531+
}
532+
533+
if (!preset.empty())
534+
out << " " << colorize(style::GRAY, "(" + preset + ")");
535+
536+
out << "\n";
537+
538+
if (meta.empty())
539+
return;
540+
541+
out << style::GRAY << " * " << style::RESET;
542+
543+
for (std::size_t i = 0; i < meta.size(); ++i)
544+
{
545+
if (i > 0)
546+
out << style::GRAY << " | " << style::RESET;
547+
548+
out << meta[i].first << ": "
549+
<< colorize(style::MAGENTA, meta[i].second);
550+
}
551+
552+
out << "\n";
553+
}
554+
555+
void print_task_success_timed(
556+
std::ostream &out,
557+
const std::string &message,
558+
long long milliseconds)
559+
{
560+
std::ostringstream oss;
561+
oss << std::fixed << std::setprecision(1)
562+
<< (static_cast<double>(milliseconds) / 1000.0);
563+
564+
out << " "
565+
<< colorize(style::GREEN, "")
566+
<< " "
567+
<< message
568+
<< " in "
569+
<< oss.str()
570+
<< "s\n";
571+
}
572+
573+
void print_task_failure_timed(
574+
std::ostream &out,
575+
const std::string &message,
576+
long long milliseconds)
577+
{
578+
std::ostringstream oss;
579+
oss << std::fixed << std::setprecision(1)
580+
<< (static_cast<double>(milliseconds) / 1000.0);
581+
582+
out << " "
583+
<< colorize(style::RED, "")
584+
<< " "
585+
<< message
586+
<< " after "
587+
<< oss.str()
588+
<< "s\n";
589+
}
590+
511591
} // namespace vix::cli::build

0 commit comments

Comments
 (0)