workerReportDecodeFailureResults function

List<EnsembleSingleTestResult> workerReportDecodeFailureResults({
  1. required int workerIndex,
  2. required Object error,
  3. Iterable<String> expectedTestIds = const [],
  4. String? outputFile,
})

Preserves a worker-level result when a report exists but cannot be decoded. The malformed artifact must not discard results already merged from other workers or turn the entire suite into an uncaught CLI exception.

Implementation

List<EnsembleSingleTestResult> workerReportDecodeFailureResults({
  required int workerIndex,
  required Object error,
  Iterable<String> expectedTestIds = const [],
  String? outputFile,
}) {
  final message = 'Test worker ${workerIndex + 1} produced an invalid '
      'results report';
  final detail = outputFile == null ? '' : '. See $outputFile';
  final testIds = expectedTestIds.toSet().toList()..sort();
  final failedTestIds =
      testIds.isEmpty ? ['test-worker-${workerIndex + 1}'] : testIds;
  return [
    for (final testId in failedTestIds)
      EnsembleSingleTestResult.failed(
        testId: testId,
        durationMs: 0,
        message: testIds.isEmpty
            ? '$message$detail'
            : 'Test worker ${workerIndex + 1} could not report assigned test '
                '"$testId" because its results report is invalid$detail',
        failure: TestFailureDetails(
          kind: TestFailureKind.incompleteExecution,
          message: testIds.isEmpty
              ? '$message$detail'
              : 'Test worker ${workerIndex + 1} could not report assigned test '
                  '"$testId" because its results report is invalid$detail',
          phase: 'worker',
        ),
      ),
  ];
}