Skip to content

Commit

Permalink
change testing dir and use repo with whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
houcine7 committed Jul 28, 2024
1 parent 988cfad commit c87de63
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 32 deletions.
1 change: 0 additions & 1 deletion .github/actions/prepare-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ runs:
git config --global user.name 'graalvm bot'
git config --global user.email '[email protected]'
echo "org.ajoberstar.grgit.auth.command.allow=true" >> gradle.properties
mkdir -p ~/test with whitespaces/.m2
27 changes: 0 additions & 27 deletions .github/workflows/test-native-maven-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,3 @@ jobs:
with:
name: maven-functional-tests-results-${{ matrix.os }}
path: native-maven-plugin/build/reports/tests/

test-native-maven-plugin-with-whitespaces:
name: "🧪 Maven: ${{ matrix.test }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
timeout-minutes: 60
needs: populate-matrix
strategy:
fail-fast: false
matrix: ${{fromJson(needs.populate-matrix.outputs.matrix)}}
steps:
- name: "☁️ Checkout repository"
uses: actions/checkout@v4
- name: "🔧 Prepare environment"
uses: ./.github/actions/prepare-environment
with:
java-version: ${{ matrix.java-version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "Set .m2 location to a folder with whitespaces"
run: echo "MAVEN_OPTS=-Dmaven.repo.local=~/test with whitespaces/.m2" >> $GITHUB_ENV
- name: "❓ Check and test the plugin"
run: ./gradlew :native-maven-plugin:functionalTest --no-daemon --fail-fast --tests ${{ matrix.test }}
- name: "📜 Upload unit test results"
if: always()
uses: actions/upload-artifact@v3
with:
name: maven-functional-tests-results-${{ matrix.os }}
path: native-maven-plugin/build/reports/tests/
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ protected List<String> getBuildArgs() throws MojoExecutionException {
if (buildArgs != null && !buildArgs.isEmpty()) {
for (String buildArg : buildArgs) {
if(buildArg.startsWith("\\Q") ||
buildArg.startsWith("--H:ConfigurationFileDirectories")) {
buildArg.startsWith("-H:ConfigurationFileDirectories")) {
cliArgs.add(buildArg);
continue;
}
String[] args = buildArg.split("\\s+");
int i=0;
while(i < args.length) {
String a =args[i];
if (a.startsWith(""+System.getProperty("user.home").charAt(0))) {
if (a.charAt(0) == System.getProperty("user.home").charAt(0)) {
StringBuilder path = new StringBuilder(a);
i++;
while( i< args.length && args[i].toLowerCase().charAt(0) <= 'z' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ import org.eclipse.jetty.server.handler.ResourceHandler
import spock.lang.Specification
import spock.lang.TempDir

import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor
import java.nio.file.StandardCopyOption
import java.nio.file.attribute.BasicFileAttributes

abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
@TempDir

Path testDirectory

Path testOrigin;
Expand All @@ -71,6 +74,13 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
boolean IS_MAC = System.getProperty("os.name", "unknown").contains("Mac");

def setup() {
var home_dir = Path.of(System.getProperty("user.home"))
testDirectory = home_dir.resolve("tests")

if (Files.notExists(testDirectory)) {
Files.createDirectory(testDirectory)
}

executor = new IsolatedMavenExecutor(
new File(System.getProperty("java.executable")),
testDirectory.resolve("m2-home").toFile(),
Expand All @@ -79,6 +89,21 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
}

def cleanup() {

//cleanup test directory and all it's sub directories
Files.walkFileTree(testDirectory, new SimpleFileVisitor<Path>() {
@Override
FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});

if (server != null) {
server.stop()
server.destroy()
Expand Down Expand Up @@ -158,7 +183,7 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
var resultingSystemProperties = [
"common.repo.uri": System.getProperty("common.repo.uri"),
"seed.repo.uri": System.getProperty("seed.repo.uri"),
"maven.repo.local": testDirectory.resolve("local-repo").toFile().absolutePath
"maven.repo.local": testDirectory.resolve("local repo").toFile().absolutePath
]
resultingSystemProperties.putAll(systemProperties)

Expand Down

0 comments on commit c87de63

Please sign in to comment.