mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
This commit is contained in:
parent
bff96ab517
commit
df56d06974
2 changed files with 36 additions and 2 deletions
|
@ -33,7 +33,7 @@ const MOCK_REPO_DIR = Path.resolve(TMP_DIR, 'mock_repo');
|
|||
|
||||
expect.addSnapshotSerializer(createAbsolutePathSerializer(MOCK_REPO_DIR));
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeAll(async () => {
|
||||
await del(TMP_DIR);
|
||||
await cpy('**/*', MOCK_REPO_DIR, {
|
||||
cwd: MOCK_REPO_SRC,
|
||||
|
@ -42,7 +42,7 @@ beforeEach(async () => {
|
|||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
afterAll(async () => {
|
||||
await del(TMP_DIR);
|
||||
});
|
||||
|
||||
|
@ -153,3 +153,32 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
|
|||
]
|
||||
`);
|
||||
});
|
||||
|
||||
it('uses cache on second run and exist cleanly', async () => {
|
||||
const config = OptimizerConfig.create({
|
||||
repoRoot: MOCK_REPO_DIR,
|
||||
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
|
||||
maxWorkerCount: 1,
|
||||
});
|
||||
|
||||
const msgs = await runOptimizer(config)
|
||||
.pipe(
|
||||
tap(state => {
|
||||
if (state.event?.type === 'worker stdio') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('worker', state.event.stream, state.event.chunk.toString('utf8'));
|
||||
}
|
||||
}),
|
||||
toArray()
|
||||
)
|
||||
.toPromise();
|
||||
|
||||
expect(msgs.map(m => m.state.phase)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"initializing",
|
||||
"initializing",
|
||||
"initializing",
|
||||
"initialized",
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
|
|
@ -44,6 +44,11 @@ export function handleOptimizerCompletion(config: OptimizerConfig) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (prevState?.phase === 'initialized' && prevState.onlineBundles.length === 0) {
|
||||
// all bundles cached
|
||||
return;
|
||||
}
|
||||
|
||||
if (prevState?.phase === 'issue') {
|
||||
throw createFailError('webpack issue');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue