From 26b8490672167e1528cf2559630d1a6477e9725b Mon Sep 17 00:00:00 2001 From: Paul Connolley Date: Tue, 17 Dec 2013 16:52:35 +0000 Subject: [PATCH] Updated the test process for mopidy.js Following on from the previous issue #609 commits, I have updated the build process to cater to the fact that the files are no longer available to test in the browser environment. 2 new browserify tasks build the mopidy.js file and then when.js file (available in node_modules.) These files are placed in test/lib/ (This directory has been added to the .gitignore file) prior to the running of the buster tests. As these files are ignored in the .gitignore, this will prevent them from being committed to git and also prevent them from being packaged up to npm. Once the tests have completed, the main browserify task will run to build the official browser release. --- .gitignore | 1 + js/Gruntfile.js | 24 ++++++++++++++++++++++-- js/buster.js | 12 +----------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 79230110..1ec12cbc 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ node_modules/ nosetests.xml *~ *.orig +js/test/lib/ diff --git a/js/Gruntfile.js b/js/Gruntfile.js index f59ed9f8..df0145ab 100644 --- a/js/Gruntfile.js +++ b/js/Gruntfile.js @@ -20,6 +20,25 @@ module.exports = function (grunt) { all: {} }, browserify: { + test_mopidy: { + files: { + "test/lib/mopidy.js": "<%= meta.files.main %>" + }, + options: { + postBundleCB: function (err, src, next) { + next(null, grunt.template.process("<%= meta.banner %>") + src); + }, + standalone: "Mopidy" + } + }, + test_when: { + files: { + "test/lib/when.js": "node_modules/when/when.js" + }, + options: { + standalone: "when" + } + }, dist: { files: { "<%= meta.files.concat %>": "<%= meta.files.main %>" @@ -68,8 +87,9 @@ module.exports = function (grunt) { } }); - grunt.registerTask("test", ["jshint", "buster"]); - grunt.registerTask("build", ["test", "browserify", "uglify"]); + grunt.registerTask("test_build", ["browserify:test_when", "browserify:test_mopidy"]); + grunt.registerTask("test", ["jshint", "test_build", "buster"]); + grunt.registerTask("build", ["test", "browserify:dist", "uglify"]); grunt.registerTask("default", ["build"]); grunt.loadNpmTasks("grunt-buster"); diff --git a/js/buster.js b/js/buster.js index 1cc517c8..c5dec850 100644 --- a/js/buster.js +++ b/js/buster.js @@ -2,23 +2,13 @@ var config = module.exports; config.browser_tests = { environment: "browser", - libs: [ - "lib/bane-*.js", - "lib/when-define-shim.js", - "lib/when-*.js" - ], - sources: ["src/**/*.js"], + libs: ["test/lib/*.js"], testHelpers: ["test/**/*-helper.js"], tests: ["test/**/*-test.js"] }; config.node_tests = { environment: "node", - libs: [ - "lib/bane-*.js", - "lib/when-define-shim.js", - "lib/when-*.js" - ], sources: ["src/**/*.js"], testHelpers: ["test/**/*-helper.js"], tests: ["test/**/*-test.js"]