Skip to content

Commit

Permalink
Adapt ReflectionCompatibilityTests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Nov 28, 2024
1 parent e3349ac commit 2f114a2
Showing 1 changed file with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,35 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static platform.tooling.support.Helper.TOOL_TIMEOUT;
import static platform.tooling.support.tests.Projects.copyToWorkspace;

import java.nio.file.Paths;

import de.sormuras.bartholdy.tool.GradleWrapper;
import java.nio.file.Path;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.ResourceLock;
import org.junit.jupiter.api.io.TempDir;
import org.opentest4j.TestAbortedException;

import platform.tooling.support.Helper;
import platform.tooling.support.MavenRepo;
import platform.tooling.support.Request;
import platform.tooling.support.process.ProcessStarters;

/**
* @since 1.11
*/
class ReflectionCompatibilityTests {

@ResourceLock(Projects.REFLECTION_TESTS)
@Test
void gradle_wrapper() {
var request = Request.builder() //
.setTool(new GradleWrapper(Paths.get(".."))) //
.setProject(Projects.REFLECTION_TESTS) //
void gradle_wrapper(@TempDir Path workspace) throws Exception {
var result = ProcessStarters.gradlew() //
.workingDir(copyToWorkspace(Projects.REFLECTION_TESTS, workspace)) //
.addArguments("-Dmaven.repo=" + MavenRepo.dir()) //
.addArguments("build", "--no-daemon", "--stacktrace", "--no-build-cache", "--warning-mode=fail") //
.setTimeout(TOOL_TIMEOUT) //
.putEnvironment("JDK8", Helper.getJavaHome("8").orElseThrow(TestAbortedException::new).toString()) //
.setJavaHome(ProcessStarters.getGradleJavaHome().orElseThrow(TestAbortedException::new)) //
.build();

var result = request.run();

assertFalse(result.isTimedOut(), () -> "tool timed out: " + result);
.startAndWait();

assertEquals(0, result.getExitCode());
assertTrue(result.getOutputLines("out").stream().anyMatch(line -> line.contains("BUILD SUCCESSFUL")));
assertThat(result.getOutput("out")).contains("Using Java version: 1.8");
assertEquals(0, result.exitCode());
assertTrue(result.stdOut().lines().anyMatch(line -> line.contains("BUILD SUCCESSFUL")));
assertThat(result.stdOut()).contains("Using Java version: 1.8");
}
}

0 comments on commit 2f114a2

Please sign in to comment.