refactor(ngcc): support running callback before writing transformed files (#36626)
This commit enhances the `CompileFn`, which is used to process each entry-point, to support running a passed-in callback (and wait for it to complete) before proceeding with writing the transformed files to disk. This functionality is currently not used. In a subsequent commit, it will be used for passing info from worker processes to the master process that will allow ngcc to recover when a worker process crashes in the middle of processing a task. PR Close #36626
This commit is contained in:

committed by
Andrew Kushnir

parent
16039d837e
commit
e367593a26
@ -57,12 +57,12 @@ describe('startWorker()', () => {
|
||||
|
||||
it('should create the `compileFn()`', () => {
|
||||
startWorker(mockLogger, createCompileFnSpy);
|
||||
expect(createCompileFnSpy).toHaveBeenCalledWith(jasmine.any(Function));
|
||||
expect(createCompileFnSpy).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function));
|
||||
});
|
||||
|
||||
it('should set up `compileFn()` to send `task-completed` messages to master', () => {
|
||||
startWorker(mockLogger, createCompileFnSpy);
|
||||
const onTaskCompleted: TaskCompletedCallback = createCompileFnSpy.calls.argsFor(0)[0];
|
||||
const onTaskCompleted: TaskCompletedCallback = createCompileFnSpy.calls.argsFor(0)[1];
|
||||
|
||||
onTaskCompleted(null as any, TaskProcessingOutcome.Processed, null);
|
||||
expect(processSendSpy).toHaveBeenCalledTimes(1);
|
||||
|
@ -132,14 +132,15 @@ describe('SingleProcessExecutor', () => {
|
||||
{allTasksCompleted: true, getNextTask: jasmine.any(Function)})]);
|
||||
});
|
||||
|
||||
it('should pass the created TaskCompletedCallback to the createCompileFn', () => {
|
||||
it('should pass the necessary callbacks to createCompileFn', () => {
|
||||
const beforeWritingFiles = jasmine.any(Function);
|
||||
const onTaskCompleted = () => {};
|
||||
const createCompileFn =
|
||||
jasmine.createSpy('createCompileFn').and.returnValue(function compileFn() {});
|
||||
function onTaskCompleted() {}
|
||||
createTaskCompletedCallback.and.returnValue(onTaskCompleted);
|
||||
executor.execute(noTasks, createCompileFn);
|
||||
expect(createCompileFn).toHaveBeenCalledTimes(1);
|
||||
expect(createCompileFn).toHaveBeenCalledWith(onTaskCompleted);
|
||||
expect(createCompileFn).toHaveBeenCalledWith(beforeWritingFiles, onTaskCompleted);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user