@@ -31,32 +31,9 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
3131 const cls = this ;
3232 describe ( `${ this . kind ( ) } code samples` , function ( this : Mocha . ISuiteCallbackContext ) {
3333 this . timeout ( 600_000 ) ; // 10 minutes
34- const cwd = path . join ( Harness . IO . getWorkspaceRoot ( ) , cls . testDir ) ;
35- const placeholderName = ".node_modules" ;
36- const moduleDirName = "node_modules" ;
37- before ( ( ) => {
38- ts . forEachAncestorDirectory ( cwd , dir => {
39- try {
40- fs . renameSync ( path . join ( dir , moduleDirName ) , path . join ( dir , placeholderName ) ) ;
41- }
42- catch {
43- // empty
44- }
45- } ) ;
46- } ) ;
4734 for ( const test of testList ) {
4835 cls . runTest ( typeof test === "string" ? test : test . file ) ;
4936 }
50- after ( ( ) => {
51- ts . forEachAncestorDirectory ( cwd , dir => {
52- try {
53- fs . renameSync ( path . join ( dir , placeholderName ) , path . join ( dir , moduleDirName ) ) ;
54- }
55- catch {
56- // empty
57- }
58- } ) ;
59- } ) ;
6037 } ) ;
6138 }
6239 private runTest ( directoryName : string ) {
@@ -137,14 +114,16 @@ ${stripAbsoluteImportPaths(result.stderr.toString().replace(/\r\n/g, "\n"))}`;
137114function stripAbsoluteImportPaths ( result : string ) {
138115 return result
139116 . replace ( / i m p o r t \( " .* ?\/ t e s t s \/ c a s e s \/ u s e r \/ / g, `import("/` )
140- . replace ( / M o d u l e ' " .* ?\/ t e s t s \/ c a s e s \/ u s e r \/ / g, `Module '"/` ) ;
117+ . replace ( / M o d u l e ' " .* ?\/ t e s t s \/ c a s e s \/ u s e r \/ / g, `Module '"/` )
118+ . replace ( / i m p o r t \( " .* ?\/ T y p e S c r i p t \/ n o d e _ m o d u l e s \/ / g, `import("../../../node_modules` )
119+ . replace ( / M o d u l e ' " .* ?\/ T y p e S c r i p t \/ n o d e _ m o d u l e s \/ / g, `Module '"../../../node_modules` ) ;
141120}
142121
143122function sortErrors ( result : string ) {
144123 return ts . flatten ( splitBy ( result . split ( "\n" ) , s => / ^ \S + / . test ( s ) ) . sort ( compareErrorStrings ) ) . join ( "\n" ) ;
145124}
146125
147- const errorRegexp = / ^ ( .+ \. [ t j ] s x ? ) \( ( \d + ) , ( \d + ) \) : e r r o r T S / ;
126+ const errorRegexp = / ^ ( .+ \. [ t j ] s x ? ) \( ( \d + ) , ( \d + ) \) ( : e r r o r T S . * ) / ;
148127function compareErrorStrings ( a : string [ ] , b : string [ ] ) {
149128 ts . Debug . assertGreaterThanOrEqual ( a . length , 1 ) ;
150129 ts . Debug . assertGreaterThanOrEqual ( b . length , 1 ) ;
@@ -156,11 +135,12 @@ function compareErrorStrings(a: string[], b: string[]) {
156135 if ( ! matchB ) {
157136 return 1 ;
158137 }
159- const [ , errorFileA , lineNumberStringA , columnNumberStringA ] = matchA ;
160- const [ , errorFileB , lineNumberStringB , columnNumberStringB ] = matchB ;
138+ const [ , errorFileA , lineNumberStringA , columnNumberStringA , remainderA ] = matchA ;
139+ const [ , errorFileB , lineNumberStringB , columnNumberStringB , remainderB ] = matchB ;
161140 return ts . comparePathsCaseSensitive ( errorFileA , errorFileB ) ||
162141 ts . compareValues ( parseInt ( lineNumberStringA ) , parseInt ( lineNumberStringB ) ) ||
163- ts . compareValues ( parseInt ( columnNumberStringA ) , parseInt ( columnNumberStringB ) ) ;
142+ ts . compareValues ( parseInt ( columnNumberStringA ) , parseInt ( columnNumberStringB ) ) ||
143+ ts . compareStringsCaseSensitive ( remainderA , remainderB ) ;
164144}
165145
166146class DefinitelyTypedRunner extends ExternalCompileRunnerBase {
0 commit comments