Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test agent execution fails in directory with spaces #485

Open
Marcono1234 opened this issue Aug 12, 2023 · 0 comments
Open

Test agent execution fails in directory with spaces #485

Marcono1234 opened this issue Aug 12, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Marcono1234
Copy link

Describe the bug
Trying to run Native Image tests with the agent fails if the project directory path contains spaces.

(Might also apply when running the application with the agent.)

To Reproduce

Steps to reproduce the behavior:

  1. Create a directory with a space in its name, for example path with-spaces
  2. In that directory create a pom.xml file with the following content:
    <project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
    
      <groupId>com.mycompany.app</groupId>
      <artifactId>my-app</artifactId>
      <version>1.0-SNAPSHOT</version>
    
      <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
      </properties>
    
      <dependencies>
        <dependency>
          <groupId>org.junit.jupiter</groupId>
          <artifactId>junit-jupiter</artifactId>
          <version>5.10.0</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
    
      <build>
        <plugins>
          <plugin>
            <groupId>org.graalvm.buildtools</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <version>0.9.24</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <id>test-native</id>
                <goals>
                  <goal>test</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </project>
  3. Create the test source file src/test/java/MyTest.java with the following content:
    import static org.junit.jupiter.api.Assertions.assertTrue;
    
    import org.junit.jupiter.api.Test;
    
    class MyTest {
        @Test
        void test() {
            assertTrue(true);
        }
    }
  4. Run mvn clean test -Dagent=true
    ❌ Bug: Surefire execution fails with:
    Error: Could not find or load main class with-spaces\target\native\agent-output\test\session-{pid}-{datetime}
    Caused by: java.lang.ClassNotFoundException: with-spaces\target\native\agent-output\test\session-{pid}-{datetime}
    

Expected behavior
Execution does not fail

Logs
Surefire log on console:

[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C "C:\Users\...\Downloads\graalvm-jdk-17.0.8+9.1\bin\java -agentlib:native-image-agent=config-output-dir=C:\Users\...\Downloads\test-native\path with-spaces\target\native\agent-output\test\session-{pid}-{datetime} -jar C:\Users\...\AppData\Local\Temp\surefire9367496019182751827\surefirebooter-20230812135354914_3.jar C:\Users\...\AppData\Local\Temp\surefire9367496019182751827 2023-08-12T13-53-54_661-jvmRun1 surefire-20230812135354914_1tmp surefire_0-20230812135354914_2tmp"

Note how there are no quotes around the -agentlib argument.

System Info (please complete the following information):

  • OS: Windows 10
  • GraalVM Version: Graal JDK 17.0.8+9.1 / GraalVM 23.0.1
  • Java Version: 17
  • Plugin version: native-maven-plugin:0.9.24

Additional context
The Gradle plugin might be affected as well, but I have not tested it.

@Marcono1234 Marcono1234 added the bug Something isn't working label Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant