Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests/lib
diff options
context:
space:
mode:
authordiosmosis <benakamoorthi@fastmail.fm>2014-03-30 20:23:31 +0400
committerdiosmosis <benakamoorthi@fastmail.fm>2014-03-30 20:23:31 +0400
commit5f88fe08526fab1f2e71d4deccadb3cfa7faaaff (patch)
tree22dd7d50104d5e8d904423b02f92479dc47e3825 /tests/lib
parenta6cd4c3a5b42e756e5fbcfe1d274b0510a66b1a1 (diff)
Fix diff generation in screenshot tests for plugins (paths were not different for plugin tests).
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/screenshot-testing/support/app.js23
-rw-r--r--tests/lib/screenshot-testing/support/chai-extras.js3
-rw-r--r--tests/lib/screenshot-testing/support/diff-viewer.js2
3 files changed, 15 insertions, 13 deletions
diff --git a/tests/lib/screenshot-testing/support/app.js b/tests/lib/screenshot-testing/support/app.js
index 71f1c73ff2..9aa89c7efd 100644
--- a/tests/lib/screenshot-testing/support/app.js
+++ b/tests/lib/screenshot-testing/support/app.js
@@ -35,7 +35,7 @@ var walk = function (dir, pattern, result) {
var Application = function () {
this.runner = null;
- this.diffViewerGenerator = new DiffViewerGenerator(path.join(uiTestsDir, config.screenshotDiffDir));
+ this.diffViewerGenerator = new DiffViewerGenerator();
};
Application.prototype.printHelpAndExit = function () {
@@ -69,6 +69,7 @@ Application.prototype.init = function () {
describe = function () {
var suite = oldDescribe.apply(null, arguments);
suite.baseDirectory = app.currentModulePath.match(/\/plugins\//) ? path.dirname(app.currentModulePath) : uiTestsDir;
+ suite.diffDir = path.join(suite.baseDirectory, config.screenshotDiffDir);
return suite;
};
};
@@ -122,6 +123,16 @@ Application.prototype.loadTestModules = function () {
}
}
+ // remove existing diffs
+ fs.list(suite.diffDir).forEach(function (item) {
+ var file = path.join(suite.diffDir, item);
+ if (fs.exists(file)
+ && item.slice(-4) == '.png'
+ ) {
+ fs.remove(file);
+ }
+ });
+
testEnvironment.setupFixture(fixture, done);
options = oldOptions;
@@ -159,16 +170,6 @@ Application.prototype.runTests = function () {
}
});
- // remove existing diffs
- fs.list(config.screenshotDiffDir).forEach(function (item) {
- var file = path.join(uiTestsDir, config.screenshotDiffDir, item);
- if (fs.exists(file)
- && item.slice(-4) == '.png'
- ) {
- fs.remove(file);
- }
- });
-
this.doRunTests();
};
diff --git a/tests/lib/screenshot-testing/support/chai-extras.js b/tests/lib/screenshot-testing/support/chai-extras.js
index 7505068e6f..1678a634d4 100644
--- a/tests/lib/screenshot-testing/support/chai-extras.js
+++ b/tests/lib/screenshot-testing/support/chai-extras.js
@@ -91,7 +91,8 @@ chai.Assertion.addChainableMethod('capture', function () {
var testInfo = {
name: screenName,
processed: fs.isFile(processedScreenshotPath) ? processedScreenshotPath : null,
- expected: fs.isFile(expectedScreenshotPath) ? expectedScreenshotPath : null
+ expected: fs.isFile(expectedScreenshotPath) ? expectedScreenshotPath : null,
+ baseDirectory: dirsBase
};
var fail = function (message) {
diff --git a/tests/lib/screenshot-testing/support/diff-viewer.js b/tests/lib/screenshot-testing/support/diff-viewer.js
index 9d812a3d7f..a49f24eb7f 100644
--- a/tests/lib/screenshot-testing/support/diff-viewer.js
+++ b/tests/lib/screenshot-testing/support/diff-viewer.js
@@ -33,7 +33,7 @@ DiffViewerGenerator.prototype.checkImageMagickCompare = function (callback) {
};
DiffViewerGenerator.prototype.getDiffPath = function (testInfo) {
- return path.resolve(path.join(this.diffDir, testInfo.name + '.png'));
+ return path.resolve(path.join(testInfo.baseDirectory, config.screenshotDiffDir, testInfo.name + '.png'));
};
// TODO: diff output path shouldn't be stored in piwik-ui-tests repo