Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

ci: run lib tests across the feature powerset in nightly (#3059)

Maximilian Roos2fb96c1d0328
diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml
index 14859bb24..aca4b0fc7 100644
--- a/.github/workflows/nightly.yaml
+++ b/.github/workflows/nightly.yaml
@@ -1,7 +1,7 @@
name: nightly
# Slower checks that aren't worth running on every PR but should run before a
# release. Jobs:
-# - feature-powerset: feature-flag unification (motivated by #2442)
+# - feature-powerset: feature-flag unification, check + lib tests (motivated by #2442)
# - release-target: PTY+shell suite on the release triples ci.yaml doesn't cover
# - benchmarks: full criterion suite + time-series gist append (cron only)
# - check-unused-dependencies: cargo-udeps on nightly toolchain
@@ -89,6 +89,15 @@ jobs:
# Workspace members must use `default-features = false` when depending on
# worktrunk, or feature unification will mask gating bugs by silently
# enabling `cli` in the lib build (see tests/helpers/wt-perf/Cargo.toml).
+ #
+ # The test step runs the unit tests per combination — the check step
+ # strips dev-deps, so `#[cfg(test)]` code is invisible to it, and a test
+ # importing a feature-gated symbol without its own gate, or a snapshot
+ # baking feature-dependent output, only surfaces when tests are built and
+ # run per combo. Bounded to `--lib`: the integration suite snapshots `wt`
+ # output, which bakes in syntax-highlighted command rendering, so it only
+ # passes with syntax-highlighting on; ci.yaml's `test` matrix already
+ # runs it (with shell-integration-tests) on every PR.
needs: gate
if: needs.gate.outputs.run == 'true'
runs-on: ubuntu-24.04
@@ -104,8 +113,15 @@ jobs:
with:
tool: cargo-hack
- - name: cargo hack check --feature-powerset --no-dev-deps
- run: cargo hack check --feature-powerset --no-dev-deps
+ - run: cargo hack check --feature-powerset --no-dev-deps
+
+ # The lib suite shells out to the mock-stub helper bin, which `--lib`
+ # doesn't build (tests/CLAUDE.md documents the fresh-target panic).
+ # mock-stub doesn't depend on worktrunk features, so one build serves
+ # every combo.
+ - run: cargo build -p mock-stub
+
+ - run: cargo hack test --feature-powerset --lib
release-target:
# Build and run the test suite on the release triples that ci.yaml's
diff --git a/src/git/error.rs b/src/git/error.rs
index cb6b430b8..0a94abd48 100644
--- a/src/git/error.rs
+++ b/src/git/error.rs
@@ -1980,6 +1980,9 @@ mod tests {
);
}
+ // The third snapshot renders a failed command through `format_bash_with_gutter`,
+ // whose output is highlighted only with the feature on.
+ #[cfg(feature = "syntax-highlighting")]
#[test]
fn snapshot_worktree_creation_failed() {
let err = GitError::WorktreeCreationFailed {
diff --git a/src/styling/mod.rs b/src/styling/mod.rs
index d93754729..275c3ca7a 100644
--- a/src/styling/mod.rs
+++ b/src/styling/mod.rs
@@ -424,6 +424,7 @@ command = "npm install"
");
}
+ #[cfg(feature = "syntax-highlighting")]
#[test]
fn test_bash_gutter_formatting_ends_with_reset() {
// Test that bash gutter formatting properly resets colors at the end of each line
@@ -675,17 +676,20 @@ cp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/bu
assert_snapshot!(result);
}
+ #[cfg(feature = "syntax-highlighting")]
#[test]
fn test_unhighlighted_text_has_consistent_dim_across_lines() {
assert_snapshot!(format_bash_with_gutter("echo {{ worktree\n}}/path"));
}
+ #[cfg(feature = "syntax-highlighting")]
#[test]
fn test_syntax_highlighting_produces_multiple_colors() {
let command = "echo 'hello' | grep hello > output.txt && cat output.txt";
assert_snapshot!(format_bash_with_gutter(command));
}
+ #[cfg(feature = "syntax-highlighting")]
#[test]
fn test_no_color_discontinuity_in_template_variables() {
// Regression test: wrap_ansi injects [39m (reset foreground color) at line ends
@@ -739,6 +743,7 @@ cp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/bu
);
}
+ #[cfg(feature = "syntax-highlighting")]
#[test]
fn test_no_bold_dim_conflict() {
// Regression test: We must never mix bold (SGR 1) and dim (SGR 2) in the same
@@ -763,6 +768,7 @@ cp -cR {{ repo_root }}/target/debug/.fingerprint {{ repo_root }}/target/debug/bu
);
}
+ #[cfg(feature = "syntax-highlighting")]
#[test]
fn test_all_tokens_are_dimmed() {
// Regression test: All highlighted tokens should be dimmed to match the base text.