Permalink
Browse files

test for creation or references of global variables - issue #1731

  • Loading branch information...
1 parent a976e5a commit 0baafd95ee9535f87bbbff34ac33c2ce211147b4 @zaach zaach committed Jun 18, 2012
Showing with 49 additions and 1 deletion.
  1. +2 −1 package.json
  2. +8 −0 tests/data/lib.jshintrc
  3. +39 −0 tests/jshint-test.js
View
@@ -37,7 +37,8 @@
"devDependencies": {
"vows": "0.5.13",
"awsbox": "0.2.12",
- "irc": "0.3.3"
+ "irc": "0.3.3",
+ "jshint": "0.7.1"
},
"scripts": {
"postinstall": "./scripts/generate_ephemeral_keys.sh",
View
@@ -0,0 +1,8 @@
+{
+ "undef": true,
+ "node": true,
+ "es5": true,
+ "esnext": true,
+ "strict": false,
+ "sub": true
+}
View
@@ -0,0 +1,39 @@
+#!/usr/bin/env node
+
+/* 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/. */
+
+require('./lib/test_env.js');
+
+// add lib/ to the require path
+
+const
+assert = require('assert'),
+vows = require('vows'),
+fs = require('fs'),
+path = require('path'),
+exec = require('child_process').exec;
+
+var suite = vows.describe('jshint');
+var jshintPath = '../node_modules/jshint/bin/hint';
+
+// disable vows (often flakey?) async error behavior
+suite.options.error = false;
+
+suite.addBatch({
+ "run jshint on the lib directory": {
+ topic: function () {
+ var child = exec(jshintPath + ' --config ./data/lib.jshintrc ../lib/ | grep "not defined"', {cwd: path.resolve(__dirname)}, this.callback);
+ },
+ "no globals are created or referenced" : function (error, stdout, stderr) {
+ var errors = stdout.split("\n").length - 1;
+ assert.strictEqual(errors, 0);
+ }
+ }
+});
+
+
+// run or export the suite.
+if (process.argv[1] === __filename) suite.run();
+else suite.export(module);

0 comments on commit 0baafd9

Please sign in to comment.