forked from angular/angular
/
incremental_spec.ts
43 lines (38 loc) · 1.65 KB
/
incremental_spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* 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 {absoluteFrom, getSourceFileOrError} from '../../file_system';
import {runInEachFileSystem} from '../../file_system/testing';
import {NOOP_PERF_RECORDER} from '../../perf';
import {makeProgram} from '../../testing';
import {TraitCompiler} from '../../transform';
import {IncrementalCompilation} from '../src/incremental';
runInEachFileSystem(() => {
describe('incremental reconciliation', () => {
it('should treat source files with changed versions as changed', () => {
const FOO_PATH = absoluteFrom('/foo.ts');
const {program} = makeProgram([
{name: FOO_PATH, contents: `export const FOO = true;`},
]);
const fooSf = getSourceFileOrError(program, FOO_PATH);
const traitCompiler = {getAnalyzedRecords: () => new Map()} as TraitCompiler;
const versionMapFirst = new Map([[FOO_PATH, 'version.1']]);
const firstCompilation = IncrementalCompilation.fresh(
program,
versionMapFirst,
);
firstCompilation.recordSuccessfulAnalysis(traitCompiler);
firstCompilation.recordSuccessfulEmit(fooSf);
const versionMapSecond = new Map([[FOO_PATH, 'version.2']]);
const secondCompilation = IncrementalCompilation.incremental(
program, versionMapSecond, program, firstCompilation.state, new Set(),
NOOP_PERF_RECORDER);
secondCompilation.recordSuccessfulAnalysis(traitCompiler);
expect(secondCompilation.safeToSkipEmit(fooSf)).toBeFalse();
});
});
});