Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
dmikurube committed Dec 13, 2023
1 parent f6bf7c1 commit 098cca7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,23 @@ public EmbulkJUnitPlatformTestFramework(final DefaultTestFilter filter) {

@Override
public WorkerTestClassProcessorFactory getProcessorFactory() {
final WorkerTestClassProcessorFactory factory;

factory = super.getProcessorFactory();

/*
return super.getProcessorFactory();
*/
if (!JavaVersion.current().isJava8Compatible()) {
throw new UnsupportedJavaRuntimeException("Running JUnit Platform requires Java 8+, please configure your test java executable with Java 8 or higher.");
}
return new EmbulkJUnitPlatformTestClassProcessorFactory(new JUnitPlatformSpec(this.getOptions(),
factory = new EmbulkJUnitPlatformTestClassProcessorFactory(new JUnitPlatformSpec(this.getOptions(),
filter2.getIncludePatterns(), filter2.getExcludePatterns(),
filter2.getCommandLineIncludePatterns()));
*/

System.out.println(factory.getClass());
System.out.println(factory.toString());

return factory;
}

static class EmbulkJUnitPlatformTestClassProcessorFactory implements WorkerTestClassProcessorFactory, Serializable {
public static class EmbulkJUnitPlatformTestClassProcessorFactory implements WorkerTestClassProcessorFactory, Serializable {
private final JUnitPlatformSpec spec;

EmbulkJUnitPlatformTestClassProcessorFactory(JUnitPlatformSpec spec) {
Expand All @@ -83,8 +88,8 @@ public TestClassProcessor create(ServiceRegistry serviceRegistry) {
IdGenerator<?> idGenerator = serviceRegistry.get(IdGenerator.class);
Clock clock = serviceRegistry.get(Clock.class);
ActorFactory actorFactory = serviceRegistry.get(ActorFactory.class);
// Class<?> clazz = getClass().getClassLoader().loadClass("org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor");
Class<?> clazz = getClass().getClassLoader().loadClass("org.embulk.gradle.embulk_plugins.EmbulkJUnitPlatformTestClassProcessor");
Class<?> clazz = getClass().getClassLoader().loadClass("org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor");
// Class<?> clazz = getClass().getClassLoader().loadClass("org.embulk.gradle.embulk_plugins.EmbulkJUnitPlatformTestClassProcessor");

Constructor<?> constructor = clazz.getConstructor(JUnitPlatformSpec.class, IdGenerator.class, ActorFactory.class, Clock.class);
return (TestClassProcessor) constructor.newInstance(spec, idGenerator, actorFactory, clock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void useEmbulkJUnitPlatform() {
method.setAccessible(true);
System.out.println("!");
method.invoke(this, new EmbulkJUnitPlatformTestFramework((DefaultTestFilter) this.getFilter()));
// method.invoke(this, new JUnitPlatformTestFramework((DefaultTestFilter) this.getFilter()));
System.out.println("?");
} catch (final IllegalAccessException ex) {
throw new GradleException("Unexpected failure", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.api.io.CleanupMode;

/**
* Tests a simple case in the Embulk plugins Gradle plugin.
Expand All @@ -40,7 +41,7 @@
class TestSimple {
@Test
@DisabledOnOs(OS.WINDOWS)
public void test(@TempDir Path tempDir) throws IOException {
public void test(@TempDir(cleanup = CleanupMode.ON_SUCCESS) Path tempDir) throws IOException {
final Path projectDir = prepareProjectDir(tempDir, "testSimple");
runGradle(projectDir, "compileJava", "generatePomFileForEmbulkPluginMavenPublication");

Expand Down
10 changes: 6 additions & 4 deletions src/test/resources/testSimple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

embulkPluginTest {
useEmbulkJUnitPlatform()
}

dependencies {
compileOnly "org.embulk:embulk-api:0.10.35"
compileOnly "org.embulk:embulk-spi:0.10.35"
Expand All @@ -38,6 +34,8 @@ dependencies {
exclude group: "*", module: "*"
}
implementation "com.github.jnr:jffi:1.2.23:native"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.1"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.1"
}

embulkPlugin {
Expand All @@ -46,6 +44,10 @@ embulkPlugin {
type = "simple"
}

embulkPluginTest {
useEmbulkJUnitPlatform()
}

publishing {
publications {
embulkPluginMaven(MavenPublication) {
Expand Down

0 comments on commit 098cca7

Please sign in to comment.