Add --testfilter (-t) flag to run a specific test
This commit is contained in:
parent
62cf6536a2
commit
b627a1a0d9
@ -132,6 +132,8 @@ var Driver = (function DriverClosure() {
|
|||||||
this.appPath = parameters.path;
|
this.appPath = parameters.path;
|
||||||
this.delay = (parameters.delay | 0) || 0;
|
this.delay = (parameters.delay | 0) || 0;
|
||||||
this.inFlightRequests = 0;
|
this.inFlightRequests = 0;
|
||||||
|
this.testFilter = parameters.testFilter ?
|
||||||
|
JSON.parse(parameters.testFilter) : [];
|
||||||
|
|
||||||
// Create a working canvas
|
// Create a working canvas
|
||||||
this.canvas = document.createElement('canvas');
|
this.canvas = document.createElement('canvas');
|
||||||
@ -163,6 +165,11 @@ var Driver = (function DriverClosure() {
|
|||||||
if (r.readyState === 4) {
|
if (r.readyState === 4) {
|
||||||
self._log('done\n');
|
self._log('done\n');
|
||||||
self.manifest = JSON.parse(r.responseText);
|
self.manifest = JSON.parse(r.responseText);
|
||||||
|
if (self.testFilter && self.testFilter.length) {
|
||||||
|
self.manifest = self.manifest.filter(function(item) {
|
||||||
|
return self.testFilter.indexOf(item.id) !== -1;
|
||||||
|
});
|
||||||
|
}
|
||||||
self.currentTask = 0;
|
self.currentTask = 0;
|
||||||
self._nextTask();
|
self._nextTask();
|
||||||
}
|
}
|
||||||
@ -422,9 +429,9 @@ var Driver = (function DriverClosure() {
|
|||||||
_done: function Driver_done() {
|
_done: function Driver_done() {
|
||||||
if (this.inFlightRequests > 0) {
|
if (this.inFlightRequests > 0) {
|
||||||
this.inflight.textContent = this.inFlightRequests;
|
this.inflight.textContent = this.inFlightRequests;
|
||||||
setTimeout(this._done(), WAITING_TIME);
|
setTimeout(this._done.bind(this), WAITING_TIME);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(this._quit(), WAITING_TIME);
|
setTimeout(this._quit.bind(this), WAITING_TIME);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
37
test/test.js
37
test/test.js
@ -40,8 +40,9 @@ function parseOptions() {
|
|||||||
.boolean(['help', 'masterMode', 'reftest', 'unitTest', 'fontTest',
|
.boolean(['help', 'masterMode', 'reftest', 'unitTest', 'fontTest',
|
||||||
'noPrompts', 'noDownload', 'downloadOnly'])
|
'noPrompts', 'noDownload', 'downloadOnly'])
|
||||||
.string(['manifestFile', 'browser', 'browserManifestFile',
|
.string(['manifestFile', 'browser', 'browserManifestFile',
|
||||||
'port', 'statsFile', 'statsDelay'])
|
'port', 'statsFile', 'statsDelay', 'testfilter'])
|
||||||
.alias('browser', 'b').alias('help', 'h').alias('masterMode', 'm')
|
.alias('browser', 'b').alias('help', 'h').alias('masterMode', 'm')
|
||||||
|
.alias('testfilter', 't')
|
||||||
.describe('help', 'Show this help message')
|
.describe('help', 'Show this help message')
|
||||||
.describe('masterMode', 'Run the script in master mode.')
|
.describe('masterMode', 'Run the script in master mode.')
|
||||||
.describe('noPrompts',
|
.describe('noPrompts',
|
||||||
@ -54,6 +55,10 @@ function parseOptions() {
|
|||||||
'those found in resources/browser_manifests/')
|
'those found in resources/browser_manifests/')
|
||||||
.describe('reftest', 'Automatically start reftest showing comparison ' +
|
.describe('reftest', 'Automatically start reftest showing comparison ' +
|
||||||
'test failures, if there are any.')
|
'test failures, if there are any.')
|
||||||
|
.describe('testfilter', 'Run specific reftest(s).')
|
||||||
|
.default('testfilter', [])
|
||||||
|
.example('$0 --b=firefox -t=issue5567 -t=issue5909',
|
||||||
|
'Run the reftest identified by issue5567 and issue5909 in Firefox.')
|
||||||
.describe('port', 'The port the HTTP server should listen on.')
|
.describe('port', 'The port the HTTP server should listen on.')
|
||||||
.default('port', 8000)
|
.default('port', 8000)
|
||||||
.describe('unitTest', 'Run the unit tests.')
|
.describe('unitTest', 'Run the unit tests.')
|
||||||
@ -85,6 +90,8 @@ function parseOptions() {
|
|||||||
yargs.showHelp();
|
yargs.showHelp();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
result.testfilter = Array.isArray(result.testfilter) ?
|
||||||
|
result.testfilter : [result.testfilter];
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +261,10 @@ function startRefTest(masterMode, showRefImages) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var startTime;
|
var startTime;
|
||||||
var manifest = JSON.parse(fs.readFileSync(options.manifestFile));
|
var manifest = getTestManifest();
|
||||||
|
if (!manifest) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (options.noDownload) {
|
if (options.noDownload) {
|
||||||
checkRefsTmp();
|
checkRefsTmp();
|
||||||
} else {
|
} else {
|
||||||
@ -274,6 +284,26 @@ function handleSessionTimeout(session) {
|
|||||||
closeSession(browser);
|
closeSession(browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTestManifest() {
|
||||||
|
var manifest = JSON.parse(fs.readFileSync(options.manifestFile));
|
||||||
|
|
||||||
|
var testFilter = options.testfilter.slice(0);
|
||||||
|
if (testFilter.length) {
|
||||||
|
manifest = manifest.filter(function(item) {
|
||||||
|
var i = testFilter.indexOf(item.id);
|
||||||
|
if (i !== -1) {
|
||||||
|
testFilter.splice(i, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (testFilter.length) {
|
||||||
|
console.error('Unrecognized test IDs: ' + testFilter.join(' '));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return manifest;
|
||||||
|
}
|
||||||
|
|
||||||
function checkEq(task, results, browser, masterMode) {
|
function checkEq(task, results, browser, masterMode) {
|
||||||
var taskId = task.id;
|
var taskId = task.id;
|
||||||
var refSnapshotDir = path.join(refsDir, os.platform(), browser, taskId);
|
var refSnapshotDir = path.join(refsDir, os.platform(), browser, taskId);
|
||||||
@ -616,6 +646,7 @@ function startBrowsers(url, initSessionCallback) {
|
|||||||
var startUrl = getServerBaseAddress() + url +
|
var startUrl = getServerBaseAddress() + url +
|
||||||
'?browser=' + encodeURIComponent(b.name) +
|
'?browser=' + encodeURIComponent(b.name) +
|
||||||
'&manifestFile=' + encodeURIComponent('/test/' + options.manifestFile) +
|
'&manifestFile=' + encodeURIComponent('/test/' + options.manifestFile) +
|
||||||
|
'&testFilter=' + JSON.stringify(options.testfilter) +
|
||||||
'&path=' + encodeURIComponent(b.path) +
|
'&path=' + encodeURIComponent(b.path) +
|
||||||
'&delay=' + options.statsDelay +
|
'&delay=' + options.statsDelay +
|
||||||
'&masterMode=' + options.masterMode;
|
'&masterMode=' + options.masterMode;
|
||||||
@ -677,7 +708,7 @@ function closeSession(browser) {
|
|||||||
|
|
||||||
function ensurePDFsDownloaded(callback) {
|
function ensurePDFsDownloaded(callback) {
|
||||||
var downloadUtils = require('./downloadutils.js');
|
var downloadUtils = require('./downloadutils.js');
|
||||||
var manifest = JSON.parse(fs.readFileSync(options.manifestFile));
|
var manifest = getTestManifest();
|
||||||
downloadUtils.downloadManifestFiles(manifest, function () {
|
downloadUtils.downloadManifestFiles(manifest, function () {
|
||||||
downloadUtils.verifyManifestFiles(manifest, function (hasErrors) {
|
downloadUtils.verifyManifestFiles(manifest, function (hasErrors) {
|
||||||
if (hasErrors) {
|
if (hasErrors) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user