Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Bug 1147741 Part 1 - Add travis tests that the jetpack-addon.ini file…
Browse files Browse the repository at this point in the history
… is up to date
  • Loading branch information
erikvold committed Apr 29, 2015
1 parent ac1e852 commit e130cb4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
3 changes: 2 additions & 1 deletion bin/jpm-test.js
Expand Up @@ -26,7 +26,8 @@ exports.run = function(type, options) {
(!isDebug && /^(modules)?$/.test(type)) && require.resolve("../bin/node-scripts/test.modules"),
(!isDebug && /^(addons)?$/.test(type)) && require.resolve("../bin/node-scripts/test.addons"),
(/^(examples)?$/.test(type)) && require.resolve("../bin/node-scripts/test.examples"),
(/^(docs)?$/.test(type)) && require.resolve("../bin/node-scripts/test.docs"),
(!isDebug && /^(docs)?$/.test(type)) && require.resolve("../bin/node-scripts/test.docs"),
(!isDebug && /^(ini)?$/.test(type)) && require.resolve("../bin/node-scripts/test.ini"),
].sort().forEach(function(filepath) {
filepath && mocha.addFile(filepath);
})
Expand Down
39 changes: 39 additions & 0 deletions bin/node-scripts/test.ini.js
@@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

var fs = require("fs");
var path = require("path");
var Promise = require("promise");
var chai = require("chai");
var expect = chai.expect;
var ini = require("./update-ini");

var addonINI = path.resolve("./test/addons/jetpack-addon.ini");

describe("Checking ini files", function () {

it("Check test/addons/jetpack-addon.ini", function (done) {

fs.readFile(addonINI, function (err, data) {
if (err) {
throw err;
}
var text = data.toString();
var expected = "";

ini.makeAddonIniContent()
.then(function(contents) {
expected = contents;

setTimeout(function end() {
expect(expected.trim()).to.be.equal(text.trim());
done();
});
});
});

});

});
20 changes: 15 additions & 5 deletions bin/node-scripts/update-ini.js
Expand Up @@ -16,6 +16,18 @@ function updateAddonINI() {
return new Promise(function(resolve) {
console.log("Start updating " + addonINI);

makeAddonIniContent().
then(function(contents) {
fs.writeFileSync(addonINI, contents, { encoding: "utf8" });
console.log("Done updating " + addonINI);
resolve();
});
})
}
exports.updateAddonINI = updateAddonINI;

function makeAddonIniContent() {
return new Promise(function(resolve) {
var data = parser.parse(fs.readFileSync(addonINI, { encoding: "utf8" }).toString());
var result = {};

Expand All @@ -39,10 +51,8 @@ function updateAddonINI() {
});
contents = contents.join("\n") + "\n";

fs.writeFileSync(addonINI, contents, { encoding: "utf8" });
console.log("Done updating " + addonINI);
resolve();
return resolve(contents);
});
})
});
}
exports.updateAddonINI = updateAddonINI;
exports.makeAddonIniContent = makeAddonIniContent;
11 changes: 11 additions & 0 deletions gulpfile.js
Expand Up @@ -51,6 +51,13 @@ gulp.task('travis', function(done) {

return test("docs");
}).
then(function() {
if (filtersExist) {
return resolve();
}

return test("ini");
}).
then(function() {
if (filtersExist && !filters["modules"]) {
return resolve();
Expand Down Expand Up @@ -83,6 +90,10 @@ gulp.task('test:modules', function(done) {
test("modules").catch(console.error).then(done);
});

gulp.task('test:ini', function(done) {
test("ini").catch(console.error).then(done);
});

gulp.task('patch:clean', function(done) {
patch.clean().catch(console.error).then(done);
});
Expand Down

0 comments on commit e130cb4

Please sign in to comment.