@@ -36,7 +36,14 @@ def process_test(test_dir: str):
36
36
37
37
# Run cargo build.
38
38
print ("|--- ⚒️ Building with Cargo..." )
39
- proc = run_command (["cargo" , "build" , "--target" , "../../../jvm-unknown-unknown.json" ], cwd = test_dir )
39
+ # see if the file no_jvm_target.flag exists in the test directory
40
+ no_jvm_target = os .path .join (test_dir , "no_jvm_target.flag" )
41
+ if os .path .exists (no_jvm_target ):
42
+ print ("|---- ⚠️ Skipping JVM target build due to no_jvm_target.flag" )
43
+ proc = run_command (["cargo" , "build" ], cwd = test_dir )
44
+ else :
45
+ print ("|---- 🛠️ Building with JVM target..." )
46
+ proc = run_command (["cargo" , "build" , "--target" , "../../../jvm-unknown-unknown.json" ], cwd = test_dir )
40
47
if proc .returncode != 0 :
41
48
fail_path = os .path .join (test_dir , "cargo-build-fail.generated" )
42
49
output = f"STDOUT:\n { proc .stdout } \n \n STDERR:\n { proc .stderr } "
@@ -46,6 +53,24 @@ def process_test(test_dir: str):
46
53
47
54
# Run java with the generated jar.
48
55
print ("|--- 🤖 Running with Java..." )
56
+ # if no_jvm_target flag is set, we first need to move target/debug/deps/{test_name}-{hash}.jar to target/jvm-unknown-unknown/debug/{test_name}.jar
57
+ # we might need to make the directory first
58
+ if os .path .exists (no_jvm_target ):
59
+ print ("|---- ⚠️ Doing some needed moving around due to no_jvm_target.flag" )
60
+ # move the jar file to the target/jvm-unknown-unknown/debug directory
61
+ jar_path = os .path .join (test_dir , "target" , "debug" , "deps" , f"{ test_name } -*.jar" )
62
+ # find the jar file
63
+ jar_file = None
64
+ for file in os .listdir (os .path .join (test_dir , "target" , "debug" , "deps" )):
65
+ if file .startswith (test_name ) and file .endswith (".jar" ):
66
+ jar_file = file
67
+ break
68
+ if jar_file is None :
69
+ print ("|---- ❌ No jar file found in target/debug/deps" )
70
+ return False
71
+ # move the file
72
+ os .makedirs (os .path .join (test_dir , "target" , "jvm-unknown-unknown" , "debug" ), exist_ok = True )
73
+ os .rename (os .path .join (test_dir , "target" , "debug" , "deps" , jar_file ), os .path .join (test_dir , "target" , "jvm-unknown-unknown" , "debug" , f"{ test_name } .jar" ))
49
74
jar_path = os .path .join (test_dir , "target" , "jvm-unknown-unknown" , "debug" , f"{ test_name } .jar" )
50
75
proc = run_command (["java" , "-jar" , jar_path ])
51
76
if proc .returncode != 0 :
0 commit comments