diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2014-03-23 06:30:35 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2014-03-23 06:30:35 +0400 |
commit | 561be3dad6bb6db04f2afb3d2820beebac91d000 (patch) | |
tree | 39358704dfd4712d19f202032991d1b81f3a7d20 /tests/lib | |
parent | 366d5450f1de5c8e3a53c8e50fa09ee67538d8b0 (diff) |
Tweak screenshot test output and allow global command line options to be overridden by individual test specs.
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/screenshot-testing/support/app.js | 18 | ||||
-rw-r--r-- | tests/lib/screenshot-testing/support/test-environment.js | 29 |
2 files changed, 45 insertions, 2 deletions
diff --git a/tests/lib/screenshot-testing/support/app.js b/tests/lib/screenshot-testing/support/app.js index 2f234a7bbf..fbbcd20722 100644 --- a/tests/lib/screenshot-testing/support/app.js +++ b/tests/lib/screenshot-testing/support/app.js @@ -108,14 +108,32 @@ Application.prototype.loadTestModules = function () { var fixture = typeof suite.fixture === 'undefined' ? 'UITestFixture' : suite.fixture; suite.beforeAll(function (done) { + var oldOptions = JSON.parse(JSON.stringify(options)); + if (suite.optionsOverride) { + for (var key in suite.optionsOverride) { + options[key] = suite.optionsOverride[key]; + } + } + testEnvironment.setupFixture(fixture, done); + + options = oldOptions; }); // move to before other hooks suite._beforeAll.unshift(suite._beforeAll.pop()); suite.afterAll(function (done) { + var oldOptions = JSON.parse(JSON.stringify(options)); + if (suite.optionsOverride) { + for (var key in suite.optionsOverride) { + options[key] = suite.optionsOverride[key]; + } + } + testEnvironment.teardownFixture(fixture, done); + + options = oldOptions; }); }); }; diff --git a/tests/lib/screenshot-testing/support/test-environment.js b/tests/lib/screenshot-testing/support/test-environment.js index 9d05448499..35e19eea89 100644 --- a/tests/lib/screenshot-testing/support/test-environment.js +++ b/tests/lib/screenshot-testing/support/test-environment.js @@ -113,16 +113,29 @@ TestingEnvironment.prototype.setupFixture = function (fixtureClass, done) { var child = require('child_process').spawn(config.php, processArgs); + var firstLine = true; child.stdout.on("data", function (data) { - fs.write("/dev/stdout", data, "w"); + if (firstLine) { + data = " " + data; + firstLine = false; + } + + fs.write("/dev/stdout", data.replace(/\n/g, "\n "), "w"); }); child.stderr.on("data", function (data) { + if (firstLine) { + data = " " + data; + firstLine = false; + } + fs.write("/dev/stderr", data, "w"); }); child.on("exit", function (code) { testEnvironment.reload(); + + console.log(); if (code) { done(new Error("Failed to setup fixture " + fixtureClass + " (error code = " + code + ")")); @@ -142,17 +155,29 @@ TestingEnvironment.prototype.teardownFixture = function (fixtureClass, done) { return; } + console.log(); console.log(" Tearing down fixture " + fixtureClass + "..."); var teardownFile = path.join("./support", "teardownDatabase.php"), child = require('child_process').spawn( config.php, [teardownFile, "--server=" + JSON.stringify(config.phpServer), "--fixture=" + fixtureClass]); + var firstLine = true; child.stdout.on("data", function (data) { - fs.write("/dev/stdout", data, "w"); + if (firstLine) { + data = " " + data; + firstLine = false; + } + + fs.write("/dev/stdout", data.replace(/\n/g, "\n "), "w"); }); child.stderr.on("data", function (data) { + if (firstLine) { + data = " " + data; + firstLine = false; + } + fs.write("/dev/stderr", data, "w"); }); |