Thread
#arrow-meta
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    Hi! I migrated my work-in-progress PR over to
    arrow-meta
    , made sure that the gradle was synced to itself, set the JDK to 1.8, ran the
    ./gradlew
    tasks in the CLI, and tried to run the tests from the IDE. Unfortunately, I'm getting this:
    jereksel

    jereksel

    2 years ago
    I also had similar test errors - they are gone when
    Run tests using
    is set to
    Gradle (Default)
    - in Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    Okay! Imma try that
    There's some improvement, but for some reason I'm unable to run the stack trace here
    Are there any quirks with this task?
    jereksel

    jereksel

    2 years ago
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    oh yeah - so sorry this is something I'm writing out right now - at the moment, I'm just trying to compile some source code with testing and do an IrDump to see what kind of trees I'm working with - this is something that may not be a feature until after Kotlinconf, but the linked issue is with it!
    it could just be the way I set up my project
    jereksel

    jereksel

    2 years ago
    CI does not pass: https://github.com/arrow-kt/arrow-meta/pull/11/checks?check_run_id=275303006 It's certainly not issue with your setup
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    Right, it would have failed for the very reason I was talking about
    This is a PR marked "WIP", so it's not anywhere near done
    Rachel

    Rachel

    2 years ago
    Hi @amanda.hinchman-dominguez, I couldn't see the exceptions in your screenshot before
    FAILURE: Build failed with an exception
    so I downloaded your branch and I tried to run the tests.
    I got these exceptions:
    e: (...) /EqOperatorTest.kt: (3, 12): Unresolved reference: tschuchort
    e: (...) /EqOperatorTest.kt: (4, 12): Unresolved reference: tschuchort
    e: (...) /EqOperatorTest.kt: (48, 5): Unresolved reference: KotlinCompilation
    e: (...) /EqOperatorTest.kt: (49, 7): Unresolved reference: sources
    e: (...) /EqOperatorTest.kt: (49, 24): Unresolved reference: SourceFile
    e: (...) /EqOperatorTest.kt: (50, 7): Unresolved reference: classpaths
    e: (...) /EqOperatorTest.kt: (51, 7): Unresolved reference: pluginClasspaths
    They come from:
    import com.tschuchort.compiletesting.KotlinCompilation
    import com.tschuchort.compiletesting.SourceFile
    EqOperatorTest
    is including these dependencies which are being used in
    testing-plugin
    .
    testing-plugin/build.gradle
    is ready to include them with
    implementation "com.github.arrow-kt:kotlin-compile-testing:$kotlin_compile_testing"
    .
    I imagine that
    compileSourceCode
    and
    classpathOf
    were included temporarily in
    EqOperatorTest
    to run just a compilation without any other assertions.
    In that case, to run those tests in
    EqOperatorTest
    , it would be necessary to include:
    testImplementation "com.github.arrow-kt:kotlin-compile-testing:1.2.3-SNAPSHOT"
    in
    compiler-plugin/build.gradle
    .
    After doing that, I got an error with:
    classpaths = listOf(classpathOf("arrow-meta-prototype:rr-meta-prototype-integration-SNAPSHOT"))
    because that dependency doesn't exist.
    I suppose you were looking for a dependency to use
    extension
    annotation.
    That annotation exists in
    arrow-annotations
    so that line would be:
    classpaths = listOf(classpathOf("arrow-annotations:rr-meta-prototype-integration-SNAPSHOT"))
    Tests will be green with those changes ✔️
    However, compilation is failing.
    testing-plugin
    isn't being used here, only
    compileSourceCode
    and
    classpathOf
    which are in the same test class, so there aren't checks to inspect the result of the compilation.
    In
    EqOperatorTest
    , it`s necessary to look at the log:
    e: /tmp/Kotlin-Compilation3830289531150025141/sources/Example.kt: (1, 1): Expecting a top level declaration
    e: /tmp/Kotlin-Compilation3830289531150025141/sources/Example.kt: (2, 1): Expecting a top level declaration
    e: /tmp/Kotlin-Compilation3830289531150025141/sources/Example.kt: (2, 4): Unresolved reference: extension
    and for the second test:
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (1, 1): Expecting a top level declaration
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (2, 1): Expecting a top level declaration
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (3, 1): Expecting a top level declaration
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (4, 1): Expecting a top level declaration
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (5, 1): Expecting a top level declaration
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (6, 1): Expecting an element
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (7, 1): Expecting an element
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (8, 1): Expecting a top level declaration
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (9, 1): Expecting a top level declaration
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (4, 4): Unresolved reference: extension
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (5, 16): Unresolved reference: Eq
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (5, 28): Unresolved reference: eq
    e: /tmp/Kotlin-Compilation1071656820347319429/sources/Example.kt: (6, 8): Unresolved reference: eqv
    If you look at those
    Example.kt
    files, you'll see the source code with
    |
    .
    It's necessary to remove
    |
    from code snippets (it's already done in
    testing-plugin
    ).
    It would be necessary to execute trimMargin:
    compileSourceCode(EQ_FUNCTION.trimMargin())
    
    ...
    
    compileSourceCode(EQ_EXTENSION.trimMargin())
    It's also necessary to include the import for
    extension
    annotation at the beginning of each snippet:
    | import arrow.extension
    After that, there are other compilation errors that can be seen at log.
    I hope these steps are useful for you to continue.
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    Yes, you are correct - I am just running some tests for an irTreeDump to see what I'm working with - no actual tests are being written at the moment.
    This is a really interesting insight! I was trying to mess with the compile configurations for the classpaths but couldn't understand how or why it worked.
    So what you're saying is that I have to set Kotlin configurations according to the appropriate plugin the test resides in and add the snapshot, is that correct? i.e.
    com.github.arrow-kt:kotlin-compile-testing:1.2.3-SNAPSHOT
    I'm taking some time to start with some of this again (and prepare notes about what I've learned so far today) - thank you so much for the pointer!
    Rachel

    Rachel

    2 years ago
    Right, that would be a necessary change and the rest of the changes:
    classpaths = listOf(classpathOf("arrow-annotations:rr-meta-prototype-integration-SNAPSHOT"))
    instead of:
    classpaths = listOf(classpathOf("arrow-meta-prototype:rr-meta-prototype-integration-SNAPSHOT"))
    Include trimMargin:
    compileSourceCode(EQ_FUNCTION.trimMargin())
    
    ...
    
    compileSourceCode(EQ_EXTENSION.trimMargin())
    After that, there are other compilation errors that can be seen at log.
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    Thanks, I'll try your formatting suggestions. As for everything else, I was getting the same results with your configurations as well, which is why I wanted to pull it out and see if the behavior is still the same
    Why do you have to remove the
    |
    from the comments for compiling source code?
    Rachel

    Rachel

    2 years ago
    Because they aren't expected. Each code snippet is thought as source code in a .kt file with its imports at the beginning if they are needed.
    By the way, good news Amanda! 🎉 If you rebase your branch with
    master
    branch, you'll get a new way to add the test you're looking for: just checking that it compiles
    For instance:
    val compilerPlugin = CompilerPlugin("Arrow Meta", listOf(Dependency("compiler-plugin")))
        val arrowAnnotations = Dependency("arrow-annotations:rr-meta-prototype-integration-SNAPSHOT")
    
      assertThis(CompilerTest(
          config = {
            addCompilerPlugins(compilerPlugin) + addDependencies(arrowAnnotations)
          },
          code = {
            """
            |
            | (code snippet)
            | 
            """.source
          },
          assert = {
            compiles
          }
        ))
    So it won't be necessary to check the log in your tests 🎉
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    I'm not actually checking that something compiles - I'm simply trying to get an irDump in debugging
    But I can pull it down anyway to make sure the code is updated