@@ -86,17 +86,31 @@ async function main() {
8686 } ) ;
8787
8888 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+ }
95109 const program = result . program ! ;
96110
97111
98112
99- for ( const testFileContent of caseData . testUnitData ) {
113+ for ( const testFileContent of caseData . testUnitData ) {
100114 if ( ! isRelevantTestFile ( testFileContent ) ) continue ;
101115 try {
102116 const sourceFile = program . getSourceFile ( testFileContent . name ) ! ;
@@ -130,10 +144,15 @@ async function main() {
130144 testFileContent . content = resultStr ;
131145 } catch ( e ) {
132146 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 ;
134153 }
135154 }
136- await writeTestCase ( caseData , testFile . replace ( rootPath , "./tsc-tests/updated-tests" ) )
155+ await writeTestCase ( caseData , updatedTestFileName )
137156 console . log ( `Ran: ${ count } ` ) ;
138157 }
139158}
0 commit comments