build: switch ViewEngine ngc tests over to use NPM packages (#43431)

The View Engine ngc tests currently rely on the `npm_package` output
that is built locally. This becomes problematic with the new Angular
Package Format v13 where no metadata files are shipped. To continue
being able to test View Engine compilation, we will use the v12.x
framework packages for running the View Engine test.

Note: This means that we no longer test metadata extraction directly
for our framework packages, but given that any change to View Engine
will still land in patch, where the VE packaging still occurs, we should
be covered here.

PR Close #43431
This commit is contained in:
JoostK
2021-09-20 23:17:38 +02:00
committed by Dylan Hunn
parent a47794272b
commit 427beff0ec
4 changed files with 34 additions and 19 deletions
+8 -8
View File
@@ -42,7 +42,7 @@ jasmine_node_test(
name = "extract_i18n",
bootstrap = ["//tools/testing:node_es5"],
data = [
"//packages/core:npm_package",
"@npm//@angular/core-12",
],
tags = [
# Disabled as the tests pertain to the old extraction tool only, whereas the Ivy extraction
@@ -51,8 +51,8 @@ jasmine_node_test(
],
deps = [
":extract_i18n_lib",
"//packages/common:npm_package",
"//packages/core",
"@npm//@angular/common-12",
"@npm//minimist",
],
)
@@ -77,10 +77,10 @@ jasmine_node_test(
timeout = "long", # 900 seconds
bootstrap = ["//tools/testing:node_es5"],
data = [
"//packages/common:npm_package",
"//packages/core:npm_package",
"//packages/platform-browser:npm_package",
"//packages/router:npm_package",
"@npm//@angular/common-12",
"@npm//@angular/core-12",
"@npm//@angular/platform-browser-12",
"@npm//@angular/router-12",
],
tags = [
# Disabled as these tests are specific to the old ngc compiler, and not ngtsc which has its
@@ -116,7 +116,7 @@ jasmine_node_test(
name = "perform_watch",
bootstrap = ["//tools/testing:node_es5"],
data = [
"//packages/core:npm_package",
"@npm//@angular/core-12",
],
deps = [
":perform_watch_lib",
@@ -143,7 +143,7 @@ jasmine_node_test(
name = "perform_compile",
bootstrap = ["//tools/testing:node_es5"],
data = [
"//packages/core:npm_package",
"@npm//@angular/core-12",
],
deps = [
":perform_compile_lib",
@@ -17,8 +17,8 @@ jasmine_node_test(
timeout = "long", # 900 seconds
bootstrap = ["//tools/testing:node_es5"],
data = [
"//packages/common:npm_package",
"//packages/core:npm_package",
"@npm//@angular/common-12",
"@npm//@angular/core-12",
],
tags = [
# Disabled as these tests pertain to typechecking in the old ngc compiler. The Ivy ngtsc
+21 -6
View File
@@ -128,14 +128,29 @@ export function setupBazelTo(tmpDirPath: string) {
fs.mkdirSync(nodeModulesPath);
fs.mkdirSync(angularDirectory);
getAngularPackagesFromRunfiles().forEach(({pkgPath, name}) => {
fs.symlinkSync(pkgPath, path.join(angularDirectory, name), 'junction');
});
function linkNpmArtifact(artifact: string, target: string = artifact) {
try {
const source = resolveNpmTreeArtifact(`npm/node_modules/${artifact}`);
const dest = path.join(nodeModulesPath, target);
fs.symlinkSync(source, dest, 'junction');
} catch (e) {
// Allow a module to be missing as some Bazel targets do not need all artifacts.
if (e.code !== 'MODULE_NOT_FOUND') throw e;
}
}
// Link @angular packages. These reference the v12 packages from NPM as the ViewEngine tests
// can no longer depend on `npm_package` Bazel targets, given that the `ng_module` to produce
// them is no longer capable of producing ViewEngine packages. As a result, the `npm_package`
// outputs end up being compiled using Ivy partial compilation format which is not suitable to be
// used in ViewEngine ngc tests.
linkNpmArtifact('@angular/core-12', '@angular/core');
linkNpmArtifact('@angular/common-12', '@angular/common');
linkNpmArtifact('@angular/router-12', '@angular/router');
linkNpmArtifact('@angular/platform-browser-12', '@angular/platform-browser');
// Link typescript
const typeScriptSource = resolveNpmTreeArtifact('npm/node_modules/typescript');
const typescriptDest = path.join(nodeModulesPath, 'typescript');
fs.symlinkSync(typeScriptSource, typescriptDest, 'junction');
linkNpmArtifact('typescript');
// Link "rxjs" if it has been set up as a runfile. "rxjs" is linked optionally because
// not all compiler-cli tests need "rxjs" set up.
@@ -22,9 +22,9 @@ jasmine_node_test(
timeout = "long", # 900 seconds
bootstrap = ["//tools/testing:node_es5"],
data = [
"//packages/common:npm_package",
"//packages/core:npm_package",
"//packages/router:npm_package",
"@npm//@angular/common-12",
"@npm//@angular/core-12",
"@npm//@angular/router-12",
],
tags = [
# Disabled as these tests pertain to the old compiler and not ngtsc, which doesn't use any