Skip to content

Commit 3fc80b3

Browse files
committed
Fix detection of GHA
1 parent ed9b99e commit 3fc80b3

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
import java.nio.file.Files;
2626
import java.nio.file.Path;
2727

28+
import org.testng.SkipException;
2829
import org.testng.annotations.Test;
2930

3031
import jdk.test.lib.Platform;
3132

32-
import jtreg.SkippedException;
33-
3433
import static org.testng.Assert.assertFalse;
3534
import static org.testng.Assert.assertTrue;
3635

@@ -44,7 +43,7 @@
4443
* jdk.jlink/jdk.tools.jimage
4544
* @run testng AddSapMachineToolsTest
4645
*/
47-
46+
@Test
4847
public class AddSapMachineToolsTest {
4948

5049
private final String[] sapMachineTools = {
@@ -59,11 +58,16 @@ public class AddSapMachineToolsTest {
5958

6059
@Test
6160
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()));
61+
// async profiler is not pulled in GHA builds, so skip the test there.
62+
// checking whether we are in a GHA environment is hacky because jtreg removes environment variables,
63+
// so we guess by checking for a user name containing the String "runner"
64+
if (System.getProperty("user.name", "n/a").contains("runner")) {
65+
throw new SkipException("Detected a Github Actions environment. No tools get added to SapMachine here, so skip test.");
66+
}
67+
68+
// async profiler is only available on a subset of platforms
69+
boolean shouldHaveAsync = Platform.isOSX() ||
70+
(Platform.isLinux() && (Platform.isAArch64() || Platform.isPPC() || Platform.isX64()) && !Platform.isMusl());
6771

6872
Path sourceJavaHome = Path.of(System.getProperty("java.home"));
6973

@@ -77,7 +81,7 @@ public void testSapMachineTools() throws IOException {
7781

7882
Helper helper = Helper.newHelper();
7983
if (helper == null) {
80-
throw new SkippedException("JDK image is not suitable for this test.");
84+
throw new SkipException("JDK image is not suitable for this test.");
8185
}
8286

8387
for (String tool : sapMachineTools) {

0 commit comments

Comments
 (0)