0

I am trying to follow this documentation to add integration tests to a cloud function:

https://cloud.google.com/functions/docs/samples/functions-storage-integration-test

The first step (setup) basically starts a process using java.lang.Process:

   @BeforeClass
  public static void setUp() throws IOException {


    // Get the sample's base directory (the one containing a pom.xml file)
    String baseDir = System.getProperty("user.dir");

    // Emulate the function locally by running the Functions Framework Maven plugin
    emulatorProcess = new ProcessBuilder()
        .command("mvn", "function:run -Drun.functionTarget=function.MyFunction")
        .directory(new File("C:/"))
        .start();
  }

This throws the error

java.io.IOException: Cannot run program "mvn" (in directory "C:"): CreateProcess error=2, The system cannot find the file specified

The same happens if I instead of C:\ I follow the example and use

  String baseDir = System.getProperty("user.dir");

The funny thing is that if I just open a console and type

mvn function:run -Drun.functionTarget=function.MyFunction

When I pass the full path of the mvn command I end up with

CreateProcess error=193, %1 is not a valid Win32 application.

The path looks like "C:\Users\carlos.palma\apache-maven-3.8.8\bin\mvn"

I can execute the cloud function locally. Is there something I'm missing related to the setup of this "Functions Framework Maven plugin" ?

3
  • Does your code know how to find mvn in your shell PATH, since you're not providing the full path to it to ProcessBuilder? If not, the result isn't surprising at all. See: stackoverflow.com/questions/40168112/… Commented Nov 29, 2023 at 23:14
  • Hello @DougStevenson, and thanks for your interest in my question. When I pass the full path of the mvn command I end up with CreateProcess error=193, %1 is not a valid Win32 application. The path looks like "C:\\Users\\carlos.palma\\apache-maven-3.8.8\\bin\\mvn" Commented Nov 30, 2023 at 15:36
  • 1
    That's information you should probably add to your question to make it more clear what you tried and what doesn't work. Commented Nov 30, 2023 at 15:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.