8000 Tests, mocks, test parallelism by andrewaylett · Pull Request #107 · andrewaylett/arc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Tests, mocks, test parallelism #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged

Tests, mocks, test parallelism #107

merged 1 commit into from
May 29, 2025

Conversation

andrewaylett
Copy link
Owner

No description provided.

@Copilot Copilot AI review requested due to automatic review settings May 29, 2025 22:15
Copy link
@Copilot 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 enhances the testing infrastructure and robustness of the Arc cache implementation. It introduces parallel test execution, expands test coverage with additional cases (e.g., null key handling, loader exception and retry, concurrent access with the same key), and enforces null-check invariants in the main cache code, along with updating module and dependency configurations.

  • Enable JUnit test parallelism via properties.
  • Add multiple tests addressing edge cases and concurrency behavior.
  • Integrate null checks via a new Invariants class and update build/module configurations.

Reviewed Changes

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

Show a summary per file
File Description
lib/src/test/resources/junit-platform.properties Enabling parallel test execution
lib/src/test/java/eu/aylett/arc/ArcTest.java Addition of tests covering null keys, loader behavior, and concurrency
lib/src/main/java/module-info.java Updated module dependencies (added JetBrains annotations)
lib/src/main/java/eu/aylett/arc/internal/Invariants.java New utility class for null-checks
lib/src/main/java/eu/aylett/arc/internal/Element.java Updated get() method handling completed exceptions and weak values
lib/src/main/java/eu/aylett/arc/Arc.java Enforcing null-checks in constructor and get() method
lib/build.gradle.kts Added dependencies for JetBrains annotations and Mockito
gradle/libs.versions.toml Updated version references for JetBrains and Mockito
gradle/gradle-daemon-jvm.properties New Gradle daemon configuration properties

@@ -269,7 +276,7 @@ record = recordedValues.stream().collect(Collectors.groupingBy((v) -> v, Collect
.forEach(adjacentPair -> {
var start = adjacentPair.getFirst();
var end = adjacentPair.getLast();
assertThat(end.toEpochMilli(), lessThan(start.plusSeconds(35).toEpochMilli()));
assertThat(end.toEpochMilli(), lessThan(start.plusSeconds(55).toEpochMilli()));
Copy link
Preview
Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Consider adding a comment explaining the rationale for increasing the timing threshold from 35 to 55 seconds in the eviction test to clarify the expected behavior.

Copilot uses AI. Check for mistakes.

var currentWeakValue = this.weakValue;
if (currentWeakValue == null || !currentWeakValue.refersTo(v)) {
this.weakValue = new WeakReference<>(v);
if (currentValue == null || currentValue.isCompletedExceptionally()) {
Copy link
Preview
Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Add a comment to clarify why elements with a completed exceptional future trigger a reload, to improve code maintainability and future understanding.

Copilot uses AI. Check for mistakes.

if (currentWeakValue != null) {
var v = currentWeakValue.get();
if (v != null) {
return (this.value = CompletableFuture.completedFuture(v)).copy();
Copy link
Preview
Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Consider adding a comment explaining the need to call copy() after creating the completed future to preserve immutability or prevent side effects.

Copilot uses AI. Check for mistakes.

@andrewaylett andrewaylett enabled auto-merge (rebase) May 29, 2025 22:16
@andrewaylett andrewaylett merged commit 148e34a into main May 29, 2025
5 checks passed
@andrewaylett andrewaylett deleted the push-nkssosynupkz branch May 29, 2025 22:17
Copy link
  • Surviving mutants in this change: 6
  • Killed mutants in this change: 11
class surviving killed
🧟eu.aylett.arc.internal.Element 6 7
💯eu.aylett.arc.internal.Invariants 0 4

See https://pitest.org

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.

1 participant
0