public onBuildTaskFinish()

in src/test-runner/run-tracker.ts [185:220]


  public onBuildTaskFinish(params: TaskFinishParams) {
    this.buildTaskTracker.addTaskFinish(params)

    if (params.dataKind !== TaskFinishDataKind.TestFinish) {
      return
    }

    const testFinishData = params.data as TestFinish
    if (testFinishData.dataKind === TestFinishDataKind.JUnitStyleTestCaseData) {
      // Workaround for missing target ID and parent task bug in bazel-bsp server (https://youtrack.jetbrains.com/issue/BAZEL-1585).
      // For now, test runs that contain the same test case in multiple targets of the run will all use the same result.
      let hasMatch = false
      for (const target of this.buildTargets.values()) {
        const key = this.languageToolManager
          .getLanguageTools(target)
          .mapTestFinishDataToLookupKey(testFinishData)

        if (!key) {
          continue
        }

        // Find the matching item and post the updated status.
        const item = this.testsByLookupKey.get(key)
        if (item) {
          this.updateStatusFromTestFinishData(item, testFinishData)
          hasMatch = true
        }
      }

      if (!hasMatch) {
        this.run.appendOutput(
          `Updating ${testFinishData.displayName}: Unable to match this test result to an item in this run.\n`
        )
      }
    }
  }