@@ -86,17 +86,31 @@ async function main() {
86
86
} ) ;
87
87
88
88
await writeTestCase ( caseData , testFile . replace ( rootPath , "./tsc-tests/original-tests" ) )
89
-
90
- const result = compileFiles ( toBeCompiled , [ ] , {
91
- declaration : "true" ,
92
- isolatedDeclarations : "true" ,
93
- removeComments : "false" ,
94
- } , settings , undefined ) ;
89
+ const updatedTestFileName = testFile . replace ( rootPath , "./tsc-tests/updated-tests" ) ;
90
+ const result = ( ( ) => {
91
+ try {
92
+ return compileFiles ( toBeCompiled , [ ] , {
93
+ declaration : "true" ,
94
+ isolatedDeclarations : "true" ,
95
+ removeComments : "false" ,
96
+ } , settings , undefined ) ;
97
+ } catch ( e ) {
98
+ return e as Error ;
99
+ }
100
+ } ) ( ) ;
101
+ if ( result instanceof Error ) {
102
+ fs . writeFile ( updatedTestFileName , `
103
+ ================= CODE MOD ERROR ==============
104
+ ${ result . message }
105
+ ${ result . stack }
106
+ ` ) ;
107
+ continue ;
108
+ }
95
109
const program = result . program ! ;
96
110
97
111
98
112
99
- for ( const testFileContent of caseData . testUnitData ) {
113
+ for ( const testFileContent of caseData . testUnitData ) {
100
114
if ( ! isRelevantTestFile ( testFileContent ) ) continue ;
101
115
try {
102
116
const sourceFile = program . getSourceFile ( testFileContent . name ) ! ;
@@ -130,10 +144,15 @@ async function main() {
130
144
testFileContent . content = resultStr ;
131
145
} catch ( e ) {
132
146
console . log ( `Test ${ testFile } failed to transform` )
133
- process . exit ( ) ;
147
+ testFileContent . content = `
148
+ ================= CODE MOD ERROR ==============
149
+ ${ e . message }
150
+ ${ e . stack }
151
+ ` ;
152
+ debugger ;
134
153
}
135
154
}
136
- await writeTestCase ( caseData , testFile . replace ( rootPath , "./tsc-tests/updated-tests" ) )
155
+ await writeTestCase ( caseData , updatedTestFileName )
137
156
console . log ( `Ran: ${ count } ` ) ;
138
157
}
139
158
}
0 commit comments