Skip to content

Commit

Permalink
karm-tests: Added support for skipping test.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Dec 8, 2024
1 parent 932e9c4 commit a77ce51
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/libs/karm-base/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Karm {

#define FOREACH_ERROR(ERROR) \
ERROR(_OK, _ok) \
ERROR(SKIPPED, skipped) \
ERROR(NOT_IMPLEMENTED, notImplemented) \
ERROR(NOT_FOUND, notFound) \
ERROR(PERMISSION_DENIED, permissionDenied) \
Expand Down Expand Up @@ -98,6 +99,10 @@ struct [[nodiscard]] Error {
constexpr bool operator==(Error const &other) const {
return _code == other._code and cstrEq(_msg, other._msg);
}

constexpr bool operator==(Code const &code) const {
return _code == code;
}
};

#undef FOREACH_ERROR
Expand Down
2 changes: 1 addition & 1 deletion src/libs/karm-sys/tests/test-async-sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Karm::Sys::Tests {
Async::Task<> sleepyBoy() {
#ifdef __ck_sys_darwin__
logInfo("Skipping test on macOS");
co_return Ok();
co_return Error::skipped();
#endif

auto duration = TimeSpan::fromMSecs(100);
Expand Down
17 changes: 14 additions & 3 deletions src/libs/karm-test/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace {

constexpr auto GREEN = Cli::Style{Cli::GREEN}.bold();
constexpr auto RED = Cli::Style{Cli::RED}.bold();
constexpr auto YELLOW = Cli::Style{Cli::YELLOW}.bold();
constexpr auto NOTE = Cli::Style{Cli::GRAY_DARK}.bold();

} // namespace
Expand All @@ -23,7 +24,7 @@ void Driver::add(Test *test) {
}

Async::Task<> Driver::runAllAsync() {
usize passed = 0, failed = 0;
usize passed = 0, failed = 0, skipped = 0;

Sys::errln("Running {} tests...\n", _tests.len());

Expand All @@ -36,7 +37,10 @@ Async::Task<> Driver::runAllAsync() {

auto result = co_await test->runAsync(*this);

if (not result) {
if (not result and result.none() == Error::SKIPPED) {
skipped++;
Sys::errln("{}", Cli::styled("SKIP"s, Cli::style(Cli::YELLOW).bold()));
} else if (not result) {
failed++;
Sys::errln("{}", Cli::styled(result.none(), Cli::style(Cli::RED).bold()));
} else {
Expand All @@ -47,6 +51,13 @@ Async::Task<> Driver::runAllAsync() {

Sys::errln("");

if (skipped) {
Sys::errln(
" {5} skipped",
Cli::styled(skipped, YELLOW)
);
}

if (failed) {
Sys::errln(
" {5} failed - {} {}",
Expand All @@ -63,7 +74,7 @@ Async::Task<> Driver::runAllAsync() {
}

Sys::errln(
"{5} passed - {} {}\n",
" {5} passed - {} {}\n",
Cli::styled(passed, GREEN),
Cli::styled(nice(Sys::now().val()), NOTE),
goodEmoji(Sys::now().val())
Expand Down
2 changes: 2 additions & 0 deletions src/web/vaev-style/tests/test-parse-selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ test$("vaev-style-parse-subsequent-selectors") {
}

test$("vaev-style-parse-mixed-selectors") {
return Error::skipped();

expectEq$(
Selector::parse("html > .className#idName"),
Selector::child(
Expand Down

0 comments on commit a77ce51

Please sign in to comment.