Skip to content

Commit 0b256e1

Browse files
committed
Lots of logging, lots of commented code, but continuous testing and gradle maybe both work?
1 parent 53c8260 commit 0b256e1

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ public Runnable prepare() {
158158
LogCapturingOutputFilter logHandler = new LogCapturingOutputFilter(testApplication, true, true,
159159
TestSupport.instance()
160160
.get()::isDisplayTestOutput);
161-
// TODO do we want to do this setting of the TCCL? I think it just makes problems?
162-
Thread.currentThread().setContextClassLoader(tcl);
163161

162+
System.out.println("HOLLY TCCL watch 1 " + Thread.currentThread().getContextClassLoader());
164163
Set<UniqueId> allDiscoveredIds = new HashSet<>();
165164
Set<UniqueId> dynamicIds = new HashSet<>();
166165
DiscoveryResult quarkusTestClasses = discoverTestClasses();
166+
System.out.println("HOLLY TCCL watch 2 " + Thread.currentThread().getContextClassLoader());
167167

168168
Launcher launcher = LauncherFactory.create(LauncherConfig.builder().build());
169169
LauncherDiscoveryRequestBuilder launchBuilder = LauncherDiscoveryRequestBuilder.request()
@@ -211,7 +211,12 @@ public FilterResult apply(TestDescriptor testDescriptor) {
211211

212212
LauncherDiscoveryRequest request = launchBuilder
213213
.build();
214+
System.out.println("HOLLY TCCL watch 2a " + Thread.currentThread().getContextClassLoader());
215+
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
214216
TestPlan testPlan = launcher.discover(request);
217+
System.out.println("HOLLY TCCL watch 3 " + Thread.currentThread().getContextClassLoader());
218+
Thread.currentThread().setContextClassLoader(deploymentClassLoader);
219+
System.out.println("HOLLY TCCL watch 4 " + Thread.currentThread().getContextClassLoader());
215220
long toRun = testPlan.countTestIdentifiers(TestIdentifier::isTest);
216221
for (TestRunListener listener : listeners) {
217222
listener.runStarted(toRun);

test-framework/junit5-config/src/main/java/io/quarkus/test/config/ConfigLauncherSession.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ public void launcherSessionOpened(final LauncherSession session) {
2121
// before the formal loading phase. To make that work, the TCCL has to be
2222
// set to the FCL by the time this is called, even though we want config to live on the app classloader
2323
ClassLoader old = Thread.currentThread().getContextClassLoader();
24-
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
24+
System.out.println("HOLLY creating config launcher, I am " + this.getClass().getClassLoader());
25+
System.out.println("HOLLY creating config launcher, TCCL is " + Thread.currentThread().getContextClassLoader());
26+
if (old.toString().contains("Facade")) {
27+
Thread.currentThread()
28+
.setContextClassLoader(ClassLoader.getSystemClassLoader());
29+
}
30+
System.out.println("HOLLY creating config launcher, second TCCL is " + Thread.currentThread().getContextClassLoader());
2531
try {
2632
TestConfigProviderResolver resolver = new TestConfigProviderResolver();
2733
ConfigProviderResolver.setInstance(resolver);

test-framework/junit5-config/src/main/java/io/quarkus/test/config/TestConfigProviderResolver.java

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.quarkus.runtime.configuration.ConfigUtils;
1313
import io.smallrye.config.SmallRyeConfig;
1414
import io.smallrye.config.SmallRyeConfigBuilder;
15+
import io.smallrye.config.SmallRyeConfigBuilderCustomizer;
1516
import io.smallrye.config.SmallRyeConfigProviderResolver;
1617

1718
/**
@@ -53,6 +54,11 @@ public Config getConfig(final LaunchMode mode) {
5354
SmallRyeConfig config = configs.computeIfAbsent(mode, new Function<LaunchMode, SmallRyeConfig>() {
5455
@Override
5556
public SmallRyeConfig apply(final LaunchMode launchMode) {
57+
System.out.println((("HOLLY wull build, iam " + this.getClass()
58+
.getClassLoader() + " tccl"
59+
+ Thread.currentThread()
60+
.getContextClassLoader()
61+
+ " condi" + SmallRyeConfigBuilderCustomizer.class.getClassLoader())));
5662
return ConfigUtils.configBuilder(false, true, mode)
5763
.withProfile(mode.getDefaultProfile())
5864
.withMapping(TestConfig.class, "quarkus.test")

test-framework/junit5/src/main/java/io/quarkus/test/junit/launcher/CustomLauncherInterceptor.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ public <T> T intercept(Invocation<T> invocation) {
3535
// and causes some problems with config being set on the wrong classloader.
3636

3737
// It's unclear if it's better to special-case gradle to reduce the impact, or be generic to make things consistent
38-
if (System.getProperty("org.gradle.test.worker") != null) {
39-
// This gets called several times; some for creation of LauncherSessionListener instances registered via the ServiceLoader mechanism,
40-
// some for creation of Launcher instances, and some for calls to Launcher.discover(LauncherDiscoveryRequest), Launcher.execute(TestPlan, TestExecutionListener...), and Launcher.execute(LauncherDiscoveryRequest, TestExecutionListener...)
41-
// We only know why it was called *after* calling invocation.proceed, sadly
42-
// The Gradle classloading seems to happen immediately after the ConfigSessionListener is triggered, but before the next launch invocation
43-
adjustContextClassLoader();
44-
}
38+
// if (System.getProperty("org.gradle.test.worker") != null) {
39+
// This gets called several times; some for creation of LauncherSessionListener instances registered via the ServiceLoader mechanism,
40+
// some for creation of Launcher instances, and some for calls to Launcher.discover(LauncherDiscoveryRequest), Launcher.execute(TestPlan, TestExecutionListener...), and Launcher.execute(LauncherDiscoveryRequest, TestExecutionListener...)
41+
// We only know why it was called *after* calling invocation.proceed, sadly
42+
// The Gradle classloading seems to happen immediately after the ConfigSessionListener is triggered, but before the next launch invocation
43+
//adjustContextClassLoader();
44+
// }
4545

4646
return answer;
4747

0 commit comments

Comments
 (0)