Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include other language's sourceSets in tests #35

Open
renatoathaydes opened this issue May 8, 2018 · 9 comments
Open

Include other language's sourceSets in tests #35

renatoathaydes opened this issue May 8, 2018 · 9 comments

Comments

@renatoathaydes
Copy link

Issue based on gradle/gradle#5303 (comment)

When trying to run Kotlin or Groovy tests, this error occurs:

> Task :test FAILED

example.MyGroovyTest > initializationError FAILED
    java.lang.ClassNotFoundException

The stack-trace is not helpful as it just shows it can't find the class when running tests... but as @oehme pointed out in the original issue, looks like this line is to blame: it should add the source directories of all test tasks, not only Java's test task.

@oehme
Copy link

oehme commented May 8, 2018

it should add the source directories of all test tasks, not only Java's test task.

Not quite. It should add all classes as module patches, not just the classes compiled from Java. It should use test.classesDirs instead of test.java.outputDir.

@renatoathaydes
Copy link
Author

testClassesDirs returns a FileCollection with only the root directories, but it seems we need each and every file path. How do you get that (hoping there's a way without manually walking the file tree)?

@renatoathaydes
Copy link
Author

Oh well, I found out that this seems to give every class file:

"$moduleName=" + test.getTestClassesDirs().asFileTree.asPath

But the tests still do not run :( any ideas?

@oehme
Copy link

oehme commented May 8, 2018

You don't need the files, the root directories are just fine. Make sure you got the syntax right. I haven't checked what separator --patch-module expects.

@renatoathaydes
Copy link
Author

@oehme
Using all files, or just the directories, it still doesn't run any tests.

The syntax is correct. I printed the option:

Using --patch-module com.athaydes.rawhttp.core=/Users/renato/programming/projects/rawhttp/rawhttp-core/build/classes/java/test:/Users/renato/programming/projects/rawhttp/rawhttp-core/build/classes/kotlin/test

The kotlin/test dir contains all the test class files, as expected... it just won't run the tests.

What else can control what tests should run (the names are correct as they worked on Java 8)???

@renatoathaydes
Copy link
Author

Looks like by adding a single Java test to the project, things go further...

But Gradle is just totally broken, now I get some other random error:

> Task :rawhttp-core:test FAILED
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
java.lang.ClassCastException: slf4j.api@1.7.13/org.slf4j.helpers.NOPLoggerFactory cannot be cast to org.gradle.internal.logging.slf4j.OutputEventListenerBackedLoggerContext
        at org.gradle.internal.logging.slf4j.Slf4jLoggingConfigurer.configure(Slf4jLoggingConfigurer.java:42)
        at org.gradle.internal.logging.config.LoggingSystemAdapter.startCapture(LoggingSystemAdapter.java:54)
        at org.gradle.internal.logging.services.DefaultLoggingManager$StartableLoggingSystem.start(DefaultLoggingManager.java:324)
        at org.gradle.internal.logging.services.DefaultLoggingManager.start(DefaultLoggingManager.java:78)
        at org.gradle.internal.logging.services.DefaultLoggingManager.start(DefaultLoggingManager.java:37)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:83)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:64)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:62)
<=============> 100% EXECUTING [1m 57s]ternal.worker.GradleWorkerMain.main(GradleWorkerMain.java:67)

It just hangs there forever after that.

@oehme
Copy link

oehme commented May 8, 2018

Having SLF4j on the module path will break Gradle's test executors. That's a known bug.

I don't think adding a Java test fixed anything, it's just trying to run the Java class first. You'll still get the same error for the Groovy class later.

I don't know why it won't load that class, I'm afraid you'll have to debug that issue with gradle test --debug-jvm.

@renatoathaydes
Copy link
Author

Can you get Gradle to run any tests in Groovy or Kotlin?? I created a hello-world project to try and it just doesn't work no matter what I do.

@oehme
Copy link

oehme commented May 9, 2018

I don't have time to look into this atm, please try using a debugger to understand why the JVM won't load the class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants