Skip to content

Commit 20e8e7e

Browse files
Improved flaky tests report page
1 parent b0a2999 commit 20e8e7e

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

tests/osn-tests/util/list-reporter.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var retryContext = require('./retry_context.ts');
55

66
var DEFAULT_MAX_SUMMARY_ITEMS = 20;
77
var DEFAULT_MAX_TEXT_LENGTH = 200;
8+
var INTENTIONAL_FLAKY_FAILURE_PREFIX = 'Intentional flaky failure for CI validation:';
89

910
function ListReporter(runner) {
1011
mocha.reporters.Base.call(this, runner);
@@ -58,6 +59,27 @@ function ListReporter(runner) {
5859
return normalized.substr(0, maxLength - 3) + '...';
5960
}
6061

62+
function normalizeTestFilePath(filePath) {
63+
if (typeof filePath !== 'string' || !filePath.trim()) {
64+
return '';
65+
}
66+
67+
var relativePath = path.relative(process.cwd(), filePath);
68+
var normalizedPath = relativePath && !relativePath.startsWith('..')
69+
? relativePath
70+
: filePath;
71+
72+
return normalizedPath.split(path.sep).join('/');
73+
}
74+
75+
function isIntentionalCiValidationFailure(err) {
76+
return Boolean(
77+
err &&
78+
typeof err.message === 'string' &&
79+
err.message.indexOf(INTENTIONAL_FLAKY_FAILURE_PREFIX) === 0
80+
);
81+
}
82+
6183
function summarizeFlakyTests(flakyTests, maxItems) {
6284
var visibleTests = flakyTests.slice(0, maxItems);
6385
var summaryLines = visibleTests.map(function(testCase) {
@@ -123,16 +145,17 @@ function ListReporter(runner) {
123145

124146
runner.on('pass', function(test) {
125147
passes++;
148+
var retryFailure = retryContext.getRetryFailure(test);
126149
retryContext.clearRetryFailure(test);
127150

128-
if (getRetryCount(test) > 0) {
151+
if (getRetryCount(test) > 0 && !isIntentionalCiValidationFailure(retryFailure)) {
129152
flakyTestCases.push({
130153
suite: test.parent.title,
131154
title: test.title,
132155
fullTitle: typeof test.fullTitle === 'function'
133156
? test.fullTitle()
134157
: test.parent.title + ' ' + test.title,
135-
file: test.file || '',
158+
file: normalizeTestFilePath(test.file || ''),
136159
duration: test.duration,
137160
attempts: getRetryCount(test) + 1
138161
});

0 commit comments

Comments
 (0)