|
27 | 27 | * #L% |
28 | 28 | */ |
29 | 29 |
|
30 | | -package org.apposed.appose; |
| 30 | +package org.apposed.appose.builder; |
31 | 31 |
|
32 | | -import org.apposed.appose.Service.Task; |
33 | | -import org.apposed.appose.builder.MambaBuilder; |
34 | | -import org.apposed.appose.builder.PixiBuilder; |
35 | | -import org.apposed.appose.builder.UvBuilder; |
| 32 | +import org.apposed.appose.Appose; |
| 33 | +import org.apposed.appose.Environment; |
| 34 | +import org.apposed.appose.TestBase; |
36 | 35 | import org.apposed.appose.util.FilePaths; |
37 | 36 | import org.junit.jupiter.api.Test; |
38 | 37 |
|
39 | 38 | import java.io.File; |
40 | 39 | import java.io.IOException; |
41 | | -import java.util.List; |
42 | 40 |
|
43 | | -import static org.junit.jupiter.api.Assertions.assertEquals; |
44 | | -import static org.junit.jupiter.api.Assertions.assertFalse; |
45 | 41 | import static org.junit.jupiter.api.Assertions.assertInstanceOf; |
46 | | -import static org.junit.jupiter.api.Assertions.assertNotNull; |
47 | 42 | import static org.junit.jupiter.api.Assertions.assertThrows; |
48 | | -import static org.junit.jupiter.api.Assertions.assertTrue; |
49 | 43 |
|
50 | | -/** End-to-end tests for the Appose builder subsystem and implementations. */ |
51 | | -public class BuilderTest extends TestBase { |
| 44 | +/** End-to-end tests for {@link PixiBuilder}. */ |
| 45 | +public class PixiBuilderTest extends TestBase { |
52 | 46 |
|
53 | 47 | /** Tests the builder-agnostic API with an environment.yml file. */ |
54 | 48 | @Test |
@@ -125,60 +119,6 @@ public void testPixiPyproject() throws Exception { |
125 | 119 | cowsayAndAssert(env, "pixi-pyproject"); |
126 | 120 | } |
127 | 121 |
|
128 | | - /** Tests explicit mamba builder selection using {@code .builder()} method. */ |
129 | | - @Test |
130 | | - public void testExplicitMambaBuilder() throws Exception { |
131 | | - Environment env = Appose |
132 | | - .file("src/test/resources/envs/cowsay.yml") |
133 | | - .builder("mamba") |
134 | | - .base("target/envs/mamba-cowsay") |
135 | | - .logDebug() |
136 | | - .build(); |
137 | | - |
138 | | - assertInstanceOf(MambaBuilder.class, env.builder()); |
139 | | - |
140 | | - // Verify it actually used mamba by checking for conda-meta directory. |
141 | | - File envBase = new File(env.base()); |
142 | | - File condaMeta = new File(envBase, "conda-meta"); |
143 | | - assertTrue(condaMeta.exists() && condaMeta.isDirectory(), |
144 | | - "Environment should have conda-meta directory when using mamba builder"); |
145 | | - |
146 | | - cowsayAndAssert(env, "yay"); |
147 | | - } |
148 | | - |
149 | | - @Test |
150 | | - public void testUv() throws Exception { |
151 | | - Environment env = Appose |
152 | | - .uv("src/test/resources/envs/cowsay-requirements.txt") |
153 | | - .base("target/envs/uv-cowsay") |
154 | | - .logDebug() |
155 | | - .build(); |
156 | | - assertInstanceOf(UvBuilder.class, env.builder()); |
157 | | - cowsayAndAssert(env, "uv"); |
158 | | - } |
159 | | - |
160 | | - @Test |
161 | | - public void testUvBuilderAPI() throws Exception { |
162 | | - Environment env = Appose |
163 | | - .uv() |
164 | | - .include("cowsay==6.1") |
165 | | - .base("target/envs/uv-cowsay-builder") |
166 | | - .logDebug() |
167 | | - .build(); |
168 | | - assertInstanceOf(UvBuilder.class, env.builder()); |
169 | | - cowsayAndAssert(env, "fast"); |
170 | | - } |
171 | | - |
172 | | - @Test |
173 | | - public void testUvPyproject() throws Exception { |
174 | | - Environment env = Appose |
175 | | - .uv("src/test/resources/envs/cowsay-pyproject.toml") |
176 | | - .base("target/envs/uv-cowsay-pyproject") |
177 | | - .logDebug() |
178 | | - .build(); |
179 | | - cowsayAndAssert(env, "pyproject"); |
180 | | - } |
181 | | - |
182 | 122 | /** Tests building environment from content string using type-specific builder.*/ |
183 | 123 | @Test |
184 | 124 | public void testContentAPI() throws Exception { |
@@ -251,75 +191,4 @@ public void testContentPixiToml() throws Exception { |
251 | 191 | assertInstanceOf(PixiBuilder.class, env.builder()); |
252 | 192 | cowsayAndAssert(env, "toml!"); |
253 | 193 | } |
254 | | - |
255 | | - /** |
256 | | - * Tests fluent chaining from base Builder methods to SimpleBuilder methods. |
257 | | - * This verifies that the recursive generics enable natural method chaining. |
258 | | - */ |
259 | | - @Test |
260 | | - public void testCustom() throws Exception { |
261 | | - Environment env = Appose.custom() |
262 | | - .env("CUSTOM_VAR", "test_value") // Base Builder method |
263 | | - .inheritRunningJava() // SimpleBuilder method |
264 | | - .appendSystemPath() // SimpleBuilder method |
265 | | - .build(); |
266 | | - |
267 | | - assertNotNull(env); |
268 | | - assertNotNull(env.binPaths()); |
269 | | - assertFalse(env.binPaths().isEmpty(), |
270 | | - "Custom environment should have binary paths configured"); |
271 | | - assertTrue(env.launchArgs().isEmpty(), |
272 | | - "Custom environment should have no special launcher"); |
273 | | - |
274 | | - // Verify environment variables are propagated. |
275 | | - assertNotNull(env.envVars()); |
276 | | - assertEquals("test_value", env.envVars().get("CUSTOM_VAR")); |
277 | | - |
278 | | - // Verify inheritRunningJava() sets JAVA_HOME. |
279 | | - String javaHome = System.getProperty("java.home"); |
280 | | - if (javaHome != null) { |
281 | | - assertEquals(javaHome, env.envVars().get("JAVA_HOME")); |
282 | | - // Verify Java bin directory is in binPaths. |
283 | | - String javaBin = new File(javaHome, "bin").getAbsolutePath(); |
284 | | - assertTrue(env.binPaths().contains(javaBin), |
285 | | - "Java bin directory should be in binPaths"); |
286 | | - } |
287 | | - |
288 | | - // Verify that the custom environment can execute Python tasks. |
289 | | - try (Service service = env.python()) { |
290 | | - maybeDebug(service); |
291 | | - Task task = service.task("2 + 2"); |
292 | | - task.waitFor(); |
293 | | - assertComplete(task); |
294 | | - Number result = (Number) task.result(); |
295 | | - assertEquals(4, result.intValue()); |
296 | | - } |
297 | | - |
298 | | - // Test custom environment with specific base directory. |
299 | | - File customDir = new File("target/test-custom"); |
300 | | - customDir.mkdirs(); |
301 | | - try { |
302 | | - Environment customEnv = Appose.custom() |
303 | | - .base(customDir) |
304 | | - .appendSystemPath() |
305 | | - .build(); |
306 | | - |
307 | | - assertEquals(customDir.getAbsolutePath(), customEnv.base()); |
308 | | - assertNotNull(customEnv.binPaths()); |
309 | | - } |
310 | | - finally { |
311 | | - customDir.delete(); |
312 | | - } |
313 | | - |
314 | | - // Test custom environment with specific binary paths. |
315 | | - Environment pathEnv = Appose.custom() |
316 | | - .binPaths("/usr/bin", "/usr/local/bin") |
317 | | - .build(); |
318 | | - |
319 | | - List<String> binPaths = pathEnv.binPaths(); |
320 | | - assertTrue(binPaths.contains("/usr/bin"), |
321 | | - "Custom binPaths should include /usr/bin"); |
322 | | - assertTrue(binPaths.contains("/usr/local/bin"), |
323 | | - "Custom binPaths should include /usr/local/bin"); |
324 | | - } |
325 | 194 | } |
0 commit comments