Skip to content

Commit f6b1d3e

Browse files
Liviu RauDevtools-frontend LUCI CQ
authored andcommitted
Report source locations to ResultDB
This adds source file information for Interaction and E2E tests. It is not possible atm to add that info for Unit tests, and line number information is expensive to extract. See bug below for details. Bug: 389873145 Change-Id: Ie640f8cc617685ba4faff9f0b28f4ca411e5eede Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6175033 Reviewed-by: Eric Leese <[email protected]> Reviewed-by: Philip Pfaffe <[email protected]> Commit-Queue: Liviu Rau <[email protected]>
1 parent 9ee155b commit f6b1d3e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

test/conductor/resultsdb.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
import * as fs from 'fs';
66
import * as http from 'http';
7+
import * as path from 'path';
8+
9+
import {GEN_DIR} from './paths.js';
10+
11+
export const REPO = 'https://chromium.googlesource.com/devtools/devtools-frontend';
712

813
// This type mirrors test_result.proto.
914
// https://source.chromium.org/chromium/infra/infra/+/main:recipes-py/recipe_proto/go.chromium.org/luci/resultdb/proto/sink/v1/test_result.proto
@@ -19,6 +24,13 @@ export interface TestResult {
1924
filePath: string,
2025
},
2126
};
27+
testMetadata?: {
28+
name: string,
29+
location: {
30+
repo: string,
31+
fileName?: string,
32+
},
33+
};
2234
}
2335

2436
class SanitizedTestIdTag {
@@ -94,3 +106,7 @@ export function sendTestResult(results: TestResult): void {
94106
request.write(data);
95107
request.end();
96108
}
109+
110+
export function testLocation(file?: string): string|undefined {
111+
return file ? `//${path.relative(GEN_DIR, file).replace('.js', '.ts')}` : undefined;
112+
}

test/shared/mocha-resultsdb-reporter.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ class ResultsDbReporter extends Mocha.reporters.Spec {
136136
testId: ResultsDb.sanitizedTestId(testId),
137137
duration: `${test.duration || 0}ms`,
138138
tags: [{key: 'run', value: String(testRetry.currentRetry() + 1)}],
139+
testMetadata: {
140+
name: test.title,
141+
location: {
142+
repo: ResultsDb.REPO,
143+
fileName: ResultsDb.testLocation(test.file),
144+
}
145+
}
139146
};
140147
const hookName = this.maybeHook(test);
141148
if (hookName) {

0 commit comments

Comments
 (0)