Skip to content
Extraits de code Groupes Projets
Valider 5f88fe08 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Fix diff generation in screenshot tests for plugins (paths were not different for plugin tests).

parent a6cd4c3a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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();
};
......
......@@ -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) {
......
......@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter