Skip to content

making test suite a bit faster#812

Merged
yegor256 merged 3 commits intomasterfrom
811
Mar 29, 2026
Merged

making test suite a bit faster#812
yegor256 merged 3 commits intomasterfrom
811

Conversation

@yegor256
Copy link
Copy Markdown
Member

@yegor256 yegor256 commented Mar 24, 2026

fixes #811

Summary by CodeRabbit

  • Refactor

    • Introduced caching across lint components to reduce redundant work, improving lint performance and resource loading speed.
  • Tests

    • Added scoped lint configurations for faster, targeted checks; updated test expectations and adjusted timeouts for more reliable execution.
  • Chores

    • Bumped a build dependency to a newer version.

Copilot AI review requested due to automatic review settings March 24, 2026 01:56
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e1ef35dc-55c2-4947-b09a-204d893df748

📥 Commits

Reviewing files that changed from the base of the PR and between e96fae0 and 96791f8.

📒 Files selected for processing (3)
  • pom.xml
  • src/test/java/org/eolang/lints/SourceTest.java
  • src/test/java/org/eolang/lints/WpaLintsTest.java
✅ Files skipped from review due to trivial changes (1)
  • pom.xml

📝 Walkthrough

Walkthrough

This change introduces static caches for lint name and lint collections, refactors XSL-based lint loading to use a cached list built via resource resolution, and narrows test lint scopes to speed and stabilize test execution. Tests and a cactoos dependency version were updated.

Changes

Cohort / File(s) Summary
Cached Mono/WPA Lint Names
src/main/java/org/eolang/lints/MonoLintNames.java, src/main/java/org/eolang/lints/WpaLintNames.java
Precompute and store lint name iterables in private static final fields; constructors now reuse cached NAMES instead of rebuilding on each instantiation.
Cached Combined Lint Names
src/main/java/org/eolang/lints/MonoLints.java
Added private static final List<String> ALL_NAMES computed once from existing lint sources; reused where a list of all mono lint names is required.
PK XSL Lint Loading Refactor
src/main/java/org/eolang/lints/PkByXsl.java
Introduce private static final List<?> LINTS populated by load() using PathMatchingResourcePatternResolver and streams; change constructor to use cached LINTS wrapped in Shuffled; adjust IOException handling and replace cactoos Mapped with Java streams.
PkWpa reuse of Mono names
src/main/java/org/eolang/lints/PkWpa.java
Added cached ListOf<String> MONO_NAMES static field and reuse it in constructor call sites instead of creating new MonoLintNames instances each time.
Scoped/Updated Tests
src/test/java/org/eolang/lints/SourceTest.java, src/test/java/org/eolang/lints/WpaLintsTest.java
Added SourceTest.SINGLE lint iterable and updated tests to pass explicit, smaller lint sets; removed some @Timeout annotations; wrapped a test map in Sticky in WpaLintsTest.
Dependency version bump
pom.xml
Updated org.cactoos:cactoos from 0.57.0 to 0.59.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • implement LfDfSticky #393 — touches PkWpa construction and mono-lint usage patterns; likely related to caching/reuse of mono lint names.

Suggested labels

core

Suggested reviewers

  • h1alexbel

Poem

🐰 I cached the names so they hop once and rest,
the lints now settle tidy in their nest.
Tests trimmed to nibble, not to roam,
the suite runs lighter — home sweet home. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the PR—performance optimization through caching and code refactoring—which aligns with the changeset across multiple source files.
Linked Issues check ✅ Passed The PR implements caching strategies (static final fields) and removes redundant computations in MonoLintNames, MonoLints, PkByXsl, PkWpa, and WpaLintNames, directly addressing the objective to reduce test suite execution time.
Out of Scope Changes check ✅ Passed All changes are performance-focused optimizations directly supporting the test suite speedup objective; pom.xml dependency update and SourceTest modifications are supporting changes aligned with performance goals.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 811

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

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 targets issue #811 by reducing full test-suite runtime via minimizing repeated lint initialization work and narrowing down which lints are exercised in some tests.

Changes:

  • Introduces a “single lint” fast path in SourceTest so several tests validate defect detection without running the full lint set.
  • Adds static caching for mono/WPA lint name collections to avoid recomputing them during WPA/Program setup.
  • Caches XSL-based lint instances in PkByXsl to avoid repeated classpath scanning and XSL parsing.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/test/java/org/eolang/lints/SourceTest.java Uses a single XSL lint in selected tests to reduce runtime; adjusts test inputs accordingly.
src/main/java/org/eolang/lints/WpaLintNames.java Caches WPA lint names statically to reduce repeated iteration.
src/main/java/org/eolang/lints/PkWpa.java Reuses cached mono lint names when building WPA lints.
src/main/java/org/eolang/lints/PkByXsl.java Loads and caches XSL-based lint instances once, then shuffles the cached list per iteration.
src/main/java/org/eolang/lints/MonoLints.java Precomputes a cached list of all lint names used by LtIncorrectUnlint.
src/main/java/org/eolang/lints/MonoLintNames.java Caches mono lint names statically to reduce repeated iteration.

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

@@ -133,24 +142,24 @@ void suppressesManyLints() throws IOException {
}

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The @Timeout annotation was removed from this test. Dropping timeouts usually doesn’t make the suite faster, but it does remove protection against hangs (e.g., parser/XSLT deadlocks or CI environment stalls). Consider keeping a timeout here (potentially reduced if the goal is faster feedback) so a single stuck run can’t block the whole test suite.

Suggested change
@Timeout(unit = TimeUnit.SECONDS, value = 60L)

Copilot uses AI. Check for mistakes.
);
}

@Tag("deep")
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The @Timeout for this multithreaded test was removed. Since this test runs in parallel and is tagged "deep", keeping a timeout is important to avoid the entire suite hanging indefinitely on rare CI stalls or deadlocks; consider restoring a reasonable timeout (even if shorter than before).

Suggested change
@Tag("deep")
@Tag("deep")
@Timeout(value = 1, unit = TimeUnit.MINUTES)

Copilot uses AI. Check for mistakes.
Comment on lines +78 to 83
throw new IllegalArgumentException(ex);
}
}
).collect(Collectors.toList());
} catch (final IOException ex) {
throw new IllegalArgumentException(ex);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

IOException is wrapped into IllegalArgumentException without any context about which XSL resource failed to load. This makes failures hard to diagnose (especially during static initialization). Consider using an exception type that reflects an internal loading failure (e.g., IllegalStateException) and include the resource URL/filename in the message for both the inner and outer catch paths.

Suggested change
throw new IllegalArgumentException(ex);
}
}
).collect(Collectors.toList());
} catch (final IOException ex) {
throw new IllegalArgumentException(ex);
throw new IllegalStateException(
String.format(
"Failed to load XSL lint resource from '%s'",
res.toString()
),
ex
);
}
}
).collect(Collectors.toList());
} catch (final IOException ex) {
throw new IllegalStateException(
"Failed to resolve XSL lint resources with pattern 'classpath*:org/eolang/lints/**/*.xsl'",
ex
);

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot added the core Changes are made to core parts of the code base label Mar 29, 2026
@yegor256 yegor256 merged commit 3ae6966 into master Mar 29, 2026
22 of 23 checks passed
@yegor256 yegor256 deleted the 811 branch March 29, 2026 03:48
@0crat
Copy link
Copy Markdown

0crat commented Mar 29, 2026

@yegor256 Hey there! Nice work on the contribution - you've earned +4 points this time! Here's the breakdown: +16 as a basis, +8.45 for your 169 hits-of-code, -4 for going over 100 hits-of-code, and -8 for skipping the code review (ouch!). Next time, try to get some reviews in there to avoid that penalty and maybe keep the contributions a bit more focused - you'll hit those higher point ranges! Your running score is +5, so keep the momentum going and don't forget to check your Zerocracy account too! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes are made to core parts of the code base

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Full test suite execution exceeding acceptable time limit

3 participants