Skip to content

Commit 2798688

Browse files
committed
Cleanup tests
1 parent 8fcddbf commit 2798688

File tree

2 files changed

+21
-32
lines changed

2 files changed

+21
-32
lines changed

native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationFunctionalTest.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,16 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
131131
file("target/").listFiles().findAll(x->x.name.contains("native-image") && x.name.endsWith(".args")).size() == 1
132132
}
133133
134+
def "can handle spaces when writing the args file"() {
135+
withSpacesInProjectDir()
136+
withSample("java-application")
137+
138+
when:
139+
mvn '-DquickBuild', '-Pnative', 'native:write-args-file'
140+
141+
then:
142+
buildSucceeded
143+
outputContains "Args file written to: target" + File.separator + "native-image"
144+
}
145+
134146
}

native-maven-plugin/src/testFixtures/groovy/org/graalvm/buildtools/maven/AbstractGraalVMMavenFunctionalTest.groovy

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,20 @@ package org.graalvm.buildtools.maven
4343

4444
import org.eclipse.jetty.server.Server
4545
import org.eclipse.jetty.server.ServerConnector
46-
import org.eclipse.jetty.server.SymlinkAllowedResourceAliasChecker
4746
import org.eclipse.jetty.server.handler.ContextHandler
4847
import org.eclipse.jetty.server.handler.ResourceHandler
4948
import spock.lang.Specification
5049
import spock.lang.TempDir
5150

52-
import java.nio.file.FileVisitResult
5351
import java.nio.file.Files
5452
import java.nio.file.Path
55-
import java.nio.file.SimpleFileVisitor
5653
import java.nio.file.StandardCopyOption
57-
import java.nio.file.attribute.BasicFileAttributes
5854

5955
abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
60-
56+
@TempDir
6157
Path testDirectory
6258

63-
Path testOrigin;
59+
Path testOrigin
6460

6561
private IsolatedMavenExecutor executor
6662

@@ -69,18 +65,11 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
6965
Server server
7066
ServerConnector connector
7167

72-
boolean IS_WINDOWS = System.getProperty("os.name", "unknown").contains("Windows");
73-
boolean IS_LINUX = System.getProperty("os.name", "unknown").contains("Linux");
74-
boolean IS_MAC = System.getProperty("os.name", "unknown").contains("Mac");
68+
boolean IS_WINDOWS = System.getProperty("os.name", "unknown").contains("Windows")
69+
boolean IS_LINUX = System.getProperty("os.name", "unknown").contains("Linux")
70+
boolean IS_MAC = System.getProperty("os.name", "unknown").contains("Mac")
7571

7672
def setup() {
77-
Path HomeDir = Path.of(System.getProperty("user.home"))
78-
testDirectory = HomeDir.resolve("tests")
79-
80-
if (Files.notExists(testDirectory)) {
81-
Files.createDirectory(testDirectory)
82-
}
83-
8473
executor = new IsolatedMavenExecutor(
8574
new File(System.getProperty("java.executable")),
8675
testDirectory.resolve("m2-home").toFile(),
@@ -89,19 +78,6 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
8978
}
9079

9180
def cleanup() {
92-
Files.walkFileTree(testDirectory, new SimpleFileVisitor<Path>() {
93-
@Override
94-
FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
95-
Files.delete(file);
96-
return FileVisitResult.CONTINUE;
97-
}
98-
@Override
99-
FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
100-
Files.delete(dir);
101-
return FileVisitResult.CONTINUE;
102-
}
103-
});
104-
10581
if (server != null) {
10682
server.stop()
10783
server.destroy()
@@ -177,12 +153,13 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
177153
}
178154

179155
void mvn(List<String> args, Map<String, String> systemProperties) {
180-
System.out.println("Running copy of maven project `" + testOrigin + "` with " + args);
156+
println("Running copy of maven project ${testOrigin} in ${testDirectory} with $args")
181157
var resultingSystemProperties = [
182158
"common.repo.uri": System.getProperty("common.repo.uri"),
183159
"seed.repo.uri": System.getProperty("seed.repo.uri"),
184-
"maven.repo.local": testDirectory.resolve("local repo").toFile().absolutePath
160+
"maven.repo.local": testDirectory.resolve("local-repo").toFile().absolutePath
185161
]
162+
println "Using local repo: ${resultingSystemProperties['maven.repo.local']}"
186163
resultingSystemProperties.putAll(systemProperties)
187164

188165
result = executor.execute(
@@ -192,7 +169,7 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
192169
*args],
193170
new File(System.getProperty("maven.settings"))
194171
)
195-
System.out.println("Exit code is ${result.exitCode}")
172+
println "Exit code is ${result.exitCode}"
196173

197174
}
198175

0 commit comments

Comments
 (0)