@@ -38,7 +38,7 @@ const constEnumCaptureRegexp = /^(\s*)(export )?const enum (\S+) {(\s*)$/gm;
3838const constEnumReplacement = "$1$2enum $3 {$4" ;
3939
4040const cmdLineOptions = minimist ( process . argv . slice ( 2 ) , {
41- boolean : [ "debug" , "inspect" , "light" , "colors" , "lint" , "soft" , "fix" ] ,
41+ boolean : [ "debug" , "inspect" , "light" , "colors" , "lint" , "soft" , "fix" , "failed" , "keepFailed" ] ,
4242 string : [ "browser" , "tests" , "host" , "reporter" , "stackTraceLimit" , "timeout" ] ,
4343 alias : {
4444 "b" : "browser" ,
@@ -598,7 +598,6 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
598598 return seq ;
599599} ) ;
600600
601-
602601// Task to build the tests infrastructure using the built compiler
603602const run = path . join ( builtLocalDirectory , "run.js" ) ;
604603gulp . task ( run , /*help*/ false , [ servicesFile , tsserverLibraryFile ] , ( ) => {
@@ -653,10 +652,12 @@ function runConsoleTests(defaultReporter, runInParallel, done) {
653652 let testTimeout = cmdLineOptions . timeout ;
654653 const debug = cmdLineOptions . debug ;
655654 const inspect = cmdLineOptions . inspect ;
656- const tests = cmdLineOptions . tests ;
655+ let tests = cmdLineOptions . tests ;
657656 const runners = cmdLineOptions . runners ;
658657 const light = cmdLineOptions . light ;
659658 const stackTraceLimit = cmdLineOptions . stackTraceLimit ;
659+ const failed = cmdLineOptions . failed ;
660+ const keepFailed = cmdLineOptions . keepFailed || failed ;
660661 const testConfigFile = "test.config" ;
661662 if ( fs . existsSync ( testConfigFile ) ) {
662663 fs . unlinkSync ( testConfigFile ) ;
@@ -679,8 +680,8 @@ function runConsoleTests(defaultReporter, runInParallel, done) {
679680 testTimeout = 400000 ;
680681 }
681682
682- if ( tests || runners || light || testTimeout || taskConfigsFolder ) {
683- writeTestConfigFile ( tests , runners , light , taskConfigsFolder , workerCount , stackTraceLimit , testTimeout ) ;
683+ if ( tests || runners || light || testTimeout || taskConfigsFolder || keepFailed ) {
684+ writeTestConfigFile ( tests , runners , light , taskConfigsFolder , workerCount , stackTraceLimit , testTimeout , keepFailed ) ;
684685 }
685686
686687 const colors = cmdLineOptions . colors ;
@@ -690,7 +691,8 @@ function runConsoleTests(defaultReporter, runInParallel, done) {
690691 // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
691692 if ( ! runInParallel ) {
692693 const args = [ ] ;
693- args . push ( "-R" , reporter ) ;
694+ args . push ( "-R" , "scripts/failed-tests" ) ;
695+ args . push ( "-O" , '"reporter=' + reporter + ( keepFailed ? ",keepFailed=true" : "" ) + '"' ) ;
694696 if ( tests ) {
695697 args . push ( "-g" , `"${ tests } "` ) ;
696698 }
@@ -711,8 +713,12 @@ function runConsoleTests(defaultReporter, runInParallel, done) {
711713 }
712714 args . push ( run ) ;
713715 setNodeEnvToDevelopment ( ) ;
714- exec ( mocha , args , lintThenFinish , finish ) ;
715-
716+ if ( failed ) {
717+ exec ( host , [ "scripts/run-failed-tests.js" ] . concat ( args ) , lintThenFinish , finish ) ;
718+ }
719+ else {
720+ exec ( mocha , args , lintThenFinish , finish ) ;
721+ }
716722 }
717723 else {
718724 // run task to load all tests and partition them between workers
@@ -888,8 +894,9 @@ function cleanTestDirs(done) {
888894 * @param {number= } workerCount
889895 * @param {string= } stackTraceLimit
890896 * @param {number= } timeout
897+ * @param {boolean= } keepFailed
891898 */
892- function writeTestConfigFile ( tests , runners , light , taskConfigsFolder , workerCount , stackTraceLimit , timeout ) {
899+ function writeTestConfigFile ( tests , runners , light , taskConfigsFolder , workerCount , stackTraceLimit , timeout , keepFailed ) {
893900 const testConfigContents = JSON . stringify ( {
894901 test : tests ? [ tests ] : undefined ,
895902 runner : runners ? runners . split ( "," ) : undefined ,
@@ -899,6 +906,7 @@ function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCou
899906 taskConfigsFolder,
900907 noColor : ! cmdLineOptions . colors ,
901908 timeout,
909+ keepFailed
902910 } ) ;
903911 console . log ( "Running tests with config: " + testConfigContents ) ;
904912 fs . writeFileSync ( "test.config" , testConfigContents ) ;
0 commit comments