* Run the compiler to completion, and assert that no errors occurred.
(customTransformers?: CustomTransformers)
| 289 | * Run the compiler to completion, and assert that no errors occurred. |
| 290 | */ |
| 291 | driveMain(customTransformers?: CustomTransformers): void { |
| 292 | if (isNgpTestMode()) { |
| 293 | const { |
| 294 | rootNames, |
| 295 | options, |
| 296 | errors: configErrors, |
| 297 | } = readNgcCommandLineAndConfiguration(this.commandLineArgs); |
| 298 | expect(configErrors.length).toBe(0); |
| 299 | const tsconfigPath = this.fs.resolve(this.basePath, 'tsconfig.json'); |
| 300 | const writeFileCallback = |
| 301 | this.multiCompileHostExt !== null |
| 302 | ? this.multiCompileHostExt.writeFile.bind(this.multiCompileHostExt) |
| 303 | : undefined; |
| 304 | const result = performNgpCompilationSync({ |
| 305 | fs: this.fs, |
| 306 | basePath: this.basePath, |
| 307 | tsconfigPath, |
| 308 | rootNames, |
| 309 | options, |
| 310 | emit: true, |
| 311 | complianceMode: true, |
| 312 | customTransformers, |
| 313 | writeFileCallback, |
| 314 | session: this.ngpSession ?? undefined, |
| 315 | }); |
| 316 | this.lastTsProgram = result.tsProgram; |
| 317 | const errors = result.diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error); |
| 318 | expect(errors.map((e) => ts.flattenDiagnosticMessageText(e.messageText, '\n'))).toEqual([]); |
| 319 | expect(result.exitCode).toBe(0); |
| 320 | return; |
| 321 | } |
| 322 | |
| 323 | const errorSpy = jasmine.createSpy('consoleError').and.callFake(console.error); |
| 324 | let reuseProgram: {program: Program | undefined} | undefined = undefined; |
| 325 | if (this.multiCompileHostExt !== null) { |
| 326 | reuseProgram = { |
| 327 | program: this.oldProgram || undefined, |
| 328 | }; |
| 329 | } |
| 330 | const exitCode = main( |
| 331 | this.commandLineArgs, |
| 332 | errorSpy, |
| 333 | undefined, |
| 334 | customTransformers, |
| 335 | reuseProgram, |
| 336 | this.changedResources, |
| 337 | ); |
| 338 | |
| 339 | if (errorSpy.calls.count() > 0) { |
| 340 | console.error('>>>', errorSpy.calls.allArgs().join('\n')); |
| 341 | } |
| 342 | expect(errorSpy).not.toHaveBeenCalled(); |
| 343 | |
| 344 | expect(exitCode).toBe(0); |
| 345 | if (this.multiCompileHostExt !== null) { |
| 346 | this.oldProgram = reuseProgram!.program!; |
| 347 | } |
| 348 | } |
no test coverage detected