-
Notifications
You must be signed in to change notification settings - Fork 41
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
[WIP] TypeClassResolutionTest for code snippets #57
Conversation
d40d051
to
806d7d2
Compare
@i-walker The heavy test base class |
# Conflicts: # testing-plugin/build.gradle
Thanks to both of you I will do a complete cleanUp and close the PR #53 |
# Conflicts: # testing-plugin/src/main/kotlin/arrow/meta/plugin/testing/CompilationAssertions.kt
val actualStatus: CompilationStatus, | ||
val log: String, | ||
val actualGeneratedFilePath: Path, | ||
val classesDirectory: File |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other directories and this is only the classes directory. For instance:
Paths.get(internalResult.outputDirectory.parent, "sources", "$DEFAULT_FILENAME.meta")
is jumping to the parent in order to access to sources. I think if we talk about classes directory, the source code communicates better.
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, what's changing here?
idea-plugin/src/test/kotlin/arrow/meta/ide/plugins/typeclasses/TypeResolutionTest.kt
Outdated
Show resolved
Hide resolved
@@ -10,14 +10,14 @@ import java.nio.file.Paths | |||
|
|||
private const val DEFAULT_FILENAME = "Example.kt" | |||
|
|||
internal data class CompilationResult( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change breaks the purpose of our testing library. I'm still trying to figure out what's the need but I'm thinking about 2 options:
- Thinking about an assertion and improving the testing library with that assertion.
- If it's only necessary to get the classes after the compilation, it seems that's not a goal of our testing library. We could add a function for compiling sources with the use of the compiler plugin in this module.
Our testing library is a step further from kotilin-compiler-testing. It doesn't show the result of the compilation to the user and does all the assertions according to the compilation data. If we need to manage the result of a compilation, for instance, get the directory of classes, it's not necessary our testing library. kotlin-compiler-testing can be used directlty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose that we focus on implementing this deliverable and negotiate with @raulraja what the best approach is. I do understand that you value the set of principles in testing-plugin
and I am certain there is a solution, which works for everyone.
Though for now, we need the time to iterate and fulfill our deadlines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@i-walker CompilationResult should remain internal unless you have a valid reason to make it public as the compiler tests are hiddng that behind asserts. Why do you need this method public? We are attempting to make the DSL cohesive with the rest of the APIs and both compiler and ide should share the design but this model was not intended to be part of the public API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to provide typeclass resolution tests we need the metadata, that the compiler-plugin produces. Within an IdeEnvironment we can only reference and create files, but without the engine of a compiler. Naturally, we would lean on something which we already use in Meta
We are in need of a function in testing-plugin
, where we can utilize a function (Source) -> (List<Config>) -> CompilationResult
or something isomorphic.
We're only proposing a collaboration between testing-plugin
and idea-plugin
, unless we're dropping tests for SyntheticResolution
. Consequently, we can not guarantee issues that the current scala-idea-plugin
has e.g.: redlines on Syntheticmembers and other unresolved references we add to the language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of metadata is that and how is it used? We can just add a new assert for that that gives you that metadata or analyzes.it in the interpreter of the test DSL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need .class
files and everything generated in the build folder.
We also need the actual files and directories, no interpretation or assertion.
Thus, the editor in the TestEnvironment is able to index generated members and screens out unresolved ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The underlying library has the property `outputDirectory, which includes some of the files we need. But we're not able to compile it with the current settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We grab the metadata and copy it into the buildFolder of each IdeTestEnviroment. After that, we can initiate indexing as it would happen if a user would start a gradle build task in Idea.
This looks good. We can now work on it 😄 |
idea-plugin/src/main/kotlin/arrow/meta/ide/testing/env/types/HeavyTestSyntax.kt
Outdated
Show resolved
Hide resolved
idea-plugin/src/main/kotlin/arrow/meta/ide/testing/env/types/HeavyTestSyntax.kt
Outdated
Show resolved
Hide resolved
idea-plugin/src/main/kotlin/arrow/meta/ide/testing/env/types/HeavyTestSyntax.kt
Outdated
Show resolved
Hide resolved
…ers of a single module only
See proposal in #65 |
@i-walker I fixed a few of the classloader issues. The problem is, that the JetBrains plugin already comes with As a side-effect, this brings down the side of There's one (last?) exception which I can't solve: I've made sure that the Kotlin plugin is bundling 1.3.50 by checking
|
@rachelcarmena Thanks! Probably only partially. Most of the dependencies excluded from testing-plugin are inherited from kotlin-compile-testing. I‘d be glad to replace testing-plugin, though! |
Simplify kotlin compiler integration with the proposal of @rachelcarmena
# Conflicts: # testing-plugin/build.gradle
…y kotlin-compiler-client-embeddable is.
I've merged #65. Now there are a few more remaining problems.
Exception:
|
@jansorg, we've just merged a fix on master. There was an error when shadowing |
@rachelcarmena Thanks! I've merge master. It's still broken. |
as far as I can tell, this will be superseded by #252 . Heavy tests won't be needed anymore when that wip PR is finished and merged. |
@i-walker cc @raulraja
This PR adds a very early version of a "heavy" test to test type resolution. A heavy test is a test which configures a full IntelliJ runtime environment and a project on disk before the test methods are run. This is more heavyweight than the light tests we're usually running in
idea-plugin
.This is not ready to merge
arrow.meta.ide.plugins.typeclasses.TypeResolutionTest
is a wip test to demonstrate how the heavy testing is done.This needs to happen as soon as it's working:
What's broken
TypeClassResolutionTest
currently produces an exception about a mismatch of classorg.jetbrains.kotlin.idea.KotlinFileType
. Both the Kotlin IDE plugin and dependencykotlin-compiler-embedded
contain this class.