Previously, running the entire template test suite took about twelve minutes. In order to speed this up, test top level directories as individual test targets that can be run in parallel. It now takes about 4 minutes to run everything (on a Macbook Pro) Documentation updated as well, as commands have changed. Change-Id: Ie815a7fafc64b442f36b92d0d295f8cfbe12cc0d
97 lines
2.3 KiB
JavaScript
97 lines
2.3 KiB
JavaScript
const fs = require('fs');
|
|
const twinkie = require('fried-twinkie');
|
|
|
|
const EXTERN_NAMES = [
|
|
'Gerrit',
|
|
'GrAnnotation',
|
|
'GrAttributeHelper',
|
|
'GrChangeActionsInterface',
|
|
'GrChangeReplyInterface',
|
|
'GrDiffBuilder',
|
|
'GrDiffBuilderImage',
|
|
'GrDiffBuilderSideBySide',
|
|
'GrDiffBuilderUnified',
|
|
'GrDiffGroup',
|
|
'GrDiffLine',
|
|
'GrDomHooks',
|
|
'GrEtagDecorator',
|
|
'GrGapiAuth',
|
|
'GrGerritAuth',
|
|
'GrLinkTextParser',
|
|
'GrPluginEndpoints',
|
|
'GrRangeNormalizer',
|
|
'GrReporting',
|
|
'GrReviewerUpdatesParser',
|
|
'GrThemeApi',
|
|
'moment',
|
|
'page',
|
|
'util'];
|
|
|
|
fs.readdir('./polygerrit-ui/temp/behaviors/', (err, data) => {
|
|
if (err) {
|
|
console.log('error /polygerrit-ui/temp/behaviors/ directory');
|
|
}
|
|
const behaviors = data;
|
|
const externs = [];
|
|
|
|
for (const behavior of behaviors) {
|
|
externs.push({
|
|
path: `./polygerrit-ui/temp/behaviors/${behavior}`,
|
|
src: fs.readFileSync(
|
|
`./polygerrit-ui/temp/behaviors/${behavior}`, 'utf-8'),
|
|
});
|
|
}
|
|
|
|
let mappings = JSON.parse(fs.readFileSync(
|
|
`./polygerrit-ui/temp/map.json`, 'utf-8'));
|
|
|
|
// The directory is passed as arg2 by the test target.
|
|
const directory = process.argv[2];
|
|
if (directory) {
|
|
const mappingSpecificDirectory = {};
|
|
|
|
for (key of Object.keys(mappings)) {
|
|
if (directory === mappings[key].directory) {
|
|
mappingSpecificDirectory[key] = mappings[key];
|
|
}
|
|
}
|
|
mappings = mappingSpecificDirectory;
|
|
}
|
|
|
|
// If a particular file was passed by the user, don't test everything.
|
|
const file = process.argv[3];
|
|
if (file) {
|
|
const mappingSpecificFile = {};
|
|
for (key of Object.keys(mappings)) {
|
|
if (key.includes(file)) {
|
|
mappingSpecificFile[key] = mappings[key];
|
|
}
|
|
}
|
|
mappings = mappingSpecificFile;
|
|
}
|
|
|
|
externs.push({
|
|
path: 'custom-externs.js',
|
|
src: '/** @externs */' +
|
|
EXTERN_NAMES.map( name => { return `var ${name};`; }).join(' '),
|
|
});
|
|
|
|
const promises = [];
|
|
|
|
for (key of Object.keys(mappings)) {
|
|
if (mappings[key].html && mappings[key].js) {
|
|
promises.push(twinkie.checkTemplate(
|
|
mappings[key].html,
|
|
mappings[key].js,
|
|
'polygerrit.' + mappings[key].package,
|
|
externs
|
|
));
|
|
}
|
|
}
|
|
|
|
Promise.all(promises).then(() => {}, joinedErrors => {
|
|
if (joinedErrors) {
|
|
process.exit(1);
|
|
}
|
|
});
|
|
}); |