@@ -31,32 +31,9 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
31
31
const cls = this ;
32
32
describe ( `${ this . kind ( ) } code samples` , function ( this : Mocha . ISuiteCallbackContext ) {
33
33
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
- } ) ;
47
34
for ( const test of testList ) {
48
35
cls . runTest ( typeof test === "string" ? test : test . file ) ;
49
36
}
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
- } ) ;
60
37
} ) ;
61
38
}
62
39
private runTest ( directoryName : string ) {
@@ -137,14 +114,16 @@ ${stripAbsoluteImportPaths(result.stderr.toString().replace(/\r\n/g, "\n"))}`;
137
114
function stripAbsoluteImportPaths ( result : string ) {
138
115
return result
139
116
. 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` ) ;
141
120
}
142
121
143
122
function sortErrors ( result : string ) {
144
123
return ts . flatten ( splitBy ( result . split ( "\n" ) , s => / ^ \S + / . test ( s ) ) . sort ( compareErrorStrings ) ) . join ( "\n" ) ;
145
124
}
146
125
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 . * ) / ;
148
127
function compareErrorStrings ( a : string [ ] , b : string [ ] ) {
149
128
ts . Debug . assertGreaterThanOrEqual ( a . length , 1 ) ;
150
129
ts . Debug . assertGreaterThanOrEqual ( b . length , 1 ) ;
@@ -156,11 +135,12 @@ function compareErrorStrings(a: string[], b: string[]) {
156
135
if ( ! matchB ) {
157
136
return 1 ;
158
137
}
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 ;
161
140
return ts . comparePathsCaseSensitive ( errorFileA , errorFileB ) ||
162
141
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 ) ;
164
144
}
165
145
166
146
class DefinitelyTypedRunner extends ExternalCompileRunnerBase {
0 commit comments