@@ -425,6 +425,9 @@ module Harness {
425425 listFiles ( path : string , filter : RegExp , options ?: { recursive ?: boolean } ) : string [ ] ;
426426 log ( text : string ) : void ;
427427 getMemoryUsage ?( ) : number ;
428+ args ( ) : string [ ] ;
429+ getExecutingFilePath ( ) : string ;
430+ exit ( exitCode ?: number ) : void ;
428431 }
429432 export var IO : IO ;
430433
@@ -446,7 +449,10 @@ module Harness {
446449 } else {
447450 fso = { } ;
448451 }
449-
452+
453+ export const args = ( ) => ts . sys . args ;
454+ export const getExecutingFilePath = ( ) => ts . sys . getExecutingFilePath ( ) ;
455+ export const exit = ( exitCode : number ) => ts . sys . exit ( exitCode ) ;
450456 export const resolvePath = ( path : string ) => ts . sys . resolvePath ( path ) ;
451457 export const getCurrentDirectory = ( ) => ts . sys . getCurrentDirectory ( ) ;
452458 export const newLine = ( ) => harnessNewLine ;
@@ -517,6 +523,9 @@ module Harness {
517523 export const getCurrentDirectory = ( ) => ts . sys . getCurrentDirectory ( ) ;
518524 export const newLine = ( ) => harnessNewLine ;
519525 export const useCaseSensitiveFileNames = ( ) => ts . sys . useCaseSensitiveFileNames ;
526+ export const args = ( ) => ts . sys . args ;
527+ export const getExecutingFilePath = ( ) => ts . sys . getExecutingFilePath ( ) ;
528+ export const exit = ( exitCode : number ) => ts . sys . exit ( exitCode ) ;
520529
521530 export const readFile : typeof IO . readFile = path => ts . sys . readFile ( path ) ;
522531 export const writeFile : typeof IO . writeFile = ( path , content ) => ts . sys . writeFile ( path , content ) ;
@@ -589,6 +598,10 @@ module Harness {
589598 export const newLine = ( ) => harnessNewLine ;
590599 export const useCaseSensitiveFileNames = ( ) => false ;
591600 export const getCurrentDirectory = ( ) => "" ;
601+ export const args = ( ) => < string [ ] > [ ] ;
602+ export const getExecutingFilePath = ( ) => "" ;
603+ export const exit = ( exitCode : number ) => { } ;
604+
592605 let supportsCodePage = ( ) => false ;
593606
594607 module Http {
@@ -1331,8 +1344,8 @@ module Harness {
13311344 export function getErrorBaseline ( inputFiles : { unitName : string ; content : string } [ ] , diagnostics : ts . Diagnostic [ ] ) {
13321345 diagnostics . sort ( ts . compareDiagnostics ) ;
13331346 let outputLines : string [ ] = [ ] ;
1334- // Count up all the errors we find so we don't miss any
1335- let totalErrorsReported = 0 ;
1347+ // Count up all errors that were found in files other than lib.d.ts so we don't miss any
1348+ let totalErrorsReportedInNonLibraryFiles = 0 ;
13361349
13371350 function outputErrorText ( error : ts . Diagnostic ) {
13381351 let message = ts . flattenDiagnosticMessageText ( error . messageText , Harness . IO . newLine ( ) ) ;
@@ -1343,8 +1356,15 @@ module Harness {
13431356 . filter ( s => s . length > 0 )
13441357 . map ( s => "!!! " + ts . DiagnosticCategory [ error . category ] . toLowerCase ( ) + " TS" + error . code + ": " + s ) ;
13451358 errLines . forEach ( e => outputLines . push ( e ) ) ;
1346-
1347- totalErrorsReported ++ ;
1359+
1360+ // do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics
1361+ // if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers)
1362+ // then they will be added twice thus triggering 'total errors' assertion with condition
1363+ // 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length
1364+
1365+ if ( ! error . file || ! isLibraryFile ( error . file . fileName ) ) {
1366+ totalErrorsReportedInNonLibraryFiles ++ ;
1367+ }
13481368 }
13491369
13501370 // Report global errors
@@ -1428,7 +1448,9 @@ module Harness {
14281448 return diagnostic . file && diagnostic . file . fileName . indexOf ( "test262-harness" ) >= 0 ;
14291449 } ) ;
14301450
1431- assert . equal ( totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics , diagnostics . length , "total number of errors" ) ;
1451+ // Verify we didn't miss any errors in total
1452+ assert . equal ( totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics , diagnostics . length , "total number of errors" ) ;
1453+
14321454 return minimalDiagnosticsToString ( diagnostics ) +
14331455 Harness . IO . newLine ( ) + Harness . IO . newLine ( ) + outputLines . join ( "\r\n" ) ;
14341456 }
@@ -1805,11 +1827,11 @@ module Harness {
18051827 return filePath . indexOf ( Harness . libFolder ) === 0 ;
18061828 }
18071829
1808- export function getDefaultLibraryFile ( ) : { unitName : string , content : string } {
1809- let libFile = Harness . userSpecifiedRoot + Harness . libFolder + "/" + " lib.d.ts";
1830+ export function getDefaultLibraryFile ( io : Harness . IO ) : { unitName : string , content : string } {
1831+ let libFile = Harness . userSpecifiedRoot + Harness . libFolder + "lib.d.ts" ;
18101832 return {
18111833 unitName : libFile ,
1812- content : IO . readFile ( libFile )
1834+ content : io . readFile ( libFile )
18131835 } ;
18141836 }
18151837
0 commit comments