style(ngcc): reformat of ngcc after clang update (#36447)
PR Close #36447
This commit is contained in:

committed by
Kara Erickson

parent
bfa55162de
commit
74b7a8eaf5
@ -14,13 +14,13 @@ import {MockLogger} from '../helpers/mock_logger';
|
||||
runInEachFileSystem(() => {
|
||||
describe('AsyncLocker', () => {
|
||||
describe('lock()', () => {
|
||||
it('should guard the `fn()` with calls to `write()` and `remove()`', async() => {
|
||||
it('should guard the `fn()` with calls to `write()` and `remove()`', async () => {
|
||||
const fs = getFileSystem();
|
||||
const log: string[] = [];
|
||||
const lockFile = new MockLockFile(fs, log);
|
||||
const locker = new AsyncLocker(lockFile, new MockLogger(), 100, 10);
|
||||
|
||||
await locker.lock(async() => {
|
||||
await locker.lock(async () => {
|
||||
log.push('fn() - before');
|
||||
// This promise forces node to do a tick in this function, ensuring that we are truly
|
||||
// testing an async scenario.
|
||||
@ -31,7 +31,7 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
|
||||
it('should guard the `fn()` with calls to `write()` and `remove()`, even if it throws',
|
||||
async() => {
|
||||
async () => {
|
||||
let error: string = '';
|
||||
const fs = getFileSystem();
|
||||
const log: string[] = [];
|
||||
@ -39,7 +39,7 @@ runInEachFileSystem(() => {
|
||||
const locker = new AsyncLocker(lockFile, new MockLogger(), 100, 10);
|
||||
|
||||
try {
|
||||
await locker.lock(async() => {
|
||||
await locker.lock(async () => {
|
||||
log.push('fn()');
|
||||
throw new Error('ERROR');
|
||||
});
|
||||
@ -50,7 +50,7 @@ runInEachFileSystem(() => {
|
||||
expect(log).toEqual(['write()', 'fn()', 'remove()']);
|
||||
});
|
||||
|
||||
it('should retry if another process is locking', async() => {
|
||||
it('should retry if another process is locking', async () => {
|
||||
const fs = getFileSystem();
|
||||
const log: string[] = [];
|
||||
const lockFile = new MockLockFile(fs, log);
|
||||
@ -69,7 +69,7 @@ runInEachFileSystem(() => {
|
||||
return lockFileContents;
|
||||
});
|
||||
|
||||
const promise = locker.lock(async() => log.push('fn()'));
|
||||
const promise = locker.lock(async () => log.push('fn()'));
|
||||
// The lock is now waiting on the lock-file becoming free, so no `fn()` in the log.
|
||||
expect(log).toEqual(['write()', 'read() => 188']);
|
||||
expect(logger.logs.info).toEqual([[
|
||||
@ -83,7 +83,7 @@ runInEachFileSystem(() => {
|
||||
expect(log).toEqual(['write()', 'read() => 188', 'write()', 'fn()', 'remove()']);
|
||||
});
|
||||
|
||||
it('should extend the retry timeout if the other process locking the file changes', async() => {
|
||||
it('should extend the retry timeout if the other process locking the file changes', async () => {
|
||||
const fs = getFileSystem();
|
||||
const log: string[] = [];
|
||||
const lockFile = new MockLockFile(fs, log);
|
||||
@ -102,7 +102,7 @@ runInEachFileSystem(() => {
|
||||
return lockFileContents;
|
||||
});
|
||||
|
||||
const promise = locker.lock(async() => log.push('fn()'));
|
||||
const promise = locker.lock(async () => log.push('fn()'));
|
||||
// The lock is now waiting on the lock-file becoming free, so no `fn()` in the log.
|
||||
expect(log).toEqual(['write()', 'read() => 188']);
|
||||
expect(logger.logs.info).toEqual([[
|
||||
@ -132,7 +132,7 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
|
||||
it('should error if another process does not release the lock-file before this times out',
|
||||
async() => {
|
||||
async () => {
|
||||
const fs = getFileSystem();
|
||||
const log: string[] = [];
|
||||
const lockFile = new MockLockFile(fs, log);
|
||||
@ -151,7 +151,7 @@ runInEachFileSystem(() => {
|
||||
return lockFileContents;
|
||||
});
|
||||
|
||||
const promise = locker.lock(async() => log.push('fn()'));
|
||||
const promise = locker.lock(async () => log.push('fn()'));
|
||||
|
||||
// The lock is now waiting on the lock-file becoming free, so no `fn()` in the log.
|
||||
expect(log).toEqual(['write()', 'read() => 188']);
|
||||
@ -159,10 +159,11 @@ runInEachFileSystem(() => {
|
||||
let error: Error;
|
||||
await promise.catch(e => error = e);
|
||||
expect(log).toEqual(['write()', 'read() => 188', 'write()', 'read() => 188']);
|
||||
expect(error !.message)
|
||||
expect(error!.message)
|
||||
.toEqual(
|
||||
`Timed out waiting 0.2s for another ngcc process, with id 188, to complete.\n` +
|
||||
`(If you are sure no ngcc process is running then you should delete the lock-file at ${lockFile.path}.)`);
|
||||
`(If you are sure no ngcc process is running then you should delete the lock-file at ${
|
||||
lockFile.path}.)`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ runInEachFileSystem(() => {
|
||||
class LockFileUnderTest extends LockFileWithChildProcess {
|
||||
// Note that log is initialized in the `createUnlocker()` function that is called from
|
||||
// super(), so we can't initialize it here.
|
||||
log !: string[];
|
||||
log!: string[];
|
||||
constructor(fs: FileSystem) {
|
||||
super(fs, new MockLogger());
|
||||
fs.ensureDir(fs.dirname(this.path));
|
||||
@ -47,7 +47,11 @@ runInEachFileSystem(() => {
|
||||
const log = this.log;
|
||||
// Normally this would fork a child process and return it.
|
||||
// But we don't want to do that in these tests.
|
||||
return <any>{disconnect() { log.push('unlocker.disconnect()'); }};
|
||||
return <any>{
|
||||
disconnect() {
|
||||
log.push('unlocker.disconnect()');
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {AbsoluteFsPath, FileSystem, absoluteFrom, getFileSystem} from '../../../../src/ngtsc/file_system';
|
||||
import {absoluteFrom, AbsoluteFsPath, FileSystem, getFileSystem} from '../../../../src/ngtsc/file_system';
|
||||
import {runInEachFileSystem} from '../../../../src/ngtsc/file_system/testing';
|
||||
import {removeLockFile} from '../../../src/locking/lock_file_with_child_process/util';
|
||||
import {MockLogger} from '../../helpers/mock_logger';
|
||||
@ -24,8 +24,9 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
|
||||
describe('removeLockFile()', () => {
|
||||
it('should do nothing if there is no file to remove',
|
||||
() => { removeLockFile(fs, logger, absoluteFrom('/lockfile/path'), '1234'); });
|
||||
it('should do nothing if there is no file to remove', () => {
|
||||
removeLockFile(fs, logger, absoluteFrom('/lockfile/path'), '1234');
|
||||
});
|
||||
|
||||
it('should do nothing if the pid does not match', () => {
|
||||
fs.writeFile(lockFilePath, '888');
|
||||
|
@ -50,7 +50,9 @@ runInEachFileSystem(() => {
|
||||
const lockFile = new MockLockFile(fs, log);
|
||||
const locker = new SyncLocker(lockFile);
|
||||
|
||||
spyOn(lockFile, 'write').and.callFake(() => { throw {code: 'EEXIST'}; });
|
||||
spyOn(lockFile, 'write').and.callFake(() => {
|
||||
throw {code: 'EEXIST'};
|
||||
});
|
||||
spyOn(lockFile, 'read').and.returnValue('188');
|
||||
|
||||
expect(() => locker.lock(() => {}))
|
||||
@ -58,7 +60,8 @@ runInEachFileSystem(() => {
|
||||
`ngcc is already running at process with id 188.\n` +
|
||||
`If you are running multiple builds in parallel then you should pre-process your node_modules via the command line ngcc tool before starting the builds;\n` +
|
||||
`See https://v9.angular.io/guide/ivy#speeding-up-ngcc-compilation.\n` +
|
||||
`(If you are sure no ngcc process is running then you should delete the lock-file at ${lockFile.path}.)`);
|
||||
`(If you are sure no ngcc process is running then you should delete the lock-file at ${
|
||||
lockFile.path}.)`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user