Skip to content

Commit

Permalink
Add test service that will be used to configure default values for te…
Browse files Browse the repository at this point in the history
…st runs

Sometimes the defaults that make sense for end-users do not fit well with our tests. Phantoms for instance should be off by default and only configured.
  • Loading branch information
Col-E committed Jan 12, 2025
1 parent 7d25623 commit 1390a4c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import org.junit.jupiter.api.parallel.Isolated;
import software.coley.recaf.Bootstrap;
import software.coley.recaf.Recaf;
import software.coley.recaf.services.plugin.PluginManagerConfig;
import software.coley.recaf.util.TestEnvironment;
import software.coley.recaf.services.workspace.WorkspaceManager;
import software.coley.recaf.util.TestEnvironment;

import java.lang.annotation.Annotation;

Expand All @@ -17,9 +16,17 @@
*/
@Isolated
public class TestBase {
protected static final Recaf recaf = Bootstrap.get();
protected static final Recaf recaf;
protected static WorkspaceManager workspaceManager;

static {
Bootstrap.setWeldConsumer(w -> w.addPackage(true, TestConfigSetup.class));
recaf = Bootstrap.get();

// Trigger the test-default bean to load
recaf.get(TestConfigSetup.class).configure();
}

@BeforeAll
public static void setupWorkspaceManager() {
TestEnvironment.initTestEnv();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package software.coley.recaf.test;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import software.coley.recaf.services.compile.JavacCompilerConfig;

/**
* Configures default values for the test environment. Some of our values that are best enabled by default
* for users aren't the best for testing the 'base case' of things during test development.
*
* @author Matt Coley
*/
@ApplicationScoped
public class TestConfigSetup {
private final JavacCompilerConfig javac;

@Inject
public TestConfigSetup(JavacCompilerConfig javac) {
this.javac = javac;
}

public void configure() {
// Do not generate phantoms by default when using the compiler service
javac.getGeneratePhantoms().setValue(false);
}
}

0 comments on commit 1390a4c

Please sign in to comment.