38
38
# SOFTWARE.
39
39
40
40
import os
41
- import subprocess
42
41
import tempfile
43
42
import unittest
44
43
import urllib .parse
@@ -217,7 +216,7 @@ def generate_app(self, target_dir):
217
216
218
217
@unittest .skipUnless (is_gradle_enabled , "ENABLE_GRADLE_STANDALONE_UNITTESTS is not true" )
219
218
def test_gradle_generated_app (self ):
220
- with tempfile .TemporaryDirectory () as tmpdir :
219
+ with tempfile .TemporaryDirectory () as tmpdir :
221
220
target_dir = os .path .join (str (tmpdir ), "generated_app_gradle" + self .target_dir_name_sufix ())
222
221
self .generate_app (target_dir )
223
222
build_file = os .path .join (target_dir , self .build_file_name )
@@ -231,7 +230,7 @@ def test_gradle_generated_app(self):
231
230
util .check_ouput ("BUILD SUCCESS" , out )
232
231
233
232
cmd = gradlew_cmd + ["nativeCompile" ]
234
- # gradle needs jdk <= 22, but it looks like the 'gradle nativeCompile' cmd does not complain if higher,
233
+ # gradle needs jdk <= 22, but it looks like the 'gradle nativeCompile' cmd does not complain if higher,
235
234
# which is fine, because we need to build the native binary with a graalvm build
236
235
# and the one we have set in JAVA_HOME is at least jdk24
237
236
# => run without gradle = True
@@ -267,6 +266,22 @@ def test_gradle_generated_app(self):
267
266
#GR-51132 - NoClassDefFoundError when running polyglot app in java mode
268
267
util .check_ouput ("java.lang.NoClassDefFoundError" , out , False )
269
268
269
+ # move app to another folder
270
+ # this will break launcher symlinks, but should be able to recover from that
271
+ target_dir2 = os .path .join (str (tmpdir ), "generated_app_gradle.2" + self .target_dir_name_sufix ())
272
+ os .rename (target_dir , target_dir2 )
273
+ # adding new dep triggers launcher without venv regen
274
+ self .copy_build_files (target_dir2 )
275
+ build_file2 = os .path .join (target_dir2 , self .build_file_name )
276
+ append (build_file2 , self .packages_termcolor_ujson ())
277
+
278
+ gradlew_cmd2 = util .get_gradle_wrapper (target_dir2 , self .env )
279
+ cmd = gradlew_cmd2 + ["build" , "run" ]
280
+ out , return_code = util .run_cmd (cmd , self .env , cwd = target_dir2 , gradle = True )
281
+ util .check_ouput ("BUILD SUCCESS" , out )
282
+ util .check_ouput ("Deleting GraalPy venv due to broken launcher symlinks" , out )
283
+ util .check_ouput ("hello java" , out )
284
+
270
285
@unittest .skipUnless (is_gradle_enabled , "ENABLE_GRADLE_STANDALONE_UNITTESTS is not true" )
271
286
def test_gradle_generated_app_external_resources (self ):
272
287
with tempfile .TemporaryDirectory () as tmpdir :
@@ -300,7 +315,7 @@ def test_gradle_generated_app_external_resources(self):
300
315
out , return_code = util .run_cmd (cmd , self .env , cwd = target_dir , gradle = True )
301
316
util .check_ouput ("BUILD SUCCESS" , out )
302
317
303
- # gradle needs jdk <= 22, but it looks like the 'gradle nativeCompile' cmd does not complain if higher,
318
+ # gradle needs jdk <= 22, but it looks like the 'gradle nativeCompile' cmd does not complain if higher,
304
319
# which is fine, because we need to build the native binary with a graalvm build
305
320
# and the one we have set in JAVA_HOME is at least jdk24
306
321
# => run without gradle = True
@@ -704,6 +719,19 @@ def test_generated_app(self):
704
719
#GR-51132 - NoClassDefFoundError when running polyglot app in java mode
705
720
util .check_ouput ("java.lang.NoClassDefFoundError" , out , False )
706
721
722
+ # move app to another folder
723
+ # this will break launcher symlinks, but should be able to recover from that
724
+ target_dir2 = os .path .join (str (tmpdir ), target_name + ".2" )
725
+ os .rename (target_dir , target_dir2 )
726
+ mvnw_cmd2 = util .get_mvn_wrapper (target_dir2 , self .env )
727
+ # adding new dep triggers launcher without venv regen
728
+ util .replace_in_file (os .path .join (target_dir2 , "pom.xml" ), "<packages>" , "<packages>\n <package>ujson</package>" )
729
+ cmd = mvnw_cmd2 + ["package" , "exec:java" , "-Dexec.mainClass=it.pkg.GraalPy" ]
730
+ out , return_code = util .run_cmd (cmd , self .env , cwd = target_dir2 )
731
+ util .check_ouput ("BUILD SUCCESS" , out )
732
+ util .check_ouput ("Deleting GraalPy venv due to changed launcher path" , out )
733
+ util .check_ouput ("hello java" , out )
734
+
707
735
@unittest .skipUnless (is_enabled , "ENABLE_STANDALONE_UNITTESTS is not true" )
708
736
def test_generated_app_external_resources (self ):
709
737
with tempfile .TemporaryDirectory () as tmpdir :
0 commit comments