Skip to content

Commit

Permalink
Warn instead of fail on leftover suite reports
Browse files Browse the repository at this point in the history
  • Loading branch information
nktpro committed Apr 11, 2024
1 parent 33582fe commit 6cd1e54
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
runs-on: [self-hosted, nix, general, arm64-linux, small]
timeout-minutes: 5
env:
IMAGE_REPOSITORY: public.ecr.aws/shopstic
RELEASE_VERSION: ${{ github.event.inputs.releaseVersion }}
NEXT_VERSION: ${{ github.event.inputs.nextVersion }}
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ object TpReporter {
}
}

private def truncateMessage(message: String, length: Int): String = {
if (message.length <= length) {
message
}
else {
message.take(length) + s" ... [${message.length - length} more chars truncated]"
}
}

def reportSuite(
uuid: ULID,
suite: TpTestSuite,
Expand Down Expand Up @@ -285,10 +294,14 @@ object TpReporter {
}
}

def reportNext(maybeTestName: Option[String], outcome: TestOutcome, time: Instant) = {
def reportNext(
maybeTestName: Option[String],
outcome: TestOutcome,
time: Instant
): ZIO[Any, IllegalStateException, Chunk[TestReport]] = {
pendingTests.modify {
case test :: tail =>
for {
val t: ZIO[Any, IllegalStateException, (Chunk[TestReport], List[TpTest])] = for {
startTime <- startTimeRef.getAndSet(time)
testOutcome = TestReport(
nodeId = test.id,
Expand Down Expand Up @@ -317,7 +330,20 @@ object TpReporter {
out -> tail
}

case Nil => ZIO.fail(new IllegalStateException("Received extra test report"))
t

case Nil =>
val suiteName = suite.name
val truncatedOutcome = outcome match {
case TestPassed => outcome
case TestIgnored => outcome
case TestFailed(message, details) =>
TestFailed(truncateMessage(message, 2048), truncateMessage(details, 2048))
}

zlogger
.warn(s"Received extra test report $suiteName $maybeTestName $truncatedOutcome")
.as(Chunk.empty -> Nil)
}
}

Expand Down

0 comments on commit 6cd1e54

Please sign in to comment.