Skip to content

test: TemplateJarRefreshActivityTest finds its JAR also once another test has listed the temp directory - #2361

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/template-jar-refresh-temp-dir
Nov 30, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/template-jar-refresh-temp-dir

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2360

TemplateJarRefreshActivityTest failed on IntelliJ 2025.3 in a CI run of #2355, which doesn't touch the templates: its three tests that build a JAR, at their first assertTemplates. One test: commit, for contributors only; no change to LSP4IJ itself. For 0.30.2.

Cause: the test

Each test built its JAR in a new folder of the temp directory, then looked it up with JarFileSystem.findFileByPath, without a refresh. The VFS looks on disk for a file it hasn't seen yet only in a folder whose children it hasn't listed yet. So once another test of the same JVM had listed the temp directory, the VFS didn't find the new folder, and assertTemplates failed at line 167. Which tests share a JVM, and in which order they run, varies with CI's three test forks.

LSP4IJ itself isn't affected: TemplateJarRefreshActivity looks up LSP4IJ's own JAR, which the VFS knows from the IDE's previous start.

Fix

The first build of a test's JAR is looked up with refreshAndFindFileByNioFile, as the IDE knows the JAR from which it read the templates at its previous start. The later builds aren't refreshed, so that the tests still see what the VFS has cached of the old JAR.

Proof

With the temp directory listed in setUp (getChildren() of its VFS file) before the test creates its folder, on macOS:

Test Result
The test as it was the three tests fail every time at line 167, as on CI; testGetTemplateRootNeverRefreshes passes
The test as it is now the four tests pass
The test as it is now, without the refresh in TemplateJarRefreshActivity.refreshOnce testTheTemplatesOfARebuiltJarAreNewAfterTheRefresh and testItRefreshesOnlyOnceForAllProjects fail at the templates they find, so the tests still need the product's refresh

Without the listing, headless, with the counts from the JUnit XMLs:

IntelliJ TemplateJarRefreshActivityTest Failures
IC 2024.2 4 0
IC 2025.3 4 0
IU 2026.3 4 0

…test has listed the temp directory

Each test built its JAR in a new folder of the temp directory and looked it up without a refresh. Once another test of
the same JVM had listed the temp directory, the VFS didn't look for the new folder on disk, and the first
assertTemplates failed, as on IntelliJ 2025.3 in a CI run of redhat-developer#2355. The first build of a test's JAR is now looked up
with a refresh, as the IDE knows the JAR from which it read the templates at its previous start.

Fixes redhat-developer#2360
@lagergren lagergren added this to the 0.30.2 milestone Nov 30, 2026
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Strengthened validation that newly built template JARs are detected on the first build, including when the virtual file system has already scanned the temporary directory. This improves confidence that template JAR discovery works in that scenario.

The test helper now refreshes the VFS and checks for the JAR on its first build. Later builds do not use this refresh check.

Changes: JAR discovery test

Layer / File(s) Summary
First-build VFS check
src/test/java/com/redhat/devtools/lsp4ij/templates/TemplateJarRefreshActivityTest.java
The helper documents why the first build needs a VFS lookup. When the JAR did not exist before the build, the helper refreshes the VFS and asserts that it finds the JAR.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other · Severity of issue fixed: Low

Merge Risk: Minimal · up to ac97d

This test-only change makes an intermittent test failure less likely and does not affect product behavior. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the test class and the specific behavior fixed: the test finds its JAR after another test has listed the temp directory. The changeset adds a refresh-based lookup for the first JAR bui…
Description check Passed The description explains the failure cause (VFS not seeing a new folder after the temp directory was listed), the fix (refreshAndFindFileByNioFile for the first JAR build only), and the verification r…
Linked Issues check Passed Issue #2360 asks for a test-only fix. The first build of each test JAR must be found through the VFS, and later builds must stay unrefreshed. At the reviewed head, `TemplateJarRefreshActivityTest.buil…
Out of Scope Changes check Passed The change summary reports one modified file: src/test/java/com/redhat/devtools/lsp4ij/templates/TemplateJarRefreshActivityTest.java (+9/-0). The head file shows the first-build refresh in build, …
Full details: Title check

Explanation

The title names the test class and the specific behavior fixed: the test finds its JAR after another test has listed the temp directory. The changeset adds a refresh-based lookup for the first JAR build in TemplateJarRefreshActivityTest, so the title matches the main change. The 'test:' prefix correctly marks a test-only change.

Full details: Description check

Explanation

The description explains the failure cause (VFS not seeing a new folder after the temp directory was listed), the fix (refreshAndFindFileByNioFile for the first JAR build only), and the verification results. It directly relates to the single test-file change.

Full details: Linked Issues check

Explanation

Issue #2360 asks for a test-only fix. The first build of each test JAR must be found through the VFS, and later builds must stay unrefreshed. At the reviewed head, TemplateJarRefreshActivityTest.build calls LocalFileSystem.getInstance().refreshAndFindFileByNioFile(jar) when first is true (the JAR does not yet exist). Later builds skip the refresh, so the tests still observe the VFS-cached old JAR, as the issue requires. The change is in the test file only, and LSP4IJ product code is not changed. The PR description reports, with the temp directory listed in setUp, that the three failing tests fail at line 167 without the fix and pass with it. It also reports that the headless runs pass on IC 2024.2, IC 2025.3, and IU 2026.3. Those runs were not re-executed in this review. The full diff could not be read, so the assessment relies on the head file content and the raw change summary, which reports only this file changed. No unmet coding requirement was found.

Full details: Out of Scope Changes check

Explanation

The change summary reports one modified file: src/test/java/com/redhat/devtools/lsp4ij/templates/TemplateJarRefreshActivityTest.java (+9/-0). The head file shows the first-build refresh in build, with Javadoc explaining it. This change directly implements #2360. No unrelated product code, configuration, or other file change is reported. The full diff could not be read, so a change outside the summary cannot be fully excluded.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3396acd5-ea38-4215-befb-b947e75c2978
Commits

Reviewing files that changed from the base of the PR and between d1d8df5 and ac97da5.

Files selected for processing: 1

  • src/test/java/com/redhat/devtools/lsp4ij/templates/TemplateJarRefreshActivityTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.84%. Comparing base (d1d8df5) to head (ac97da5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2361      +/-   ##
==========================================
- Coverage   58.86%   58.84%   -0.03%     
==========================================
  Files         849      849              
  Lines       36719    36719              
  Branches     5767     7609    +1842     
==========================================
- Hits        21614    21606       -8     
- Misses      12102    12103       +1     
- Partials     3003     3010       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren
lagergren merged commit 0612fe5 into redhat-developer:main Nov 30, 2026
11 checks passed
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.

TemplateJarRefreshActivityTest fails at times: it doesn't find its JAR once another test has listed the temp directory

1 participant