test: skip what needs komorebi for Mac's source when there is none

Sixteen tests read the source of komorebi for Mac, through the catalog that
build.rs indexes from KOMOREBI_MAC_SRC (which nix develop sets) or the checkout
itself, and panicked or failed their assertions on a machine without it: every
Windows machine, and a Mac outside nix develop. That is not a failure of
anything, so they now say why and stop, as the tests that need ffmpeg do:

  skipped: KOMOREBI_MAC_SRC is not set, or this build was made without it

testkit::komorebi_mac_source_available says whether both the variable and the
indexed catalog are there, and skip_without_komorebi_mac_source! is its use at
the top of a test. With the source they run exactly as before.

On Windows the whole suite now passes.
This commit is contained in:
LGUG2Z committed 2026-10-28 16:24:29 -07:00
1 parent 7c692138c7
commit 93a024f0f1
5 files changed
+43

No files matched your search

@@ -830,6 +830,7 @@ mod tests {
#[test]
fn the_catalog_was_built_from_komorebis_source() {
crate::skip_without_komorebi_mac_source!();
assert!(
mac().files_scanned() > 20,
"only {} files were indexed",
@@ -845,6 +846,7 @@ mod tests {
#[test]
fn the_handler_header_is_found_at_its_line() {
crate::skip_without_komorebi_mac_source!();
let found = find(
"komorebi::process_event",
Level::Info,
@@ -903,6 +905,7 @@ mod tests {
#[test]
fn a_statement_that_is_all_placeholders_is_generic() {
crate::skip_without_komorebi_mac_source!();
// `tracing::error!("{}", error)` in the process_event listener
let found = find(
"komorebi::process_event",
@@ -928,6 +931,7 @@ mod tests {
#[test]
fn every_statement_of_the_real_log_sample_is_found_in_the_source() {
crate::skip_without_komorebi_mac_source!();
let sample = include_str!("../../tests/fixtures/komorebi_plaintext_sample.log");
let lines = crate::analysis::logparse::parse(sample.as_bytes());
let structured: Vec<_> = lines.iter().filter(|line| !line.continuation).collect();
@@ -985,6 +989,7 @@ mod tests {
#[test]
fn the_same_commit_is_the_same_source() {
crate::skip_without_komorebi_mac_source!();
let skew = skew_between(
&[version("abc1234def")],
Some("abc1234def"),
@@ -1009,6 +1014,7 @@ mod tests {
#[test]
fn a_commit_the_repository_does_not_have_is_unknown() {
crate::skip_without_komorebi_mac_source!();
let skew = skew_between(
&[version("0000000000000000000000000000000000000000")],
commit(),
@@ -1090,6 +1096,7 @@ mod tests {
/// what was indexed and this fails, rather than `code` silently missing lines.
#[test]
fn every_log_statement_in_komorebis_source_is_indexed() {
crate::skip_without_komorebi_mac_source!();
let root = crate::testkit::komorebi_mac_src().join("komorebi/src");
let mut files = Vec::new();
rust_files(&root, &mut files);
+27
View File
@@ -675,6 +675,33 @@ pub fn komorebi_mac_src() -> PathBuf {
})
}
/// Whether the tests that read komorebi for Mac's source can run: `KOMOREBI_MAC_SRC` names a
/// checkout, and this build indexed it (an empty catalog means it was built without one).
///
/// A machine that has neither (Windows, or a Mac outside `nix develop`) has nothing for those
/// tests to check, which is not a failure: they use [`skip_without_komorebi_mac_source`] to say so
/// and stop, as the tests that need `ffmpeg` do.
#[must_use]
pub fn komorebi_mac_source_available() -> bool {
std::env::var_os("KOMOREBI_MAC_SRC").is_some_and(|path| !path.is_empty())
&& !crate::analysis::catalog::of(crate::analysis::flavor::Flavor::Macos).is_empty()
}
/// Ends the test that uses it, saying why, on a machine that has no komorebi for Mac source to
/// read (see [`komorebi_mac_source_available`]). Use it first in a test that needs the source.
#[macro_export]
macro_rules! skip_without_komorebi_mac_source {
() => {
if !$crate::testkit::komorebi_mac_source_available() {
eprintln!(
"skipped: KOMOREBI_MAC_SRC is not set, or this build was made without it \
(`nix develop` sets it)"
);
return;
}
};
}
/// Whether `ffmpeg` is there to make test videos with.
#[must_use]
pub fn ffmpeg_available() -> bool {
+1
View File
@@ -107,6 +107,7 @@ fn session(name: &str, mark_bug: bool) -> String {
#[test]
fn the_brief_leads_with_the_users_words_and_points_at_the_event_that_broke_it() {
komorebi_recorder::skip_without_komorebi_mac_source!();
let dir = session("brief-bug", true);
let answer = json(&["brief", &dir, "--json"]);
+6
View File
@@ -46,6 +46,7 @@ fn session(name: &str, commit: Option<&str>) -> String {
#[test]
fn a_log_line_is_traced_to_the_statement_that_wrote_it() {
komorebi_recorder::skip_without_komorebi_mac_source!();
let recorded = catalog::of(Flavor::Macos).commit().unwrap_or("unknown");
let dir = session("code-line", Some(recorded));
@@ -91,6 +92,7 @@ fn a_log_line_is_traced_to_the_statement_that_wrote_it() {
#[test]
fn an_event_is_explained_by_everything_its_handler_logged() {
komorebi_recorder::skip_without_komorebi_mac_source!();
let recorded = catalog::of(Flavor::Macos).commit().unwrap_or("unknown");
let dir = session("code-event", Some(recorded));
@@ -106,6 +108,7 @@ fn an_event_is_explained_by_everything_its_handler_logged() {
#[test]
fn a_commit_that_cannot_be_compared_is_a_warning_on_every_answer() {
komorebi_recorder::skip_without_komorebi_mac_source!();
let dir = session(
"code-skew",
Some("0000000000000000000000000000000000000000"),
@@ -145,6 +148,7 @@ fn git(args: &[&str]) -> Option<String> {
/// as if the commits were the same.
#[test]
fn only_the_files_that_changed_since_the_recorded_commit_are_doubted() {
komorebi_recorder::skip_without_komorebi_mac_source!();
let Some(history) = git(&["log", "-2", "--format=%H", "--", "komorebi/src"]) else {
return;
};
@@ -200,6 +204,7 @@ fn a_session_that_did_not_record_the_version_says_it_is_unknown() {
#[test]
fn a_line_no_statement_writes_is_said_so_and_a_bad_reference_is_not_found() {
komorebi_recorder::skip_without_komorebi_mac_source!();
let dir = session("code-missing", None);
let none = json(&["code", &dir, "log:4", "--json"]);
@@ -225,6 +230,7 @@ fn a_line_no_statement_writes_is_said_so_and_a_bad_reference_is_not_found() {
#[test]
fn statements_can_be_searched_by_their_text() {
komorebi_recorder::skip_without_komorebi_mac_source!();
let dir = session("code-grep", None);
let answer = json(&["code", &dir, "--grep", "reaping window", "--json"]);
+2
View File
@@ -93,6 +93,7 @@ fn session(name: &str) -> String {
#[test]
fn a_change_with_no_event_of_its_own_is_blamed_on_the_reaper_by_its_log_line() {
komorebi_recorder::skip_without_komorebi_mac_source!();
let dir = session("trace-reaper");
let answer = json(&["trace", &dir, "event:2", "--json"]);
@@ -141,6 +142,7 @@ fn a_change_with_no_event_of_its_own_is_blamed_on_the_reaper_by_its_log_line() {
#[test]
fn the_text_trace_reads_top_to_bottom() {
komorebi_recorder::skip_without_komorebi_mac_source!();
let dir = session("trace-text");
let text = text(&["trace", &dir, "2"]);