build: move _testing_init into tools; limit web_test concurrency (#21053)

PR Close #21053
This commit is contained in:
Miško Hevery
2017-12-18 15:37:05 -08:00
committed by Igor Minar
parent 533a010b28
commit ae97920fe2
17 changed files with 63 additions and 51 deletions

View File

@ -1,27 +0,0 @@
package(default_visibility = ["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
ts_library(
name = "browser",
testonly = 1,
srcs = ["init_browser_spec.ts"],
tsconfig = "//packages:tsconfig",
deps = [
"//packages/core/testing",
"//packages/platform-browser-dynamic/testing",
"//packages/platform-browser/animations",
],
)
ts_library(
name = "node",
testonly = 1,
srcs = ["init_node_spec.ts"],
tsconfig = "//packages:tsconfig",
deps = [
"//packages/core/testing",
"//packages/platform-server",
"//packages/platform-server/testing",
],
)

View File

@ -1,18 +0,0 @@
/**
* @license
* Copyright Google Inc. 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 {TestBed} from '@angular/core/testing';
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
TestBed.initTestEnvironment(
[BrowserDynamicTestingModule, NoopAnimationsModule], platformBrowserDynamicTesting());
(window as any).isNode = false;
(window as any).isBrowser = true;
(window as any).global = window;

View File

@ -1,44 +0,0 @@
/**
* @license
* Copyright Google Inc. 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 'zone.js/dist/zone-node.js';
import 'zone.js/dist/long-stack-trace-zone.js';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test.js';
import 'zone.js/dist/async-test.js';
import 'zone.js/dist/fake-async-test.js';
import 'reflect-metadata/Reflect';
// This hack is needed to get jasmine, node and zone working inside bazel.
// 1) we load `jasmine-core` which contains the ENV: it, describe etc...
const jasmineCore: any = require('jasmine-core');
// 2) We create an instance of `jasmine` ENV.
const patchedJasmine = jasmineCore.boot(jasmineCore);
// 3) Save the `jasmine` into global so that `zone.js/dist/jasmine-patch.js` can get a hold of it to
// patch it.
(global as any)['jasmine'] = patchedJasmine;
// 4) Change the `jasmine-core` to make sure that all subsequent jasmine's have the same ENV,
// otherwise the patch will not work.
// This is needed since Bazel creates a new instance of jasmine and it's ENV and we want to make
// sure it gets the same one.
jasmineCore.boot = function() {
return patchedJasmine;
};
// 5) Patch jasmine ENV with code which understands ProxyZone.
import 'zone.js/dist/jasmine-patch.js';
(global as any).isNode = true;
(global as any).isBrowser = false;
// Init TestBed
import {TestBed} from '@angular/core/testing';
import {ServerTestingModule, platformServerTesting} from '@angular/platform-server/testing/src/server';
import {DominoAdapter} from '@angular/platform-server/src/domino_adapter';
TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting());
DominoAdapter.makeCurrent();

View File

@ -23,21 +23,21 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -37,27 +37,27 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
# dissable since tests are running but not yet passing
tags = ["manual"],
deps = [
":test_lib",
":test_node_only_lib",
"//packages/_testing_init:node",
"//packages/core",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# dissable since tests are running but not yet passing
tags = ["manual"],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -51,24 +51,24 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
":test_node_only_lib",
"//packages/_testing_init:node",
"//packages/platform-server",
"//packages/platform-server/testing",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -18,21 +18,23 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# "exclusive" - a work around for circle CI to prevent too many concurrent tests. :-()
tags = ["exclusive"],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -19,21 +19,23 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# "exclusive" - a work around for circle CI to prevent too many concurrent tests. :-()
tags = ["exclusive"],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -15,11 +15,11 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
# dissable since tests are running but not yet passing
tags = ["manual"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)

View File

@ -19,25 +19,25 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
# dissable since tests are running but not yet passing
tags = ["manual"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# dissable since tests are running but not yet passing
tags = ["manual"],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -25,25 +25,25 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
# dissable since tests are running but not yet passing
tags = ["manual"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# dissable since tests are running but not yet passing
tags = ["manual"],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -25,9 +25,9 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)

View File

@ -21,21 +21,21 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -22,21 +22,21 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -20,21 +20,21 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//packages/_testing_init:node",
"//tools/testing:node",
],
)
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:web_test_bootstrap_scripts",
],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)

View File

@ -22,13 +22,14 @@ ts_library(
ts_web_test(
name = "test_web",
bootstrap = [
"//:angular_bootstrap_scripts",
"//:node_modules/angular/angular.js",
"//:node_modules/angular-mocks/angular-mocks.js",
"//:web_test_bootstrap_scripts",
"//:angularjs",
],
# "exclusive" - a work around for circle CI to prevent too many concurrent tests. :-()
tags = ["exclusive"],
# do not sort
deps = [
"//packages/_testing_init:browser",
"//tools/testing:browser",
":test_lib",
],
)