Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/java/app/testlens/cli/util/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public final class Console {
private Console() {}

/**
* Human-readable build environment, e.g. {@code "Linux 6.8.0-45-generic · amd64 · Java 21.0.5"}; {@code null}
* Human-readable build environment, e.g. {@code "Linux 6.8.0-45-generic · amd64 · Java 21.0.5 · Gradle 8.12"}; {@code null}
* without any data, so callers can omit the environment instead of printing placeholders.
*/
public static @Nullable String environment(@Nullable BuildEnvironment environment) {
Expand All @@ -27,11 +27,15 @@ private Console() {}
var os = Stream.of(environment.getOsName(), environment.getOsVersion())
.filter(Objects::nonNull)
.collect(Collectors.joining(" "));
var buildTool = Stream.of(environment.getBuildToolType(), environment.getBuildToolVersion())
.filter(Objects::nonNull)
.collect(Collectors.joining(" "));
var parts = Stream
.of(
os.isEmpty() ? null : os,
environment.getOsArch(),
environment.getJavaVersion() == null ? null : "Java " + environment.getJavaVersion()
environment.getJavaVersion() == null ? null : "Java " + environment.getJavaVersion(),
buildTool.isEmpty() ? null : buildTool
)
.filter(Objects::nonNull)
.toList();
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/app/testlens/cli/FlakesCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class FlakesCommandTest {
.osName("Linux")
.osVersion("6.8.0-45-generic")
.osArch("amd64")
.javaVersion("21.0.5");
.javaVersion("21.0.5")
.buildToolType("Gradle")
.buildToolVersion("8.12");

@RegisterExtension
static WireMockExtension wireMock = WireMockExtension.newInstance()
Expand Down Expand Up @@ -110,7 +112,7 @@ void prints_the_build_environment_of_each_flake() {
" newest flake first, executions in chronological order",
"",
" 1. 0123456 @ main · :core:test · CI / build",
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5",
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5 · Gradle 8.12",
" 1. FAILED (2026-01-02 03:04:05Z - 03:04:07Z (2s), see " + JOB_URL + ")",
" java.lang.AssertionError: boom",
" 2. SUCCESSFUL (2026-01-02 04:04:05Z - 04:04:07Z (2s))"
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/app/testlens/cli/PrCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class PrCommandTest {
.osName("Linux")
.osVersion("6.8.0-45-generic")
.osArch("amd64")
.javaVersion("21.0.5");
.javaVersion("21.0.5")
.buildToolType("Gradle")
.buildToolVersion("8.12");

private static final Pattern OSC8_LINK = Pattern.compile("\u001B]8;;(.*?)\u001B\\\\");

Expand Down Expand Up @@ -173,7 +175,7 @@ void prints_the_build_environment_of_executions() {
"CI / build > :test",
" FooTests > bar()",
" 1. FAILED (2026-01-02 03:04:05Z - 03:04:06Z (1s 500ms), see " + JOB_URL + ")",
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5",
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5 · Gradle 8.12",
" - foo bar",
" + foo baz",
" java.lang.AssertionError: boom",
Expand All @@ -182,7 +184,7 @@ void prints_the_build_environment_of_executions() {
" second",
" ... 1 more",
" 2. SKIPPED (2026-01-02 03:04:05Z, see " + JOB_URL + ")",
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5"
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5 · Gradle 8.12"
);
}

Expand Down
8 changes: 5 additions & 3 deletions src/test/java/app/testlens/cli/TestCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class TestCommandTest {
.osName("Linux")
.osVersion("6.8.0-45-generic")
.osArch("amd64")
.javaVersion("21.0.5");
.javaVersion("21.0.5")
.buildToolType("Gradle")
.buildToolVersion("8.12");

private static final Pattern OSC8_LINK = Pattern.compile("\\u001B]8;;(.*?)\\u001B\\\\");

Expand Down Expand Up @@ -135,14 +137,14 @@ void prints_the_build_environment_of_executions() {
" newest first, successful runs are not shown",
" 1. FAILED (2026-01-02 03:04:05Z - 03:04:07Z (2s), see " + JOB_URL + ")",
" CI / build > :core:test · 0123456 @ main",
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5",
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5 · Gradle 8.12",
" - foo bar",
" + foo baz",
" java.lang.AssertionError: boom",
" at Foo.bar(Foo.java:1)",
" 2. SUCCESSFUL (2026-01-02 04:04:05Z - 04:04:07Z (2s), see " + OTHER_JOB_URL + ")",
" :core:testJava21 · 89abcde @ main",
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5"
" Linux 6.8.0-45-generic · amd64 · Java 21.0.5 · Gradle 8.12"
);
}

Expand Down
4 changes: 3 additions & 1 deletion src/test/java/app/testlens/cli/tui/ExecutionsViewTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ void shows_the_build_environment_of_the_selected_execution() {
.osVersion("6.8.0-45-generic")
.osArch("amd64")
.javaVersion("21.0.5")
.buildToolType("Gradle")
.buildToolVersion("8.12")
),
execution(TestExecutionResponse.OutcomeEnum.SUCCESSFUL, ":core:testJava21")
);

assertThat(render(view)).contains("Env: Linux 6.8.0-45-generic · amd64 · Java 21.0.5");
assertThat(render(view)).contains("Env: Linux 6.8.0-45-generic · amd64 · Java 21.0.5 · Gradle 8.12");
}

@Test
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/app/testlens/cli/tui/FlakesViewTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,16 @@ void shows_the_build_environment_of_the_selected_flake() {
.osVersion("6.8.0-45-generic")
.osArch("amd64")
.javaVersion("21.0.5")
.buildToolType("Gradle")
.buildToolVersion("8.12")
)
)
.toList()
);
var controller = new FlakesController(new FocusManager(), TEST, List.of(flake));

assertThat(render(new FlakesView(controller, TEST, null, null, null)))
.contains("Env: Linux 6.8.0-45-generic · amd64 · Java 21.0.5");
.contains("Env: Linux 6.8.0-45-generic · amd64 · Java 21.0.5 · Gradle 8.12");
}

// the executions are deliberately newest first, to verify the tabs are chronological
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/app/testlens/cli/tui/PrTuiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,16 @@ void shows_the_build_environment_of_the_selected_execution() {
.osVersion("6.8.0-45-generic")
.osArch("amd64")
.javaVersion("21.0.5")
.buildToolType("Gradle")
.buildToolVersion("8.12")
)
)
),
new FocusManager()
);
var view = new PrTuiView(controller);

assertThat(render(view)).contains("Env: Linux 6.8.0-45-generic · amd64 · Java 21.0.5");
assertThat(render(view)).contains("Env: Linux 6.8.0-45-generic · amd64 · Java 21.0.5 · Gradle 8.12");
}

@Test
Expand Down
Loading