Skip to content

Commit 3295c34

Browse files
committed
chore: add script to generate ivy test blacklist
1 parent e60bbd2 commit 3295c34

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

scripts/ivy/generate-blacklist.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env node
2+
3+
const path = require('path');
4+
const fs = require('fs');
5+
6+
const karmaOutput = JSON.parse(fs.readFileSync('/tmp/karma-result.json'));
7+
8+
9+
let generatedBlacklist = {};
10+
for (const desc of Object.keys(karmaOutput)) {
11+
generatedBlacklist = {...generatedBlacklist, ...getFullFailure(karmaOutput[desc], desc)};
12+
}
13+
14+
// We want to "remember" the notes from the current blacklist on angular/angular unless the
15+
// error message has changed. We need to know where the local angular/angular repo is.
16+
const angularRepoPath = process.argv[2];
17+
if (!angularRepoPath) {
18+
console.error('Please provide the path to your local angular/angular repo as the first argument');
19+
process.exit(1);
20+
}
21+
22+
// Read the contents of the previous blacklist.
23+
const previousBlacklistPath =
24+
path.join(angularRepoPath, 'tools', 'material-ci', 'angular_material_test_blacklist.js');
25+
const previousBlacklistContent = fs.readFileSync(previousBlacklistPath, 'utf-8');
26+
27+
// Because the blacklist is a javascript file meant to be executed, we just actually execute it with
28+
// eval. Create a dummy `window` for it to add to.
29+
const window = {};
30+
eval(previousBlacklistContent);
31+
const previousBlacklist = window.testBlacklist;
32+
33+
// Copy any existing test notes.
34+
for (const testName of Object.keys(generatedBlacklist)) {
35+
if (previousBlacklist[testName] &&
36+
generatedBlacklist[testName].error === previousBlacklist[testName].error) {
37+
generatedBlacklist[testName].notes = previousBlacklist[testName].notes;
38+
}
39+
}
40+
41+
// Format the output as an executable javascript program.
42+
const output =
43+
`/**
44+
* @license
45+
* Copyright Google Inc. All Rights Reserved.
46+
*
47+
* Use of this source code is governed by an MIT-style license that can be
48+
* found in the LICENSE file at https://angular.io/license
49+
*/
50+
51+
/**
52+
* Blacklist of unit tests from angular/material2 with ivy that are skipped when running on
53+
* angular/angular. As bugs are resolved, items should be removed from this blacklist.
54+
*
55+
* The \`notes\` section should be used to keep track of specific issues associated with the failures.
56+
*
57+
* TODO(jelbourn): it's not currently straightforward to regenerate this blacklist from scratch.
58+
*/
59+
60+
// clang-format off
61+
// tslint:disable
62+
63+
window.testBlacklist = ${JSON.stringify(generatedBlacklist, null, 2)};
64+
// clang-format on`;
65+
66+
// Write that sucker to dist.
67+
fs.writeFileSync('dist/angular_material_test_blacklist.js', output, 'utf-8');
68+
69+
70+
/**
71+
* Given a karma test result, get a blacklist entry in the form
72+
* {[full test name]: {error: '...', notes: '...'}}
73+
*/
74+
function getFullFailure(result, fullName = '') {
75+
if (result['log']) {
76+
if (result['log'].length) {
77+
return {[fullName]: {
78+
error: result['log'][0].split('\n')[0],
79+
notes: 'Unknown',
80+
}};
81+
}
82+
83+
return {};
84+
}
85+
86+
let failures = {};
87+
for (const key of Object.keys(result)) {
88+
failures = {...failures, ...getFullFailure(result[key], fullName + ' ' + key)};
89+
}
90+
91+
return failures;
92+
}

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,6 +4351,11 @@ ftp@~0.3.10:
43514351
readable-stream "1.1.x"
43524352
xregexp "2.0.0"
43534353

4354+
fun-map@^3.3.1:
4355+
version "3.3.1"
4356+
resolved "https://registry.yarnpkg.com/fun-map/-/fun-map-3.3.1.tgz#6415fde3b93ad58f9ee9566236cff3e3c64b94cb"
4357+
integrity sha1-ZBX947k61Y+e6VZiNs/z48ZLlMs=
4358+
43544359
gauge@~2.7.3:
43554360
version "2.7.4"
43564361
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
@@ -6420,6 +6425,13 @@ karma-jasmine@^2.0.1:
64206425
dependencies:
64216426
jasmine-core "^3.3"
64226427

6428+
karma-json-result-reporter@^1.0.0:
6429+
version "1.0.0"
6430+
resolved "https://registry.yarnpkg.com/karma-json-result-reporter/-/karma-json-result-reporter-1.0.0.tgz#9bfaa17d610470d08556e48ccbaf64d7950c7255"
6431+
integrity sha1-m/qhfWEEcNCFVuSMy69k15UMclU=
6432+
dependencies:
6433+
fun-map "^3.3.1"
6434+
64236435
karma-parallel@^0.3.0:
64246436
version "0.3.1"
64256437
resolved "https://registry.yarnpkg.com/karma-parallel/-/karma-parallel-0.3.1.tgz#781876e5992b2781619e762f3e04dcbf85f47fa1"

0 commit comments

Comments
 (0)