Skip to content

Commit 47ba922

Browse files
committed
Fix detection of GHA
1 parent ed9b99e commit 47ba922

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/jdk/tools/jlink/plugins/AddSapMachineToolsTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ public class AddSapMachineToolsTest {
5959

6060
@Test
6161
public void testSapMachineTools() throws IOException {
62-
// async profiler is only available on restricted set of platforms and not in Github Actions builds
63-
String gha = System.getenv("GITHUB_ACTIONS");
64-
boolean shouldHaveAsync = (gha == null || !gha.contains("true")) &&
65-
(Platform.isOSX() ||
66-
(Platform.isLinux() && (Platform.isAArch64() || Platform.isPPC() || Platform.isX64()) && !Platform.isMusl()));
62+
// async profiler is not pulled in GHA builds, so skip the test there.
63+
// checking whether we are in a GHA environment is hacky because jtreg removes environment variables,
64+
// so we guess by checking for a user name containing the String "runner"
65+
if (System.getProperty("user.name", "n/a").contains("runner")) {
66+
throw new SkippedException("Detected a Github Actions environment. No tools get added to SapMachine here, so skip test.");
67+
}
68+
69+
// async profiler is only available on a subset of platforms
70+
boolean shouldHaveAsync = Platform.isOSX() ||
71+
(Platform.isLinux() && (Platform.isAArch64() || Platform.isPPC() || Platform.isX64()) && !Platform.isMusl());
6772

6873
Path sourceJavaHome = Path.of(System.getProperty("java.home"));
6974

0 commit comments

Comments
 (0)