From 5089f26e62bb9a17b2e695a1caf0a4cfa97775ef Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Thu, 19 Mar 2015 16:20:26 -0700 Subject: [PATCH] Bug 1143357 Starting gulp tasks for tests --- .travis.yml | 5 +---- bin/jpm-test.js | 30 ++++++++++++++++-------------- gulpfile.js | 23 +++++++++++++++++++++++ package.json | 6 ++---- 4 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 gulpfile.js diff --git a/.travis.yml b/.travis.yml index 7bc454e22..b9780e8e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,11 +14,8 @@ before_install: before_script: - npm install mozilla-download -g - - npm install jpm -g + - npm install gulp -g - cd .. - mozilla-download --branch nightly -c prerelease --host ftp.mozilla.org firefox - export JPM_FIREFOX_BINARY=$TRAVIS_BUILD_DIR/../firefox/firefox - cd $TRAVIS_BUILD_DIR - -script: - - npm test diff --git a/bin/jpm-test.js b/bin/jpm-test.js index 3b83639d1..f9836e102 100644 --- a/bin/jpm-test.js +++ b/bin/jpm-test.js @@ -3,8 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -var readParam = require("./node-scripts/utils").readParam; -var path = require("path"); +var Promise = require("promise"); var Mocha = require("mocha"); var mocha = new Mocha({ ui: "bdd", @@ -12,16 +11,19 @@ var mocha = new Mocha({ timeout: 900000 }); -var type = readParam("type"); +exports.run = function(type) { + return new Promise(function(resolve) { + type = type || ""; + [ + (/^(modules)?$/.test(type)) && require.resolve("../bin/node-scripts/test.modules"), + (/^(addons)?$/.test(type)) && require.resolve("../bin/node-scripts/test.addons"), + (/^(examples)?$/.test(type)) && require.resolve("../bin/node-scripts/test.examples"), + ].sort().forEach(function(filepath) { + filepath && mocha.addFile(filepath); + }) -[ - (!type || type == "modules") && require.resolve("../bin/node-scripts/test.modules"), - (!type || type == "addons") && require.resolve("../bin/node-scripts/test.addons"), - (!type || type == "examples") && require.resolve("../bin/node-scripts/test.examples"), -].sort().forEach(function(filepath) { - filepath && mocha.addFile(filepath); -}) - -mocha.run(function (failures) { - process.exit(failures); -}); + mocha.run(function(failures) { + resolve(failures); + }); + }); +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 000000000..fc1b89e79 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,23 @@ +/* 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 gulp = require('gulp'); + +gulp.task('test', function(done) { + require("./bin/jpm-test").run().then(done); +}); + +gulp.task('test:addons', function(done) { + require("./bin/jpm-test").run("addons").then(done); +}); + +gulp.task('test:examples', function(done) { + require("./bin/jpm-test").run("examples").then(done); +}); + +gulp.task('test:modules', function(done) { + require("./bin/jpm-test").run("modules").then(done); +}); + diff --git a/package.json b/package.json index 0e0c1f0e3..f2faebc75 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,7 @@ "license": "MPL 2.0", "unpack": true, "scripts": { - "test": "node ./bin/jpm-test.js", - "modules": "node ./bin/jpm-test.js --type modules", - "addons": "node ./bin/jpm-test.js --type addons", - "examples": "node ./bin/jpm-test.js --type examples" + "test": "gulp test" }, "homepage": "https://github.com/mozilla/addon-sdk", "repository": { @@ -25,6 +22,7 @@ "async": "0.9.0", "chai": "2.1.1", "glob": "4.4.2", + "gulp": "3.8.11", "jpm": "0.0.29", "lodash": "3.3.1", "mocha": "2.1.0",