couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benk...@apache.org
Subject fauxton commit: updated refs/heads/master to 6203825
Date Thu, 01 Oct 2015 15:26:53 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master cde32162d -> 62038259c


Add a test to confirm test exists

A pet peeve with running a single mocha test on the command line,
like `grunt file --file=./a/b/c.js` is that (a) it spends several
seconds compiling, copying etc. then (b) just ends. It doesn't
notify you that the file doesn't exist.

This little PR adds a test that runs up front: if the file you
entered doesn't exist, it lets you know about it and stops the
process immediately.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/62038259
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/62038259
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/62038259

Branch: refs/heads/master
Commit: 62038259c53e2595e45095891eec72ccc61cadd1
Parents: cde3216
Author: Ben Keen <ben.keen@gmail.com>
Authored: Wed Sep 30 14:54:04 2015 -0700
Committer: Ben Keen <ben.keen@gmail.com>
Committed: Thu Oct 1 08:26:39 2015 -0700

----------------------------------------------------------------------
 Gruntfile.js     |  3 ++-
 tasks/fauxton.js | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62038259/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index c1035da..e9f36aa 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -364,6 +364,7 @@ module.exports = function (grunt) {
       }
     },
     gen_initialize: templateSettings,
+    checkTestExists: templateSettings,
 
     mkcouchdb: couch_config,
     rmcouchdb: couch_config,
@@ -540,7 +541,7 @@ module.exports = function (grunt) {
    */
   // clean out previous build artifacts and lint
   grunt.registerTask('lint', ['clean', 'jshint']);
-  grunt.registerTask('test', ['clean:release', 'dependencies', 'jsx', 'jshint', 'shell:stylecheck',
'gen_initialize:development', 'test_inline']);
+  grunt.registerTask('test', ['checkTestExists', 'clean:release', 'dependencies', 'jsx',
'jshint', 'shell:stylecheck', 'gen_initialize:development', 'test_inline']);
 
   // lighter weight test task for use inside dev/watch
   grunt.registerTask('test_inline', ['mochaSetup', 'jst', 'concat:test_config_js', 'shell:phantomjs']);

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/62038259/tasks/fauxton.js
----------------------------------------------------------------------
diff --git a/tasks/fauxton.js b/tasks/fauxton.js
index ed5c021..630b3ed 100644
--- a/tasks/fauxton.js
+++ b/tasks/fauxton.js
@@ -107,6 +107,16 @@ module.exports = function (grunt) {
     grunt.file.write(dest, tmpl(app));
   });
 
+  // quick sanity check to run immediately when the user specifies a specific mocha test
to run, like
+  //     `grunt test --file=./my/test.js`
+  // This dies immediately if the file doesn't exist and notifies the user.
+  grunt.registerMultiTask('checkTestExists', 'Confirms that if a specific mocha test exists',
function () {
+    var fileSrc = grunt.option('file');
+    if (fileSrc && !fs.existsSync(fileSrc)) {
+      grunt.fail.fatal('Mocha test file not found: ' + fileSrc);
+    }
+  });
+
   grunt.registerMultiTask('mochaSetup', 'Generate a config.js and runner.html for tests',
function () {
     var data = this.data,
         configInfo,


Mime
View raw message