Allow tests to be ignored by specific browsers

This commit is contained in:
MoyuScript
2017-08-11 22:22:10 +08:00
parent f2286cc299
commit 8adf7f8521
4 changed files with 264 additions and 206 deletions

View File

@ -7,10 +7,16 @@ const slash = require('slash');
const parseRefTest = require('./parse-reftest');
const outputPath = 'tests/reftests.js';
const ignoredTests = [
'/tests/reftests/background/radial-gradient.html',
'/tests/reftests/text/chinese.html'
];
const ignoredTests = fs
.readFileSync(path.resolve(__dirname, `../tests/reftests/ignore.txt`))
.toString()
.split('\n')
.filter(l => l.length)
.reduce((acc, l) => {
const m = l.match(/^(\[(.+)\])?(.+)$/i);
acc[m[3]] = m[2] ? m[2].split(',') : [];
return acc;
}, {});
glob(
'../tests/reftests/**/*.html',
@ -27,8 +33,7 @@ glob(
const testList = files.reduce((acc, filename) => {
const refTestFilename = path.resolve(__dirname, filename.replace(/\.html$/, '.txt'));
const name = `/${slash(path.relative('../', filename))}`;
if (ignoredTests.indexOf(name) === -1) {
console.log(name);
if (!Array.isArray(ignoredTests[name]) || ignoredTests[name].length) {
acc[name] = fs.existsSync(refTestFilename)
? parseRefTest(fs.readFileSync(refTestFilename).toString())
: null;
@ -36,12 +41,11 @@ glob(
console.log(`IGNORED: ${name}`);
}
return acc;
}, {});
fs.writeFileSync(
path.resolve(__dirname, `../${outputPath}`),
`module.exports = ${JSON.stringify(testList, null, 4)};`
`module.exports = ${JSON.stringify({testList, ignoredTests}, null, 4)};`
);
console.log(`${outputPath} updated`);

View File

@ -10,7 +10,7 @@ app.use('/', express.static(path.resolve(__dirname, '../')));
const listener = app.listen(0, () => {
async function run() {
const chromeless = new Chromeless();
const tests = Object.keys(reftests);
const tests = Object.keys(reftests.testList);
let i = 0;
while (tests[i]) {
const filename = tests[i];