test(ivy): run compiler compliance tests without rebuilding core,common (#25248)
Previously the compiler compliance tests ran and built test code with real dependencies on @angular/core and @angular/common. This meant that any changes to the compiler would result in long rebuild processes for tests to rerun. This change removes those dependencies and causes test code to be built against the fake_core stub of @angular/core that the ngtsc tests use. This change also removes the dependency on @angular/common entirely, as locality means it's possible to reference *ngIf without needing to link to an implementation. PR Close #25248
This commit is contained in:
parent
afa6b9e794
commit
eb999300d9
|
@ -12,17 +12,14 @@ ts_library(
|
||||||
"//packages/compiler",
|
"//packages/compiler",
|
||||||
"//packages/compiler-cli",
|
"//packages/compiler-cli",
|
||||||
"//packages/compiler/test:test_utils",
|
"//packages/compiler/test:test_utils",
|
||||||
"//packages/compiler/testing",
|
|
||||||
"//packages/core",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
jasmine_node_test(
|
jasmine_node_test(
|
||||||
name = "compliance",
|
name = "compliance",
|
||||||
bootstrap = ["angular/tools/testing/init_node_spec.js"],
|
bootstrap = ["angular/tools/testing/init_node_no_angular_spec.js"],
|
||||||
data = [
|
data = [
|
||||||
"//packages/common:npm_package",
|
"//packages/compiler-cli/test/ngtsc/fake_core:npm_package",
|
||||||
"//packages/core:npm_package",
|
|
||||||
],
|
],
|
||||||
tags = [
|
tags = [
|
||||||
"ivy-local",
|
"ivy-local",
|
||||||
|
@ -30,6 +27,6 @@ jasmine_node_test(
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":test_lib",
|
":test_lib",
|
||||||
"//tools/testing:node",
|
"//tools/testing:node_no_angular",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,9 +14,9 @@ describe('mock_compiler', () => {
|
||||||
// This produces a MockDirectory of the file needed to compile an Angular application.
|
// This produces a MockDirectory of the file needed to compile an Angular application.
|
||||||
// This setup is performed in a beforeAll which populates the map returned.
|
// This setup is performed in a beforeAll which populates the map returned.
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
|
compileFakeCore: true,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('compiling', () => {
|
describe('compiling', () => {
|
||||||
|
|
|
@ -17,9 +17,9 @@ import {compile, expectEmit} from './mock_compile';
|
||||||
describe('compiler compliance', () => {
|
describe('compiler compliance', () => {
|
||||||
|
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: true,
|
compileFakeCore: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('elements', () => {
|
describe('elements', () => {
|
||||||
|
@ -1287,7 +1287,6 @@ describe('compiler compliance', () => {
|
||||||
app: {
|
app: {
|
||||||
'spec.ts': `
|
'spec.ts': `
|
||||||
import {Component, NgModule} from '@angular/core';
|
import {Component, NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-component',
|
selector: 'my-component',
|
||||||
|
@ -1301,7 +1300,7 @@ describe('compiler compliance', () => {
|
||||||
})
|
})
|
||||||
export class MyComponent {}
|
export class MyComponent {}
|
||||||
|
|
||||||
@NgModule({declarations: [MyComponent], imports: [CommonModule]})
|
@NgModule({declarations: [MyComponent]})
|
||||||
export class MyModule {}
|
export class MyModule {}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ import {compile, expectEmit} from './mock_compile';
|
||||||
|
|
||||||
describe('compiler compliance: bindings', () => {
|
describe('compiler compliance: bindings', () => {
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
|
compileFakeCore: true,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('text bindings', () => {
|
describe('text bindings', () => {
|
||||||
|
|
|
@ -11,9 +11,9 @@ import {compile, expectEmit} from './mock_compile';
|
||||||
|
|
||||||
describe('compiler compliance: dependency injection', () => {
|
describe('compiler compliance: dependency injection', () => {
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
|
compileFakeCore: true,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create factory methods', () => {
|
it('should create factory methods', () => {
|
||||||
|
@ -21,7 +21,6 @@ describe('compiler compliance: dependency injection', () => {
|
||||||
app: {
|
app: {
|
||||||
'spec.ts': `
|
'spec.ts': `
|
||||||
import {Component, NgModule, Injectable, Attribute, Host, SkipSelf, Self, Optional} from '@angular/core';
|
import {Component, NgModule, Injectable, Attribute, Host, SkipSelf, Self, Optional} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MyService {}
|
export class MyService {}
|
||||||
|
@ -42,7 +41,7 @@ describe('compiler compliance: dependency injection', () => {
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({declarations: [MyComponent], imports: [CommonModule], providers: [MyService]})
|
@NgModule({declarations: [MyComponent], providers: [MyService]})
|
||||||
export class MyModule {}
|
export class MyModule {}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ const TRANSLATION_NAME_REGEXP = /^MSG_[A-Z0-9]+/;
|
||||||
|
|
||||||
describe('i18n support in the view compiler', () => {
|
describe('i18n support in the view compiler', () => {
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
|
compileFakeCore: true,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('single text nodes', () => {
|
describe('single text nodes', () => {
|
||||||
|
|
|
@ -11,9 +11,9 @@ import {compile, expectEmit} from './mock_compile';
|
||||||
|
|
||||||
describe('compiler compliance: listen()', () => {
|
describe('compiler compliance: listen()', () => {
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
|
compileFakeCore: true,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create declare inputs/outputs', () => {
|
it('should create declare inputs/outputs', () => {
|
||||||
|
|
|
@ -14,9 +14,9 @@ import {compile, expectEmit} from './mock_compile';
|
||||||
*/
|
*/
|
||||||
describe('compiler compliance: listen()', () => {
|
describe('compiler compliance: listen()', () => {
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
|
compileFakeCore: true,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create listener instruction on element', () => {
|
it('should create listener instruction on element', () => {
|
||||||
|
@ -63,7 +63,6 @@ describe('compiler compliance: listen()', () => {
|
||||||
app: {
|
app: {
|
||||||
'spec.ts': `
|
'spec.ts': `
|
||||||
import {Component, NgModule} from '@angular/core';
|
import {Component, NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-component',
|
selector: 'my-component',
|
||||||
|
@ -80,7 +79,7 @@ describe('compiler compliance: listen()', () => {
|
||||||
onClick2(name: any) {}
|
onClick2(name: any) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({declarations: [MyComponent], imports: [CommonModule]})
|
@NgModule({declarations: [MyComponent]})
|
||||||
export class MyModule {}
|
export class MyModule {}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ import {compile, expectEmit} from './mock_compile';
|
||||||
|
|
||||||
describe('r3_view_compiler', () => {
|
describe('r3_view_compiler', () => {
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
|
compileFakeCore: true,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('hello world', () => {
|
describe('hello world', () => {
|
||||||
|
@ -47,7 +47,6 @@ describe('r3_view_compiler', () => {
|
||||||
app: {
|
app: {
|
||||||
'example.ts': `
|
'example.ts': `
|
||||||
import {Component, OnInit, OnDestroy, ElementRef, Input, NgModule} from '@angular/core';
|
import {Component, OnInit, OnDestroy, ElementRef, Input, NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-app',
|
selector: 'my-app',
|
||||||
|
@ -83,7 +82,6 @@ describe('r3_view_compiler', () => {
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [TodoComponent, MyApp],
|
declarations: [TodoComponent, MyApp],
|
||||||
imports: [CommonModule]
|
|
||||||
})
|
})
|
||||||
export class TodoModule{}
|
export class TodoModule{}
|
||||||
`
|
`
|
||||||
|
|
|
@ -13,9 +13,9 @@ import {compile, expectEmit} from './mock_compile';
|
||||||
|
|
||||||
describe('compiler compliance: styling', () => {
|
describe('compiler compliance: styling', () => {
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
|
compileFakeCore: true,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('[style] and [style.prop]', () => {
|
describe('[style] and [style.prop]', () => {
|
||||||
|
|
|
@ -11,9 +11,9 @@ import {compile, expectEmit} from './mock_compile';
|
||||||
|
|
||||||
describe('compiler compliance: template', () => {
|
describe('compiler compliance: template', () => {
|
||||||
const angularFiles = setup({
|
const angularFiles = setup({
|
||||||
compileAngular: true,
|
compileAngular: false,
|
||||||
|
compileFakeCore: true,
|
||||||
compileAnimations: false,
|
compileAnimations: false,
|
||||||
compileCommon: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly bind to context in nested template', () => {
|
it('should correctly bind to context in nested template', () => {
|
||||||
|
@ -21,7 +21,6 @@ describe('compiler compliance: template', () => {
|
||||||
app: {
|
app: {
|
||||||
'spec.ts': `
|
'spec.ts': `
|
||||||
import {Component, NgModule} from '@angular/core';
|
import {Component, NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-component',
|
selector: 'my-component',
|
||||||
|
@ -43,7 +42,7 @@ describe('compiler compliance: template', () => {
|
||||||
onClick(outer: any, middle: any, inner: any) { }
|
onClick(outer: any, middle: any, inner: any) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({declarations: [MyComponent], imports: [CommonModule]})
|
@NgModule({declarations: [MyComponent]})
|
||||||
export class MyModule {}
|
export class MyModule {}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
@ -122,7 +121,6 @@ describe('compiler compliance: template', () => {
|
||||||
app: {
|
app: {
|
||||||
'spec.ts': `
|
'spec.ts': `
|
||||||
import {Component, NgModule} from '@angular/core';
|
import {Component, NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-component',
|
selector: 'my-component',
|
||||||
|
@ -133,7 +131,7 @@ describe('compiler compliance: template', () => {
|
||||||
})
|
})
|
||||||
export class MyComponent {}
|
export class MyComponent {}
|
||||||
|
|
||||||
@NgModule({declarations: [MyComponent], imports: [CommonModule]})
|
@NgModule({declarations: [MyComponent]})
|
||||||
export class MyModule {}
|
export class MyModule {}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
@ -174,7 +172,6 @@ describe('compiler compliance: template', () => {
|
||||||
app: {
|
app: {
|
||||||
'spec.ts': `
|
'spec.ts': `
|
||||||
import {Component, NgModule} from '@angular/core';
|
import {Component, NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-component',
|
selector: 'my-component',
|
||||||
|
@ -187,7 +184,7 @@ describe('compiler compliance: template', () => {
|
||||||
})
|
})
|
||||||
export class MyComponent {}
|
export class MyComponent {}
|
||||||
|
|
||||||
@NgModule({declarations: [MyComponent], imports: [CommonModule]})
|
@NgModule({declarations: [MyComponent]})
|
||||||
export class MyModule {}
|
export class MyModule {}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
@ -243,7 +240,6 @@ describe('compiler compliance: template', () => {
|
||||||
app: {
|
app: {
|
||||||
'spec.ts': `
|
'spec.ts': `
|
||||||
import {Component, NgModule} from '@angular/core';
|
import {Component, NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-component',
|
selector: 'my-component',
|
||||||
|
@ -258,7 +254,7 @@ describe('compiler compliance: template', () => {
|
||||||
})
|
})
|
||||||
export class MyComponent {}
|
export class MyComponent {}
|
||||||
|
|
||||||
@NgModule({declarations: [MyComponent], imports: [CommonModule]})
|
@NgModule({declarations: [MyComponent]})
|
||||||
export class MyModule {}
|
export class MyModule {}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ export type ModuleWithProviders<T> = any;
|
||||||
export class ChangeDetectorRef {}
|
export class ChangeDetectorRef {}
|
||||||
export class ElementRef {}
|
export class ElementRef {}
|
||||||
export class Injector {}
|
export class Injector {}
|
||||||
export class TemplateRef {}
|
export class TemplateRef<T = any> {}
|
||||||
export class ViewContainerRef {}
|
export class ViewContainerRef {}
|
||||||
export class ɵNgModuleFactory<T> {
|
export class ɵNgModuleFactory<T> {
|
||||||
constructor(public clazz: T) {}
|
constructor(public clazz: T) {}
|
||||||
|
@ -56,3 +56,5 @@ export class ɵNgModuleFactory<T> {
|
||||||
export function forwardRef<T>(fn: () => T): T {
|
export function forwardRef<T>(fn: () => T): T {
|
||||||
return fn();
|
return fn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SimpleChanges { [propName: string]: any; }
|
|
@ -602,12 +602,16 @@ export function isInBazel(): boolean {
|
||||||
return process.env.TEST_SRCDIR != null;
|
return process.env.TEST_SRCDIR != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setup(
|
export function setup(options: {
|
||||||
options: {compileAngular: boolean, compileAnimations: boolean, compileCommon?: boolean} = {
|
compileAngular: boolean,
|
||||||
compileAngular: true,
|
compileFakeCore?: boolean,
|
||||||
compileAnimations: true,
|
compileAnimations: boolean, compileCommon?: boolean
|
||||||
compileCommon: false,
|
} = {
|
||||||
}) {
|
compileAngular: true,
|
||||||
|
compileAnimations: true,
|
||||||
|
compileCommon: false,
|
||||||
|
compileFakeCore: false,
|
||||||
|
}) {
|
||||||
let angularFiles = new Map<string, string>();
|
let angularFiles = new Map<string, string>();
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
@ -626,6 +630,11 @@ export function setup(
|
||||||
path.join(sources, 'angular/packages/core/npm_package'), 'core', angularFiles,
|
path.join(sources, 'angular/packages/core/npm_package'), 'core', angularFiles,
|
||||||
skipDirs);
|
skipDirs);
|
||||||
}
|
}
|
||||||
|
if (options.compileFakeCore) {
|
||||||
|
readBazelWrittenFilesFrom(
|
||||||
|
path.join(sources, 'angular/packages/compiler-cli/test/ngtsc/fake_core/npm_package'),
|
||||||
|
'core', angularFiles, skipDirs);
|
||||||
|
}
|
||||||
if (options.compileAnimations) {
|
if (options.compileAnimations) {
|
||||||
// If this fails please add //packages/animations:npm_package as a test data dependency.
|
// If this fails please add //packages/animations:npm_package as a test data dependency.
|
||||||
readBazelWrittenFilesFrom(
|
readBazelWrittenFilesFrom(
|
||||||
|
|
Loading…
Reference in New Issue