@@ -5,6 +5,7 @@ var retryContext = require('./retry_context.ts');
55
66var DEFAULT_MAX_SUMMARY_ITEMS = 20 ;
77var DEFAULT_MAX_TEXT_LENGTH = 200 ;
8+ var INTENTIONAL_FLAKY_FAILURE_PREFIX = 'Intentional flaky failure for CI validation:' ;
89
910function 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