Skip to content

fix(#4718): add transpileTests option#4776

Merged
yegor256 merged 1 commit into
objectionary:masterfrom
volodya-lombrozo:4718-tests-in-it-short
Dec 26, 2025
Merged

fix(#4718): add transpileTests option#4776
yegor256 merged 1 commit into
objectionary:masterfrom
volodya-lombrozo:4718-tests-in-it-short

Conversation

@volodya-lombrozo

@volodya-lombrozo volodya-lombrozo commented Dec 25, 2025

Copy link
Copy Markdown
Member

The new 'transpileTests' option prevents EO tests from being included with the eo-runtime library.

Fixes #4718

Summary by CodeRabbit

  • New Features

    • Added a build parameter to control transpiling of test sources (transpileTests, defaults to true).
  • Refactor

    • Simplified test-runner configuration and replaced an inlined plugin block with a minimal surefire setup (no-fail if no tests).
    • Removed an explicit JUnit API test dependency from the integration test build.
  • Tests

    • Updated tests to respect the new transpile-tests setting.
    • Added a TODO note in integration tests clarifying current setup.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 25, 2025 17:39
@coderabbitai

coderabbitai Bot commented Dec 25, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Replaces the test-transpilation toggle with a new Maven parameter eo.transpileTests, threads it from MjTranspile into JavaPlaced (now a BiProc<Xnav,Boolean>), updates tests and integration POM (removed JUnit API, adjusted Surefire and set transpileTests = false).

Changes

Cohort / File(s) Change Summary
Integration test POM
eo-integration-tests/src/it/fibonacci/pom.xml
Removed org.junit.jupiter:junit-jupiter-api test dependency; added standalone maven-surefire-plugin; set eo-maven-plugin config <transpileTests>false</transpileTests>.
MjTranspile (plugin entrypoint)
eo-maven-plugin/src/main/java/org/eolang/maven/MjTranspile.java
Replaced addTestSourcesRoot with transpileTests (default true), updated Maven parameter to eo.transpileTests, and callsite changed from .exec(clazz) to .exec(clazz, this.transpileTests).
JavaPlaced (placement logic)
eo-maven-plugin/src/main/java/org/eolang/maven/JavaPlaced.java
Implementation changed from Proc<Xnav>BiProc<Xnav, Boolean>; exec now exec(Xnav, Boolean); test placement gated by if (tests && JavaPlaced.testsPresent(clazz)).
Plugin unit tests
eo-maven-plugin/src/test/java/org/eolang/maven/JavaPlacedTest.java
Updated exec(...) call sites to pass the additional boolean parameter (e.g., false, true).
Integration test notes
eo-maven-plugin/src/test/java/org/eolang/maven/MjTranspileIT.java
Added multi-line @todo Javadoc documenting dependency on local plugin artifact and suggested test relocation; minor formatting change.

Sequence Diagram(s)

sequenceDiagram
  participant Maven as Maven build
  participant Mj as MjTranspile (plugin)
  participant JP as JavaPlaced
  rect rgba(0,128,96,0.08) 
    Note over Maven,Mj: Plugin execution with parameter
    Maven->>Mj: invoke plugin (eo.transpileTests = false|true)
    Mj->>JP: exec(clazz, transpileTests)
  end
  alt transpileTests == true
    rect rgba(0,128,255,0.06)
      JP->>JP: if JavaPlaced.testsPresent(clazz) then place tests
    end
  else transpileTests == false
    rect rgba(255,128,0,0.06)
      JP-->>JP: skip placing tests
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • yegor256
  • maxonfjvipon

Poem

"A rabbit scurried through the build, 🐇
Flipped a switch so tests stay still,
BiProc carries truth along,
Transpile flag hums a gentle song,
Hooray — the plugin's running chill!"

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Out of Scope Changes check ❓ Inconclusive The PR includes documentation changes (JavaDoc in MjTranspileIT) and pom.xml modifications that appear tangential; unclear if all changes directly align with the core objective of preventing test distribution. Verify that all pom.xml changes and JavaDoc additions directly support preventing EO tests from being distributed with eo-runtime library.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: introducing a new transpileTests option.
Linked Issues check ✅ Passed The PR implements the required changes to address issue #4718: introduces transpileTests option to prevent test inclusion, updates pom.xml configuration, and modifies JavaPlaced and MjTranspile classes accordingly.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Dec 25, 2025

Copy link
Copy Markdown
Contributor

🚀 Performance Analysis

All benchmarks are within the acceptable range. No critical degradation detected (threshold is 100%). Please refer to the detailed report for more information.

Click to see the detailed report
Test Base Score PR Score Change % Change Unit Mode
benchmarks.XmirBench.xmirToEO 160.676 151.693 -8.983 -5.59% ms/op Average Time

✅ Performance gain: benchmarks.XmirBench.xmirToEO is faster by 8.983 ms/op (5.59%)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a new transpileTests configuration option for the EO Maven plugin to control whether test files are transpiled alongside production code. The change addresses issue #4718, which identified that EO tests were being improperly distributed with the eo-runtime library, causing unexpected behavior when running integration tests.

Key Changes:

  • Added transpileTests boolean parameter to MjTranspile (defaults to true for backward compatibility)
  • Updated JavaPlaced to conditionally process test files based on a boolean flag
  • Modified integration test configuration to disable test transpilation where unnecessary

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
eo-maven-plugin/src/main/java/org/eolang/maven/MjTranspile.java Introduced the transpileTests parameter and passed it to JavaPlaced for controlling test transpilation
eo-maven-plugin/src/main/java/org/eolang/maven/JavaPlaced.java Changed from Proc<Xnav> to BiProc<Xnav, Boolean> to accept the test transpilation flag
eo-maven-plugin/src/test/java/org/eolang/maven/JavaPlacedTest.java Updated test cases to pass the new boolean parameter when calling JavaPlaced.exec()
eo-maven-plugin/src/test/java/org/eolang/maven/MjTranspileIT.java Added TODO comment documenting test dependency issues
eo-integration-tests/src/it/fibonacci/pom.xml Configured transpileTests=false and removed workarounds for unwanted test execution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread eo-maven-plugin/src/test/java/org/eolang/maven/MjTranspileIT.java
Comment on lines +112 to +115
* Whether to transpile tests.
*
* @checkstyle MemberNameCheck (7 lines)
*/

Copilot AI Dec 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JavaDoc comment has inconsistent indentation. The first line of the comment starts with "* " while subsequent lines start with " * ". This should be consistent with surrounding code patterns where all lines in a JavaDoc comment use the same indentation pattern (either all with "* " or adjust spacing).

Suggested change
* Whether to transpile tests.
*
* @checkstyle MemberNameCheck (7 lines)
*/
* Whether to transpile tests.
*
* @checkstyle MemberNameCheck (7 lines)
*/

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yegor256 indeed. Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
eo-maven-plugin/src/main/java/org/eolang/maven/MjTranspile.java (1)

131-145: Potential inconsistency: test-compile-source-root added regardless of transpileTests.

When addSourcesRoot is true, the code adds generated-test-sources to Maven's test-compile-source-root (lines 137-144) regardless of the transpileTests setting. If transpileTests is false, no test Java files will be generated, but Maven will still be configured to compile from that directory. This could cause confusion or build warnings.

Consider gating the test-compile-source-root addition on the transpileTests flag:

🔎 Suggested fix to align test source root with transpileTests
         if (this.addSourcesRoot) {
             this.project.addCompileSourceRoot(this.generatedDir.getAbsolutePath());
             Logger.info(
                 this, "The directory added to Maven 'compile-source-root': %[file]s",
                 this.generatedDir
             );
+            if (this.transpileTests) {
                 final String gtests = this.generatedDir.toPath().getParent().resolve(
                     "generated-test-sources"
                 ).toAbsolutePath().toString();
                 this.project.addTestCompileSourceRoot(gtests);
                 Logger.info(
                     this, "The directory added to Maven 'test-compile-source-root': %[file]s",
                     gtests
                 );
+            }
         }
🧹 Nitpick comments (1)
eo-maven-plugin/src/main/java/org/eolang/maven/JavaPlaced.java (1)

48-56: Consider renaming parameter for clarity.

The parameter name tests is somewhat generic. Using transpileTests would better align with the configuration parameter name in MjTranspile and make the intent clearer at call sites.

🔎 Clearer parameter naming
-    public void exec(final Xnav clazz, final Boolean tests) throws IOException {
+    public void exec(final Xnav clazz, final Boolean transpileTests) throws IOException {
         if (clazz.element("java").text().isPresent()) {
             this.footprint.apply(Paths.get(""), this.target);
         }
-        if (tests && JavaPlaced.testsPresent(clazz)) {
+        if (transpileTests && JavaPlaced.testsPresent(clazz)) {
             this.placeJavaTests(clazz);
         }
     }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8605fe6 and 8c6c864.

📒 Files selected for processing (5)
  • eo-integration-tests/src/it/fibonacci/pom.xml
  • eo-maven-plugin/src/main/java/org/eolang/maven/JavaPlaced.java
  • eo-maven-plugin/src/main/java/org/eolang/maven/MjTranspile.java
  • eo-maven-plugin/src/test/java/org/eolang/maven/JavaPlacedTest.java
  • eo-maven-plugin/src/test/java/org/eolang/maven/MjTranspileIT.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Agent
  • GitHub Check: CodeQL analysis (java)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: integration
  • GitHub Check: qulice
  • GitHub Check: pr-size
  • GitHub Check: mvn (ubuntu-24.04, 23)
  • GitHub Check: mvn (ubuntu-24.04, 17)
  • GitHub Check: mvn (windows-2022, 23)
  • GitHub Check: trufflehog
  • GitHub Check: mvn (macos-15, 23)
  • GitHub Check: benchmark
  • GitHub Check: ort
  • GitHub Check: snippets
🔇 Additional comments (8)
eo-maven-plugin/src/test/java/org/eolang/maven/JavaPlacedTest.java (2)

28-47: LGTM! Test correctly updated for new API.

The test properly exercises the updated exec method signature with the false parameter, verifying Java code placement without test transpilation.


49-77: LGTM! Test correctly validates test transpilation.

The test properly exercises the updated exec method with the true parameter, verifying that Java tests are placed in the generated-test-sources directory when test transpilation is enabled.

eo-maven-plugin/src/test/java/org/eolang/maven/MjTranspileIT.java (1)

24-30: Documentation added for test dependency concern.

The TODO comment documents that these integration tests depend on a previously installed version of eo-maven-plugin rather than the current build, which could lead to testing stale behavior.

eo-integration-tests/src/it/fibonacci/pom.xml (2)

31-51: Configuration correctly disables test transpilation.

The transpileTests setting is appropriately set to false for this example module, which aligns with the PR objective to prevent EO tests from being distributed with the runtime library.


52-57: LGTM! Surefire configuration aligns with disabled test transpilation.

The failIfNoTests setting prevents build failures when no test classes are present, which is appropriate given that transpileTests is set to false.

eo-maven-plugin/src/main/java/org/eolang/maven/MjTranspile.java (2)

111-118: LGTM! Parameter properly configured with backward-compatible default.

The transpileTests parameter is correctly configured with Maven annotations and defaults to true, maintaining backward compatibility for existing builds that don't specify this parameter.


235-249: LGTM! transpileTests flag correctly passed to JavaPlaced.

The exec method invocation at line 249 correctly passes the transpileTests configuration to JavaPlaced, properly threading the flag through to control test placement logic.

eo-maven-plugin/src/main/java/org/eolang/maven/JavaPlaced.java (1)

13-19: This suggestion is not feasible. Java generics do not support primitive types as type parameters — only reference types are allowed due to how generics are implemented with type erasure. BiProc<Xnav, boolean> is syntactically invalid and cannot compile.

The current implementation using BiProc<Xnav, Boolean> is correct and the idiomatic approach in Java. The Boolean wrapper class with autoboxing/unboxing is standard practice for generic type parameters, and any theoretical NPE risk from a null Boolean parameter is typically managed at the call site and is not a common concern in practice.

Likely an incorrect or invalid review comment.

@volodya-lombrozo

Copy link
Copy Markdown
Member Author

@yegor256 could you have a look, please?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
eo-integration-tests/src/it/fibonacci/pom.xml (1)

52-57: Appropriate configuration for integration test without transpiled tests.

The <failIfNoTests>false</failIfNoTests> configuration is appropriate since transpileTests=false means test classes may not be generated. This prevents build failures when no tests are present.

Consider documenting why tests are disabled for this integration test, since the AI summary mentions a "lengthy comment" was removed from the previous Surefire configuration. A brief comment explaining that this is an integration test for the Fibonacci example (not a test suite) would improve maintainability.

📝 Optional documentation improvement
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
+         <!-- No unit tests in this integration example project -->
          <failIfNoTests>false</failIfNoTests>
        </configuration>
      </plugin>
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b50aa5 and 36025f7.

📒 Files selected for processing (5)
  • eo-integration-tests/src/it/fibonacci/pom.xml
  • eo-maven-plugin/src/main/java/org/eolang/maven/JavaPlaced.java
  • eo-maven-plugin/src/main/java/org/eolang/maven/MjTranspile.java
  • eo-maven-plugin/src/test/java/org/eolang/maven/JavaPlacedTest.java
  • eo-maven-plugin/src/test/java/org/eolang/maven/MjTranspileIT.java
✅ Files skipped from review due to trivial changes (1)
  • eo-maven-plugin/src/test/java/org/eolang/maven/MjTranspileIT.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • eo-maven-plugin/src/main/java/org/eolang/maven/JavaPlaced.java
  • eo-maven-plugin/src/test/java/org/eolang/maven/JavaPlacedTest.java
  • eo-maven-plugin/src/main/java/org/eolang/maven/MjTranspile.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: mvn (windows-2022, 23)
🔇 Additional comments (1)
eo-integration-tests/src/it/fibonacci/pom.xml (1)

46-46: Confirm transpileTests=false prevents test transpilation as intended.

The transpileTests parameter is properly implemented in eo-maven-plugin (line 116-118 of MjTranspile.java) with a default value of true. Setting it to false in this pom.xml will prevent test transpilation during the build, achieving the PR objective to exclude tests from the distribution.

@volodya-lombrozo

Copy link
Copy Markdown
Member Author

@yegor256 could you have a look one more time, please?

@yegor256
yegor256 merged commit 98f836b into objectionary:master Dec 26, 2025
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EO tests improperly distributed with puzzle 4702-c15b070e

3 participants