Skip to content

test(#4526): add tests for FpDefault#4739

Merged
yegor256 merged 1 commit into
objectionary:masterfrom
volodya-lombrozo:4526-caching-test
Dec 12, 2025
Merged

test(#4526): add tests for FpDefault#4739
yegor256 merged 1 commit into
objectionary:masterfrom
volodya-lombrozo:4526-caching-test

Conversation

@volodya-lombrozo
Copy link
Copy Markdown
Member

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

This PR refactors the FpDefaultTest class and add two disabled tests that show that caching doesn't work for eo-runtime:1.0-SNAPSHOT. In other words, when we develop eo-runtime we are required to rebuild all classes every time we want just to run a test (even without any changes).

Related to #4526

Summary by CodeRabbit

  • Tests

    • Refactored test helpers for static access and improved consistency.
    • Added tests validating cache behavior for non-standard versions; two of these tests are currently disabled.
    • Marked one flaky remote probe test as disabled with a TODO note.
  • Chores

    • Reorganized test utility structure and adjusted visibility for clearer maintenance.

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

Copilot AI review requested due to automatic review settings December 11, 2025 14:44
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 11, 2025

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

Converted two test helper methods to static, tightened visibility of an inner test helper class, updated all call sites, added two new disabled cache-related tests, and marked a flaky remote probe test as @Disabled.

Changes

Cohort / File(s) Summary
Test refactoring & disabled cache tests
eo-maven-plugin/src/test/java/org/eolang/maven/FpDefaultTest.java
Made footprintContent() and cacheContent() static and updated callers to static access. Changed inner Cache to private static final with package-private final fields and package-private path(). Replaced local defaultFootprint with FpDefaultTest.footprintContent(). Added two @Disabled tests (usesCacheEvenItSnapshot, cachesEvenItZeroVersion) and updated imports to include Disabled. Added @todo in class Javadoc.
Disable flaky remote probe test
eo-maven-plugin/src/test/java/org/eolang/maven/MjProbeTest.java
Imported JUnit Disabled and annotated findsProbesInOyRemote with @Disabled; added Javadoc noting flakiness and TODO.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Focus review on correctness of changed static calls and visibility adjustments in Cache.
  • Verify the two new disabled tests' assertions and the rationale for disabling.
  • Check MjProbeTest Javadoc and the disabled annotation placement.

Possibly related PRs

Suggested labels

core

Suggested reviewers

  • yegor256
  • maxonfjvipon

Poem

🐰 I hopped through tests and made things tight,
Static helpers now stand in plain sight.
A tiny Cache tucked neatly away,
Two dreams of caching wait for their day. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.81% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding tests for FpDefault with refactoring of the test class and two new disabled tests.
✨ 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9e45d8a and 64336ca.

📒 Files selected for processing (1)
  • eo-maven-plugin/src/test/java/org/eolang/maven/FpDefaultTest.java (19 hunks)
🔇 Additional comments (4)
eo-maven-plugin/src/test/java/org/eolang/maven/FpDefaultTest.java (4)

18-18: LGTM!

The import is correctly added to support the @Disabled annotation used in the new test methods.


25-32: LGTM!

The TODO comment provides clear context about the caching limitation and references the relevant issue and test cases.


351-360: LGTM!

Converting these helper methods to static is appropriate since they don't depend on instance state, and all call sites have been correctly updated throughout the file.


497-535: LGTM!

The refactoring improves the Cache helper class by making it static final (since it doesn't use outer class instance state), making fields final for immutability, and adjusting visibility to package-private which is appropriate for internal test scaffolding.

Comment thread eo-maven-plugin/src/test/java/org/eolang/maven/FpDefaultTest.java
Comment thread eo-maven-plugin/src/test/java/org/eolang/maven/FpDefaultTest.java
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 refactors the FpDefaultTest class by converting instance methods to static methods and adds two disabled tests that demonstrate a caching issue with SNAPSHOT and 0.0.0 versions in the EO runtime. The tests are disabled because they currently fail, highlighting that the caching mechanism doesn't work for development versions.

  • Refactored helper methods and the Cache inner class to be static, removing unnecessary instance method references
  • Added comprehensive TODO documentation explaining the caching limitation with SNAPSHOT and 0.0.0 versions
  • Added two disabled tests (usesCacheEvenItSnapshot and cachesEvenItZeroVersion) demonstrating the expected but currently failing behavior

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

void usesCacheEvenItSnapshot(@Mktmp final Path temp) throws Exception {
final Path source = FpDefaultTest.existedSource(temp);
final Path target = FpDefaultTest.notExistedTarget(temp);
final String version = "1.0.1";
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The test name and assertion message suggest this test is validating SNAPSHOT version behavior, but the version used is "1.0.1", which is a regular release version. For testing SNAPSHOT behavior, the version should contain "SNAPSHOT" (e.g., "1.0-SNAPSHOT") to properly validate the intended scenario.

Suggested change
final String version = "1.0.1";
final String version = "1.0-SNAPSHOT";

Copilot uses AI. Check for mistakes.
Comment on lines +312 to +319
MatcherAssert.assertThat(
"We expect that cache is used even for SNAPSHOT version",
new TextOf(target).asString(),
Matchers.allOf(
Matchers.equalTo(FpDefaultTest.cacheContent()),
Matchers.not(Matchers.equalTo(FpDefaultTest.footprintContent()))
)
);
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

According to the custom coding guideline, tests should contain only one assertion. This test uses Matchers.allOf which combines two matchers into a single assertion call. Consider splitting this into a single, focused assertion that validates the primary behavior: that the cache content is used.

Copilot generated this review using guidance from organization custom instructions.
Comment on lines +338 to +345
MatcherAssert.assertThat(
"We expect that cache is used even for 0.0.0 version",
new TextOf(target).asString(),
Matchers.allOf(
Matchers.equalTo(FpDefaultTest.cacheContent()),
Matchers.not(Matchers.equalTo(FpDefaultTest.footprintContent()))
)
);
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

According to the custom coding guideline, tests should contain only one assertion. This test uses Matchers.allOf which combines two matchers into a single assertion call. Consider splitting this into a single, focused assertion that validates the primary behavior: that the cache content is used.

Copilot generated this review using guidance from organization custom instructions.

@Test
@Disabled
void usesCacheEvenItSnapshot(@Mktmp final Path temp) throws Exception {
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The test name has a grammatical error. It should be "usesCacheEvenIfItIsSnapshot" or similar to properly convey the test intent with correct grammar.

Suggested change
void usesCacheEvenItSnapshot(@Mktmp final Path temp) throws Exception {
void usesCacheEvenIfItIsSnapshot(@Mktmp final Path temp) throws Exception {

Copilot uses AI. Check for mistakes.

@Test
@Disabled
void cachesEvenItZeroVersion(@Mktmp final Path temp) throws Exception {
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The test name has a grammatical error. It should be "cachesEvenIfItIsZeroVersion" or similar to properly convey the test intent with correct grammar.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 11, 2025

🚀 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 194.946 191.590 -3.355 -1.72% ms/op Average Time

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec0f732 and 688d1e7.

📒 Files selected for processing (2)
  • eo-maven-plugin/src/test/java/org/eolang/maven/FpDefaultTest.java (19 hunks)
  • eo-maven-plugin/src/test/java/org/eolang/maven/MjProbeTest.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • eo-maven-plugin/src/test/java/org/eolang/maven/FpDefaultTest.java
🧰 Additional context used
🧬 Code graph analysis (1)
eo-maven-plugin/src/test/java/org/eolang/maven/MjProbeTest.java (1)
eo-maven-plugin/src/test/java/org/eolang/maven/MjLintIT.java (1)
  • Disabled (37-101)
⏰ 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). (12)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: mvn (ubuntu-24.04, 17)
  • GitHub Check: benchmark
  • GitHub Check: mvn (windows-2022, 23)
  • GitHub Check: mvn (ubuntu-24.04, 23)
  • GitHub Check: mvn (macos-15, 23)
  • GitHub Check: trufflehog
  • GitHub Check: ort
  • GitHub Check: snippets
  • GitHub Check: integration
  • GitHub Check: pr-size
  • GitHub Check: qulice
🔇 Additional comments (1)
eo-maven-plugin/src/test/java/org/eolang/maven/MjProbeTest.java (1)

15-15: LGTM!

The import is necessary for the @Disabled annotation used below.

Comment on lines +52 to +64
/**
* Finds probes in objectionary remote repository.
* @param temp Temporary folder
* @throws IOException If some problem inside
* @todo #4526:90min Fix flaky {@link #findsProbesInOyRemote(Path)} test.
* The test sometimes fails with the following error:
* MjProbeTest.findsProbesInOyRemote:62 We should find 10 objects in
* git repository with tag '0.50.0', but 9 found.
* This might happen because the remote repository structure changes over time.
* We need to investigate this issue and fix the test to make it stable.
*/
@Test
@Disabled
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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if FpDefaultTest exists and search for related changes
fd -e java "FpDefaultTest"

# Search for @Disabled tests to understand the pattern
rg -n "@Disabled" --type=java -B 2 | head -100

Repository: objectionary/eo

Length of output: 6836


🏁 Script executed:

# Examine FpDefaultTest to understand the caching context and PR scope
cat -n eo-maven-plugin/src/test/java/org/eolang/maven/FpDefaultTest.java | head -50

# Check if MjProbeTest also mentions issue #4526
rg -n "4526" eo-maven-plugin/src/test/java/org/eolang/maven/MjProbeTest.java

# Check what other changes are in MjProbeTest around the disabled test
cat -n eo-maven-plugin/src/test/java/org/eolang/maven/MjProbeTest.java | sed -n '45,70p'

Repository: objectionary/eo

Length of output: 3558


🏁 Script executed:

# Check if MjProbeTest file shows any other disabled tests in same PR
rg -n "@Disabled|@Test" eo-maven-plugin/src/test/java/org/eolang/maven/MjProbeTest.java | head -30

# Check MjLintIT mentioned in original comment to understand the "pattern"
fd -e java "MjLintIT" -x cat -n {} | head -40

Repository: objectionary/eo

Length of output: 2088


Clear documentation and appropriate short-term workaround, but remote test inherently fragile.

The Javadoc clearly explains why the test is disabled, and the TODO provides tracking. However, some clarification:

  1. PR scope is coherent: This PR addresses multiple aspects of issue Compilation caching question #4526—both the SNAPSHOT caching issue (in FpDefaultTest) and the flaky remote repository probe test (in MjProbeTest). The apparent scope discrepancy in the original review is resolved by examining the full context.

  2. Remote test fragility is inherent: The test depends on a remote Git repository with tag 0.50.0 containing exactly 10 objects. This is inherently fragile because external repositories change over time. While disabling with clear documentation is a reasonable short-term approach, consider these longer-term improvements:

    • Using a local test fixture instead of a remote repository
    • Mocking the remote repository behavior
    • Making expectations more flexible (e.g., checking for specific high-value objects rather than an exact count)

The approach of disabling the test with clear TODO documentation is appropriate for now, but plan to make this integration test more resilient rather than leaving it disabled indefinitely.

@volodya-lombrozo
Copy link
Copy Markdown
Member Author

@yegor256 could you have a look, please?

@yegor256
Copy link
Copy Markdown
Member

@volodya-lombrozo if we cache results while eo-maven-plugin is in the SNAPSHOT version, we won't be able to run tests while changing Java code in the plugin. The data will always come from the cache. Did you consider this?

@volodya-lombrozo
Copy link
Copy Markdown
Member Author

@volodya-lombrozo if we cache results while eo-maven-plugin is in the SNAPSHOT version, we won't be able to run tests while changing Java code in the plugin. The data will always come from the cache. Did you consider this?

@yegor256 sorry, could you explain it in detail, please? How changing code in the eo-maven-plugin should affect the cache? Do you have a step-by-step example?

Actually I have already removed this functionality here and all tests pass.

@yegor256
Copy link
Copy Markdown
Member

@volodya-lombrozo imagine, you are a developer of eo-maven-plugin. You run mvn test and you see a problem. Then, you fix your Java code (in the eo-maven-plugin) and run mvn test again. The files are not generated by your new Java code, but taken from cache. You get confused.

@volodya-lombrozo
Copy link
Copy Markdown
Member Author

volodya-lombrozo commented Dec 12, 2025

@volodya-lombrozo imagine, you are a developer of eo-maven-plugin. You run mvn test and you see a problem. Then, you fix your Java code (in the eo-maven-plugin) and run mvn test again. The files are not generated by your new Java code, but taken from cache. You get confused.

@yegor256 which tests? If there are some tests that require eo files compilation - they should be clearly configured with disabled cache. Moreover, I can't find such tests

@yegor256
Copy link
Copy Markdown
Member

@volodya-lombrozo ok, this part make sense:

they should be clearly configured with disabled cache

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

Successfully merging this pull request may close these issues.

3 participants