Skip to content

Commit d8a445d

Browse files
devversionandrewseguin
authored andcommitted
build: add blocklist to disable individual tests in the project (#16833)
Similarly to what we had in the `ivy-2019` branch for disabling individual tests, we now need something similar that works with Bazel. This is necessary because there are still breaking changes that could land in the framework repository and break individual tests of the component repository. Framework now needs a way to disable those specific tests until the components repository migrated the broken tests (this can be delayed by weeks since the breaking change is not necessarily yet released) (cherry picked from commit 18b9ef3)
1 parent 0ad0051 commit d8a445d

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

test/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ ts_library(
77
name = "angular_test_init",
88
testonly = True,
99
# This file *must* end with "spec" in order for "karma_web_test_suite" to load it.
10-
srcs = ["angular-test-init-spec.ts"],
10+
srcs = [
11+
"angular-test-init-spec.ts",
12+
"test-blocklist.ts",
13+
],
1114
deps = [
1215
"@npm//@angular/core",
1316
"@npm//@angular/platform-browser-dynamic",

test/angular-test-init-spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
BrowserDynamicTestingModule,
44
platformBrowserDynamicTesting,
55
} from '@angular/platform-browser-dynamic/testing';
6+
import {testBlocklist} from './test-blocklist';
67

78
/*
89
* Common setup / initialization for all unit tests in Angular Material and CDK.
@@ -54,3 +55,16 @@ function patchTestBedToDestroyFixturesAfterEveryTest(testBedInstance: TestBed) {
5455
// https://github.com/angular/angular/blob/master/packages/core/testing/src/before_each.ts#L25
5556
afterEach(() => testBedInstance.resetTestingModule());
5657
}
58+
59+
60+
// Filter out any tests explicitly given in the blocklist. The blocklist is empty in the
61+
// components repository, but the file will be overwritten if the framework repository runs
62+
// the Angular component test suites against the latest snapshots. This is helpful because
63+
// sometimes breaking changes that break individual tests land in the framework repository.
64+
// It should be possible to disable these tests until the component repository migrated the
65+
// broken tests once the breaking change is released.
66+
(jasmine.getEnv() as any).configure({
67+
specFilter: function(spec: jasmine.Spec) {
68+
return !testBlocklist || !testBlocklist[spec.getFullName()];
69+
}
70+
});

test/test-blocklist.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
/**
10+
* List of tests that should not run in the Angular component test suites. This should
11+
* be empty in the components repository, but the file will be overwritten if the framework
12+
* repository runs the Angular component test suites against the latest snapshots. This is
13+
* helpful because sometimes breaking changes that break individual tests land in the framework
14+
* repository. It should be possible to disable these tests until the component repository
15+
* migrated the broken tests.
16+
*/
17+
export const testBlocklist: {[testName: string]: Object} = {};

0 commit comments

Comments
 (0)