[Pkg-javascript-commits] [pdf.js] 102/157: Add --testfilter (-t) flag to run a specific test
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 06:46:43 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit b627a1a0d916498493c1307339bc2bfb17a413ee
Author: Rob Wu <rob at robwu.nl>
Date: Sat Jul 11 11:26:53 2015 +0200
Add --testfilter (-t) flag to run a specific test
---
test/driver.js | 11 +++++++++--
test/test.js | 37 ++++++++++++++++++++++++++++++++++---
2 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/test/driver.js b/test/driver.js
index 5ffe556..aed80e3 100644
--- a/test/driver.js
+++ b/test/driver.js
@@ -132,6 +132,8 @@ var Driver = (function DriverClosure() {
this.appPath = parameters.path;
this.delay = (parameters.delay | 0) || 0;
this.inFlightRequests = 0;
+ this.testFilter = parameters.testFilter ?
+ JSON.parse(parameters.testFilter) : [];
// Create a working canvas
this.canvas = document.createElement('canvas');
@@ -163,6 +165,11 @@ var Driver = (function DriverClosure() {
if (r.readyState === 4) {
self._log('done\n');
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._nextTask();
}
@@ -422,9 +429,9 @@ var Driver = (function DriverClosure() {
_done: function Driver_done() {
if (this.inFlightRequests > 0) {
this.inflight.textContent = this.inFlightRequests;
- setTimeout(this._done(), WAITING_TIME);
+ setTimeout(this._done.bind(this), WAITING_TIME);
} else {
- setTimeout(this._quit(), WAITING_TIME);
+ setTimeout(this._quit.bind(this), WAITING_TIME);
}
},
diff --git a/test/test.js b/test/test.js
index f82a53d..aae5551 100644
--- a/test/test.js
+++ b/test/test.js
@@ -40,8 +40,9 @@ function parseOptions() {
.boolean(['help', 'masterMode', 'reftest', 'unitTest', 'fontTest',
'noPrompts', 'noDownload', 'downloadOnly'])
.string(['manifestFile', 'browser', 'browserManifestFile',
- 'port', 'statsFile', 'statsDelay'])
+ 'port', 'statsFile', 'statsDelay', 'testfilter'])
.alias('browser', 'b').alias('help', 'h').alias('masterMode', 'm')
+ .alias('testfilter', 't')
.describe('help', 'Show this help message')
.describe('masterMode', 'Run the script in master mode.')
.describe('noPrompts',
@@ -54,6 +55,10 @@ function parseOptions() {
'those found in resources/browser_manifests/')
.describe('reftest', 'Automatically start reftest showing comparison ' +
'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.')
.default('port', 8000)
.describe('unitTest', 'Run the unit tests.')
@@ -85,6 +90,8 @@ function parseOptions() {
yargs.showHelp();
process.exit(0);
}
+ result.testfilter = Array.isArray(result.testfilter) ?
+ result.testfilter : [result.testfilter];
return result;
}
@@ -254,7 +261,10 @@ function startRefTest(masterMode, showRefImages) {
}
var startTime;
- var manifest = JSON.parse(fs.readFileSync(options.manifestFile));
+ var manifest = getTestManifest();
+ if (!manifest) {
+ return;
+ }
if (options.noDownload) {
checkRefsTmp();
} else {
@@ -274,6 +284,26 @@ function handleSessionTimeout(session) {
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) {
var taskId = task.id;
var refSnapshotDir = path.join(refsDir, os.platform(), browser, taskId);
@@ -616,6 +646,7 @@ function startBrowsers(url, initSessionCallback) {
var startUrl = getServerBaseAddress() + url +
'?browser=' + encodeURIComponent(b.name) +
'&manifestFile=' + encodeURIComponent('/test/' + options.manifestFile) +
+ '&testFilter=' + JSON.stringify(options.testfilter) +
'&path=' + encodeURIComponent(b.path) +
'&delay=' + options.statsDelay +
'&masterMode=' + options.masterMode;
@@ -677,7 +708,7 @@ function closeSession(browser) {
function ensurePDFsDownloaded(callback) {
var downloadUtils = require('./downloadutils.js');
- var manifest = JSON.parse(fs.readFileSync(options.manifestFile));
+ var manifest = getTestManifest();
downloadUtils.downloadManifestFiles(manifest, function () {
downloadUtils.verifyManifestFiles(manifest, function (hasErrors) {
if (hasErrors) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list