|
| 1 | +/* |
| 2 | + * Copyright 2015-2022 the original author or authors. |
| 3 | + * |
| 4 | + * All rights reserved. This program and the accompanying materials are |
| 5 | + * made available under the terms of the Eclipse Public License v2.0 which |
| 6 | + * accompanies this distribution and is available at |
| 7 | + * |
| 8 | + * https://www.eclipse.org/legal/epl-v20.html |
| 9 | + */ |
| 10 | + |
| 11 | +package platform.tooling.support.tests; |
| 12 | + |
| 13 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 14 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 15 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 16 | +import static org.junit.jupiter.api.Assumptions.assumeFalse; |
| 17 | +import static platform.tooling.support.Helper.TOOL_TIMEOUT; |
| 18 | +import static platform.tooling.support.tests.XmlAssertions.verifyContainsExpectedStartedOpenTestReport; |
| 19 | + |
| 20 | +import java.nio.file.Paths; |
| 21 | + |
| 22 | +import de.sormuras.bartholdy.tool.GradleWrapper; |
| 23 | + |
| 24 | +import org.junit.jupiter.api.Test; |
| 25 | + |
| 26 | +import platform.tooling.support.MavenRepo; |
| 27 | +import platform.tooling.support.Request; |
| 28 | + |
| 29 | +/** |
| 30 | + * @since 1.9.1 |
| 31 | + */ |
| 32 | +class GraalVmStarterTests { |
| 33 | + |
| 34 | + @Test |
| 35 | + void runsTestsInNativeImage() { |
| 36 | + var request = Request.builder() // |
| 37 | + .setTool(new GradleWrapper(Paths.get(".."))) // |
| 38 | + .setProject("graalvm-starter") // |
| 39 | + .addArguments("-Dmaven.repo=" + MavenRepo.dir()) // |
| 40 | + .addArguments("javaToolchains", "nativeTest", "--no-daemon", "--stacktrace") // |
| 41 | + .setTimeout(TOOL_TIMEOUT) // |
| 42 | + .build(); |
| 43 | + |
| 44 | + var result = request.run(); |
| 45 | + |
| 46 | + assertFalse(result.isTimedOut(), () -> "tool timed out: " + result); |
| 47 | + |
| 48 | + assumeFalse( |
| 49 | + result.getOutputLines("err").stream().anyMatch(line -> line.contains("No compatible toolchains found")), |
| 50 | + "Abort test if GraalVM is not installed"); |
| 51 | + |
| 52 | + assertEquals(0, result.getExitCode()); |
| 53 | + assertTrue(result.getOutputLines("out").stream().anyMatch(line -> line.contains("BUILD SUCCESSFUL"))); |
| 54 | + |
| 55 | + var testResultsDir = Request.WORKSPACE.resolve(request.getWorkspace()).resolve("build/test-results/test"); |
| 56 | + verifyContainsExpectedStartedOpenTestReport(testResultsDir); |
| 57 | + } |
| 58 | +} |
0 commit comments