@@ -39,12 +39,9 @@ public static void clearTestoutputFolder() throws IOException {
3939 Files .createDirectory (TESTOUTPUT );
4040 }
4141
42- public void run_python_script (String scriptName , String ... args ) throws IOException , InterruptedException {
42+ public static int runCommand (String ... command ) throws IOException , InterruptedException {
4343 ProcessBuilder pb = new ProcessBuilder ();
44- pb .command ().add ("uv" );
45- pb .command ().add ("run" );
46- pb .command ().add (PYTHON_TEST_PATH .resolve (scriptName ).toString ());
47- pb .command ().addAll (Arrays .asList (args ));
44+ pb .command ().addAll (Arrays .asList (command ));
4845 Process process = pb .start ();
4946
5047 BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
@@ -58,7 +55,27 @@ public void run_python_script(String scriptName, String... args) throws IOExcept
5855 System .err .println (line );
5956 }
6057
61- int exitCode = process .waitFor ();
58+ return process .waitFor ();
59+ }
60+
61+ @ BeforeAll
62+ public static void setupUV () {
63+ try {
64+ int exitCode = runCommand ("uv" , "version" );
65+ if (exitCode != 0 ) {
66+ //setup uv
67+ assert runCommand ("uv" , "venv" ) == 0 ;
68+ assert runCommand ("uv" , "init" ) == 0 ;
69+ assert runCommand ("uv" , "add" , "zarr" ) == 0 ;
70+ }
71+ } catch (IOException | InterruptedException e ) {
72+ throw new RuntimeException ("uv not installed or not in PATH. See" );
73+ }
74+ }
75+
76+ public void run_python_script (String scriptName , String ... args ) throws IOException , InterruptedException {
77+ int exitCode = runCommand (Stream .concat (Stream .of ("uv" , "run" , PYTHON_TEST_PATH .resolve (scriptName )
78+ .toString ()), Arrays .stream (args )).toArray (String []::new ));
6279 assert exitCode == 0 ;
6380 }
6481
0 commit comments