From 07e2daff34464a72742bda711e8c06a5f2781174 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 25 Mar 2025 12:48:55 -0700 Subject: [PATCH 1/2] Make tests work on Windows --- .../rife/bld/extension/ExecOperationTest.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/test/java/rife/bld/extension/ExecOperationTest.java b/src/test/java/rife/bld/extension/ExecOperationTest.java index 815eb45..dd69a3e 100644 --- a/src/test/java/rife/bld/extension/ExecOperationTest.java +++ b/src/test/java/rife/bld/extension/ExecOperationTest.java @@ -17,6 +17,8 @@ package rife.bld.extension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; import rife.bld.BaseProject; import rife.bld.Project; import rife.bld.WebProject; @@ -24,6 +26,7 @@ import rife.bld.operations.exceptions.ExitStatusException; import java.io.File; import java.util.List; +import java.util.Locale; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; @@ -31,6 +34,8 @@ import static org.assertj.core.api.Assertions.assertThatCode; class ExecOperationTest { private static final String FOO = "foo"; + private static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.US).contains("win"); + private static final String CAT = IS_WINDOWS ? "type" : "cat"; @Test void testCommand() { @@ -53,7 +58,7 @@ class ExecOperationTest { assertThatCode(() -> new ExecOperation() .fromProject(new BaseProject()) - .command(List.of("cat", FOO)) + .command(List.of(CAT, FOO)) .execute()).isInstanceOf(ExitStatusException.class); } @@ -61,7 +66,7 @@ class ExecOperationTest { void testFailOnExit() { var op = new ExecOperation() .fromProject(new BaseProject()) - .command(List.of("cat", FOO)) + .command(List.of(CAT, FOO)) .failOnExit(false); assertThat(op.isFailOnExit()).isFalse(); assertThatCode(op::execute).doesNotThrowAnyException(); @@ -72,15 +77,22 @@ class ExecOperationTest { @Test void testTimeout() { + List sleep; + if (IS_WINDOWS) { + sleep = List.of("timeout", "/t", "10"); + } else { + sleep = List.of("sleep", "10"); + } var op = new ExecOperation() .fromProject(new BaseProject()) .timeout(5) - .command(List.of("sleep", "10")); + .command(sleep); assertThat(op.timeout()).isEqualTo(5); assertThatCode(op::execute).isInstanceOf(ExitStatusException.class); } @Test + @EnabledOnOs({OS.LINUX, OS.MAC}) void testTouch() throws Exception { var tmpFile = new File("hello.tmp"); tmpFile.deleteOnExit(); From 62b1eeb5954027c6b40c08cd2252e46451e03c08 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 25 Mar 2025 12:49:12 -0700 Subject: [PATCH 2/2] Add OS matrix for Ubuntu, Windows and macOS --- .github/workflows/bld.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index 138f5e5..947f3c4 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -1,14 +1,16 @@ name: bld-ci -on: [push, pull_request, workflow_dispatch] +on: [ push, pull_request, workflow_dispatch ] jobs: build-bld-project: - runs-on: ubuntu-latest - strategy: matrix: - java-version: [17, 21, 24] + java-version: [ 17, 21, 24 ] + kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ] + os: [ ubuntu-latest, windows-latest, macos-latest ] + + runs-on: ${{ matrix.os }} steps: - name: Checkout source repository @@ -26,4 +28,4 @@ jobs: run: ./bld download - name: Run tests - run: ./bld compile test + run: ./bld compile test \ No newline at end of file