38
38
# SOFTWARE.
39
39
40
40
import os
41
+ import shutil
41
42
import subprocess
42
43
import sys
43
44
import unittest
44
45
import urllib .parse
45
- import shutil
46
46
47
47
MAVEN_VERSION = "3.9.8"
48
48
GLOBAL_MVN_CMD = [shutil .which ('mvn' ), "--batch-mode" ]
55
55
is_gradle_plugin_test_enabled = 'ENABLE_GRADLE_PLUGIN_UNITTESTS' in os .environ and os .environ ['ENABLE_GRADLE_PLUGIN_UNITTESTS' ] == "true"
56
56
57
57
class PolyglotAppTestBase (unittest .TestCase ):
58
- def setUpClass (self ):
58
+ @classmethod
59
+ def setUpClass (cls ):
59
60
if not is_maven_plugin_test_enabled and not is_gradle_plugin_test_enabled :
60
61
return
61
62
62
- self .env = os .environ .copy ()
63
- self .env ["PYLAUNCHER_DEBUG" ] = "1"
63
+ cls .env = os .environ .copy ()
64
+ cls .env ["PYLAUNCHER_DEBUG" ] = "1"
64
65
65
- self .archetypeGroupId = "org.graalvm.python"
66
- self .archetypeArtifactId = "graalpy-archetype-polyglot-app"
67
- self .pluginArtifactId = "graalpy-maven-plugin"
68
- self .graalvmVersion = get_graalvm_version ()
66
+ cls .archetypeGroupId = "org.graalvm.python"
67
+ cls .archetypeArtifactId = "graalpy-archetype-polyglot-app"
68
+ cls .pluginArtifactId = "graalpy-maven-plugin"
69
+ cls .graalvmVersion = get_graalvm_version ()
69
70
70
71
for custom_repo in os .environ .get ("MAVEN_REPO_OVERRIDE" , "" ).split ("," ):
71
72
url = urllib .parse .urlparse (custom_repo )
72
73
if url .scheme == "file" :
73
74
jar = os .path .join (
74
75
url .path ,
75
- self .archetypeGroupId .replace ("." , os .path .sep ),
76
- self .archetypeArtifactId ,
77
- self .graalvmVersion ,
78
- f"{ self .archetypeArtifactId } -{ self .graalvmVersion } .jar" ,
76
+ cls .archetypeGroupId .replace ("." , os .path .sep ),
77
+ cls .archetypeArtifactId ,
78
+ cls .graalvmVersion ,
79
+ f"{ cls .archetypeArtifactId } -{ cls .graalvmVersion } .jar" ,
79
80
)
80
81
pom = os .path .join (
81
82
url .path ,
82
- self .archetypeGroupId .replace ("." , os .path .sep ),
83
- self .archetypeArtifactId ,
84
- self .graalvmVersion ,
85
- f"{ self .archetypeArtifactId } -{ self .graalvmVersion } .pom" ,
83
+ cls .archetypeGroupId .replace ("." , os .path .sep ),
84
+ cls .archetypeArtifactId ,
85
+ cls .graalvmVersion ,
86
+ f"{ cls .archetypeArtifactId } -{ cls .graalvmVersion } .pom" ,
86
87
)
87
88
cmd = GLOBAL_MVN_CMD + [
88
89
"install:install-file" ,
89
90
f"-Dfile={ jar } " ,
90
- f"-DgroupId={ self .archetypeGroupId } " ,
91
- f"-DartifactId={ self .archetypeArtifactId } " ,
92
- f"-Dversion={ self .graalvmVersion } " ,
91
+ f"-DgroupId={ cls .archetypeGroupId } " ,
92
+ f"-DartifactId={ cls .archetypeArtifactId } " ,
93
+ f"-Dversion={ cls .graalvmVersion } " ,
93
94
"-Dpackaging=jar" ,
94
95
f"-DpomFile={ pom } " ,
95
96
"-DcreateChecksum=true" ,
96
97
]
97
- out , return_code = run_cmd (cmd , self .env )
98
+ out , return_code = run_cmd (cmd , cls .env )
98
99
assert return_code == 0
99
100
100
101
jar = os .path .join (
101
102
url .path ,
102
- self .archetypeGroupId .replace ("." , os .path .sep ),
103
- self .pluginArtifactId ,
104
- self .graalvmVersion ,
105
- f"{ self .pluginArtifactId } -{ self .graalvmVersion } .jar" ,
103
+ cls .archetypeGroupId .replace ("." , os .path .sep ),
104
+ cls .pluginArtifactId ,
105
+ cls .graalvmVersion ,
106
+ f"{ cls .pluginArtifactId } -{ cls .graalvmVersion } .jar" ,
106
107
)
107
108
108
109
pom = os .path .join (
109
110
url .path ,
110
- self .archetypeGroupId .replace ("." , os .path .sep ),
111
- self .pluginArtifactId ,
112
- self .graalvmVersion ,
113
- f"{ self .pluginArtifactId } -{ self .graalvmVersion } .pom" ,
111
+ cls .archetypeGroupId .replace ("." , os .path .sep ),
112
+ cls .pluginArtifactId ,
113
+ cls .graalvmVersion ,
114
+ f"{ cls .pluginArtifactId } -{ cls .graalvmVersion } .pom" ,
114
115
)
115
116
116
117
cmd = GLOBAL_MVN_CMD + [
117
118
"install:install-file" ,
118
119
f"-Dfile={ jar } " ,
119
- f"-DgroupId={ self .archetypeGroupId } " ,
120
- f"-DartifactId={ self .pluginArtifactId } " ,
121
- f"-Dversion={ self .graalvmVersion } " ,
120
+ f"-DgroupId={ cls .archetypeGroupId } " ,
121
+ f"-DartifactId={ cls .pluginArtifactId } " ,
122
+ f"-Dversion={ cls .graalvmVersion } " ,
122
123
"-Dpackaging=jar" ,
123
124
f"-DpomFile={ pom } " ,
124
125
"-DcreateChecksum=true" ,
125
126
]
126
- out , return_code = run_cmd (cmd , self .env )
127
+ out , return_code = run_cmd (cmd , cls .env )
127
128
assert return_code == 0
128
129
break
129
130
@@ -285,4 +286,4 @@ def patch_properties_file(properties_file, distribution_url_override):
285
286
else :
286
287
new_lines .append (line )
287
288
with (open (properties_file , "w" )) as f :
288
- f .writelines (new_lines )
289
+ f .writelines (new_lines )
0 commit comments