davsclaus commented on code in PR #28004:
URL: https://github.com/apache/camel/pull/28004#discussion_r4302906675
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CamelCommandBaseTestSupport.java:
##########
@@ -17,20 +17,56 @@
package org.apache.camel.dsl.jbang.core.commands;
+import java.io.IOException;
+import java.nio.file.Files;
import java.nio.file.Path;
+import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
import org.apache.camel.dsl.jbang.core.common.StringPrinter;
+import org.apache.camel.util.FileUtil;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
public class CamelCommandBaseTestSupport {
protected StringPrinter printer;
+ private Path previousHome;
+ private Path testHome;
+
@BeforeEach
public void setup() throws Exception {
printer = new StringPrinter();
}
+ /**
+ * Gives the test a home directory of its own: an empty directory for the
{@code .camel} directory, the user
+ * configuration and the plugins of the CLI. The tests run in parallel
forks, so a fixed directory would be shared
+ * with the tests of the other forks. The previous home is used again
after the test.
+ *
+ * @return the home directory
+ */
+ protected Path useTestHomeDir() throws IOException {
+ if (previousHome == null) {
+ previousHome = CommandLineHelper.getHomeDir();
+ }
+ testHome = Files.createTempDirectory("camel-cli-test-home");
Review Comment:
Applied in 6cb566e3168f: a second call removes the temporary home of the
earlier one.
_Claude Code on behalf of davsclaus_
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/EvalSimpleTest.java:
##########
@@ -16,15 +16,39 @@
*/
package org.apache.camel.dsl.jbang.core.commands;
+import java.nio.file.Path;
+
import org.apache.camel.dsl.jbang.core.commands.action.EvalExpressionCommand;
+import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
+import org.apache.camel.util.HomeHelper;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import picocli.CommandLine;
+@UsesWorkingDirectory
@DisabledIfSystemProperty(named = "ci.env.name", matches = ".*",
disabledReason = "Runs only local")
class EvalSimpleTest extends CamelCommandBaseTestSupport {
+ private Path previousHome;
Review Comment:
Done in 6cb566e3168f a bit differently: `CamelCommandBaseTestSupport` has
`useHomeDir(Path)` now, which uses a given home and restores the previous one
after the test (`useTestHomeDir()` uses it too). `EvalSimpleTest` calls it with
the home of the user, without a field or an `@AfterEach` of its own, and its
comment says why it does not use `useTestHomeDir()`. AGENTS.md of the module
mentions `useHomeDir(Path)`.
_Claude Code on behalf of davsclaus_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]