Skip to content

Commit

Permalink
Stop provides results from baseline as a part of UNCHANGED results fr…
Browse files Browse the repository at this point in the history
…om the final report
  • Loading branch information
avafanasiev committed Jul 14, 2024
1 parent 49df7cf commit 97a63ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,19 @@ internal fun applyBaseline(report: Run, baseline: Run, options: Options): DiffSt
.filterNot { it.baselineState == BaselineState.ABSENT }
.onEach { result -> baselineCounter.increment(ResultKey(result)) }
.forEach { result ->
val removedFromReport = result.equalIndicators
.flatMap(reportIndex::getOrEmpty)
.any(undecidedFromReport::remove)
//compare with all equal indicators
val matchedResults = result.equalIndicators.flatMap(reportIndex::getOrEmpty).toSet()
val removed = undecidedFromReport.removeAll(matchedResults)

if (removedFromReport || !options.wasChecked.apply(result)) {
state.put(result, BaselineState.UNCHANGED)
if (removed) {
//leads to eliminating problems with the same hash
state.put(matchedResults.first(), BaselineState.UNCHANGED)
} else {
add(result)
if (!options.wasChecked.apply(result)) {
state.put(result, BaselineState.UNCHANGED)
} else {
add(result)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ class BaselineFingerprintTest {
@Test
fun `backward compat -- report v1_v2 - baseline v1`() {
// we can only compare v1 because baseline doesn't have v2
test(readReport("v1_v2"), readBaseline("v1"), expectBaselineMismatch)
val report = readReport("v1_v2")
test(report, readBaseline("v1"), expectBaselineMismatch)
// final report should contain results from report, baseline results only with ABSENT state
report.runs?.get(0)?.results?.forEach {
val expectedSize = if (it.baselineState == BaselineState.ABSENT) 1 else 2
Assertions.assertEquals(expectedSize, it.partialFingerprints.getValues(BaselineCalculation.EQUAL_INDICATOR)?.size)
}
}

@Test
Expand Down

0 comments on commit 97a63ba

Please sign in to comment.