couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benk...@apache.org
Subject [1/2] fauxton commit: updated refs/heads/master to 30b551a
Date Mon, 06 Apr 2015 19:38:31 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master e229a45fc -> 30b551a74


Control over exactly what nw tests to omit

This PR expands on the option where you could choose to omit
specific addon test from being ran. Previously you could only
omit test on the addon-level. This now lets you fine-tune exactly
what nightwatch tests you want to omit.

See the updated readme.txt file in this commit for an explanation
of how it works.


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

Branch: refs/heads/master
Commit: c9c1c817f1e22f967a3b17a7bc47c3a0a5bcda5f
Parents: e229a45
Author: Ben Keen <ben.keen@gmail.com>
Authored: Mon Feb 23 10:02:01 2015 -0800
Committer: Ben Keen <ben.keen@gmail.com>
Committed: Mon Apr 6 10:01:31 2015 -0700

----------------------------------------------------------------------
 package.json                                    |  2 +-
 readme.md                                       | 25 +++++++-
 tasks/fauxton.js                                | 61 +++++++++++++++-----
 .../nightwatch_tests/nightwatch.json.underscore |  3 +-
 4 files changed, 72 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/c9c1c817/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index cd8efe1..5a076df 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,7 @@
     "http-proxy": "~1.1.4",
     "jsxcs": "~0.2.1",
     "nano": "~5.12.0",
-    "nightwatch": "~0.5.33",
+    "nightwatch": "^0.6.0",
     "react-tools": "^0.12.0",
     "request": "^2.54.0",
     "send": "~0.1.1",

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/c9c1c817/readme.md
----------------------------------------------------------------------
diff --git a/readme.md b/readme.md
index 724ddf5..54f84b9 100644
--- a/readme.md
+++ b/readme.md
@@ -88,7 +88,30 @@ And to run the tests (in another terminal tab):
     
     grunt nightwatch
 
-
+##### Omitting nightwatch tests
+
+If you need to omit particular tests from running you can add a `testBlacklist` option to
the nightwatch section of 
+your settings.json file. That defines an object of the following form:
+
+```javascript
+// ... 
+"nightwatch": {
+  // ... 
+  "testBlacklist": {
+    "documents": ["*"],
+    "databases": [
+      "checkDatabaseTooltip.js",
+      "createsDatabase.js"
+    ]
+  }
+}
+// ...
+
+```
+
+The properties (`documents`, `databases`) map to a particular addon folder name (see `app/addons`).
The values 
+should be an array of tests that you don't want to run. `*` will flag all tests from being
ran, otherwise you 
+just enter the names of the files to omit.
 
 
 ### To Deploy Fauxton

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/c9c1c817/tasks/fauxton.js
----------------------------------------------------------------------
diff --git a/tasks/fauxton.js b/tasks/fauxton.js
index ee73399..bc481ca 100644
--- a/tasks/fauxton.js
+++ b/tasks/fauxton.js
@@ -23,8 +23,8 @@ module.exports = function (grunt) {
   });
 
   grunt.registerMultiTask('get_deps', 'Fetch external dependencies', function (version) {
-    grunt.log.writeln("Fetching external dependencies");
 
+    grunt.log.writeln("Fetching external dependencies");
     var done = this.async(),
         data = this.data,
         target = data.target || "app/addons/",
@@ -142,8 +142,11 @@ module.exports = function (grunt) {
     // perform a little validation on the settings
     _validateNightwatchSettings(this.data.settings);
 
-    // figure out what tests we need to run by examining the settings.json file content
-    var addonsWithTests = _getNightwatchTests(this.data.settings);
+    // figure out what tests we need to run by examining the settings.json file content.
This method returns
+    // the list of addon folders to test, plus a list of files to exclude
+    var result = _getNightwatchTests(this.data.settings);
+    var addonsWithTests = result.addonFolders;
+    var excludeTests = result.excludeTests;
 
     // if the user passed a --file="X" on the command line, filter out
     var singleTestToRun = grunt.option('file');
@@ -155,6 +158,7 @@ module.exports = function (grunt) {
     var nightwatchTemplate = _.template(grunt.file.read(this.data.template));
     grunt.file.write(this.data.dest, nightwatchTemplate({
       src_folders: JSON.stringify(addonsWithTests),
+      exclude_tests: JSON.stringify(excludeTests, null, '\t'),
       custom_commands_path: JSON.stringify(this.data.settings.nightwatch.custom_commands_path),
       globals_path: this.data.settings.nightwatch.globals_path,
       fauxton_username: this.data.settings.nightwatch.fauxton_username,
@@ -210,26 +214,51 @@ module.exports = function (grunt) {
   };
 
   function _getNightwatchTests (settings) {
-    var addonBlacklist = (_.has(settings.nightwatch, 'addonBlacklist')) ? settings.nightwatch.addonBlacklist
: [];
+    var testBlacklist = (_.has(settings.nightwatch, 'testBlacklist')) ? settings.nightwatch.testBlacklist
: {};
+    var addonFolders = [],
+        excludeTests = [];
 
-    return _.filter(settings.deps, function (addon) {
-
-      // if we've explicitly been told to ignore this addon's test, ignore 'em!
-      if (_.contains(addonBlacklist, addon.name)) {
-        return false;
+    _.each(settings.deps, function (addon) {
+      var addonTestsFolder = 'app/addons/' + addon.name + '/tests/nightwatch';
+      if (_.has(addon, 'path')) {
+        addonTestsFolder = addon.path + '/tests/nightwatch';
       }
 
-      var fileLocation = 'app/addons/' + addon.name + '/tests/nightwatch';
-      if (_.has(addon, 'path')) {
-        fileLocation = addon.path + '/tests/nightwatch';
+      // if this addon doesn't have any tests, just move along. Nothing to see here.
+      if (!fs.existsSync(addonTestsFolder)) {
+        return;
       }
 
-      // see if the addon has any tests
-      return fs.existsSync(fileLocation);
+      // next up: see if this addon has anything blacklisted
+      if (_.has(testBlacklist, addon.name) && _.isArray(testBlacklist[addon.name])
&& testBlacklist[addon.name].length > 0) {
+
+        // a '*' means the user wants to blacklist all tests in the addon
+        if (_.contains(testBlacklist[addon.name], '*')) {
+          return;
+        }
+
+        // add the folder to test. Any specific files will be blacklisted separately
+        addonFolders.push(addonTestsFolder);
+
+        _.each(fs.readdirSync(addonTestsFolder), function (file) {
+          if (_.contains(testBlacklist[addon.name], file)) {
+            // the relative path is added to work around an oddity with nightwatch. It evaluates
all exclude paths
+            // relative to the current src_folder being examined, so we need to return to
the root first
+            excludeTests.push('../../../../../' + addonTestsFolder + '/' + file);
+          }
+        });
+
+      } else {
 
-    }).map(function (addon) {
-      return 'app/addons/' + addon.name + '/tests/nightwatch';
+        // add the whole folder
+        addonFolders.push(addonTestsFolder);
+      }
     });
+
+    return {
+      addonFolders: addonFolders,
+      excludeTests: excludeTests
+    };
   }
 
 };

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/c9c1c817/test/nightwatch_tests/nightwatch.json.underscore
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/nightwatch.json.underscore b/test/nightwatch_tests/nightwatch.json.underscore
index f92a398..9d33770 100644
--- a/test/nightwatch_tests/nightwatch.json.underscore
+++ b/test/nightwatch_tests/nightwatch.json.underscore
@@ -38,7 +38,8 @@
         "browserName" : "firefox",
         "javascriptEnabled" : true,
         "acceptSslCerts" : true
-      }
+      },
+      "exclude": <%= exclude_tests %>
     },
 
     "chrome" : {


Mime
View raw message