Skip to content

Commit e7521ac

Browse files
jelbournkara
authored andcommitted
chore: add script to generate ivy test blacklist (#14877)
1 parent dc7b97a commit e7521ac

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

scripts/ivy/generate-blacklist.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
58+
// clang-format off
59+
// tslint:disable
60+
61+
window.testBlacklist = ${JSON.stringify(generatedBlacklist, null, 2)};
62+
// clang-format on`;
63+
64+
// Write that sucker to dist.
65+
fs.writeFileSync('dist/angular_material_test_blacklist.js', output, 'utf-8');
66+
67+
68+
/**
69+
* Given a karma test result, get a blacklist entry in the form
70+
* {[full test name]: {error: '...', notes: '...'}}
71+
*/
72+
function getFullFailure(result, fullName = '') {
73+
if (result['log']) {
74+
if (result['log'].length) {
75+
return {[fullName]: {
76+
error: result['log'][0].split('\n')[0],
77+
notes: 'Unknown',
78+
}};
79+
}
80+
81+
return {};
82+
}
83+
84+
let failures = {};
85+
for (const key of Object.keys(result)) {
86+
failures = {...failures, ...getFullFailure(result[key], fullName + ' ' + key)};
87+
}
88+
89+
return failures;
90+
}

0 commit comments

Comments
 (0)