Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

remove need for runlint/runtest scripts

resolved into makefile
switched nodeunit reporter to skip_passed
  • Loading branch information...
commit c526245920111e2946561cf29ecb17f412239aba 1 parent 583df10
Paul Armstrong authored April 09, 2012
16  Makefile
@@ -6,14 +6,16 @@ all:
6 6
 browser:
7 7
 	@scripts/browser.sh
8 8
 
  9
+tests := $(shell find . -name '*.test.js' ! -path "*node_modules/*" ! -path "*dist/*")
  10
+reporter = skip_passed
9 11
 test:
10  
-	@node tests/speed.js
11  
-	@node scripts/runtests.js
12  
-
13  
-testf:
14  
-	@node_modules/nodeunit/bin/nodeunit ${file}
  12
+	@node_modules/nodeunit/bin/nodeunit --reporter ${reporter} ${tests}
15 13
 
  14
+files := $(shell find . -name '*.js' ! -path "*node_modules/*" ! -path "*dist/*")
16 15
 lint:
17  
-	@node scripts/runlint.js
  16
+	@node_modules/nodelint/nodelint ${files} --config=scripts/config-lint.js
  17
+
  18
+speed:
  19
+	@node tests/speed.js
18 20
 
19  
-.PHONY: all browser test lint
  21
+.PHONY: all browser test lint speed
5  scripts/config-lint.js
... ...
@@ -1,8 +1,3 @@
1  
-module.exports = {
2  
-    root: __dirname + '/../',
3  
-    pathIgnore: ['*node_modules*', '*browser/underscore*', '*dist/browser/*', '*dist/test*']
4  
-};
5  
-
6 1
 var options = {
7 2
     adsafe: false,
8 3
     bitwise: true,
5  scripts/config-test.js
... ...
@@ -1,5 +0,0 @@
1  
-module.exports = {
2  
-    root: __dirname + '/../',
3  
-    testRunner: 'default',
4  
-    pathIgnore: ['*node_modules*', '*dist/test*']
5  
-};
35  scripts/runlint.js
... ...
@@ -1,35 +0,0 @@
1  
-var util = require('util'),
2  
-    child_process = require('child_process'),
3  
-    configFile = __dirname + '/config-lint',
4  
-    ignore = '',
5  
-    config,
6  
-    root,
7  
-    i;
8  
-
9  
-process.argv.forEach(function (val, index, array) {
10  
-    if (index < 2) {
11  
-        return;
12  
-    }
13  
-
14  
-    if (val === '-c') {
15  
-        configFile = process.argv[~~index + 1];
16  
-    }
17  
-});
18  
-
19  
-config = require(configFile);
20  
-
21  
-function runLint(error, stdout, stderr) {
22  
-    var files = stdout.trim().replace(/\n/g, ' ');
23  
-
24  
-    child_process.exec('node ' + __dirname + '/../node_modules/nodelint/nodelint ' + files + ' --config ' + configFile + '.js', { cwd: config.root }, function (error, stdout, stderr) {
25  
-        util.puts(stdout);
26  
-    });
27  
-}
28  
-
29  
-i = config.pathIgnore.length;
30  
-while (i) {
31  
-    i -= 1;
32  
-    ignore += ' ! -path "' + config.pathIgnore[i] + '"';
33  
-}
34  
-
35  
-child_process.exec('find . -name "*.js"' + ignore, { cwd: config.root }, runLint);
124  scripts/runtests.js
... ...
@@ -1,124 +0,0 @@
1  
-var util = require('util'),
2  
-    child_process = require('child_process'),
3  
-    nodeunit = require('nodeunit'),
4  
-    configFile = __dirname + '/config-test',
5  
-    ignore = '',
6  
-    path = require('path'),
7  
-    fs = require('fs'),
8  
-    track = require(__dirname + '/../node_modules/nodeunit/lib/track'),
9  
-    utils = require(__dirname + '/../node_modules/nodeunit/lib/utils'),
10  
-    AssertionError = require(__dirname + '/../node_modules/nodeunit/lib/assert').AssertionError,
11  
-    config,
12  
-    i,
13  
-    l;
14  
-
15  
-process.argv.forEach(function (val, index, array) {
16  
-    if (index < 2) {
17  
-        return;
18  
-    }
19  
-
20  
-    if (val === '-c') {
21  
-        configFile = process.argv[~~index + 1];
22  
-    }
23  
-});
24  
-
25  
-config = require(configFile);
26  
-
27  
-/*!
28  
- * Nodeunit
29  
- * Copyright (c) 2010 Caolan McMahon
30  
- * MIT Licensed
31  
- */
32  
-function run(files, options) {
33  
-
34  
-    if (!options) {
35  
-        options = JSON.parse(fs.readFileSync(__dirname + '/../node_modules/nodeunit/bin/nodeunit.json', 'utf8'));
36  
-    }
37  
-
38  
-    var content,
39  
-        names,
40  
-        i = 0,
41  
-        error = function (str) {
42  
-            return options.error_prefix + str + options.error_suffix;
43  
-        },
44  
-        ok = function (str) {
45  
-            return options.ok_prefix + str + options.ok_suffix;
46  
-        },
47  
-        bold = function (str) {
48  
-            return options.bold_prefix + str + options.bold_suffix;
49  
-        },
50  
-        assertion_message = function (str) {
51  
-            return options.assertion_prefix + str + options.assertion_suffix;
52  
-        },
53  
-        start = new Date().getTime(),
54  
-        paths = files.map(function (p) {
55  
-            return path.join(process.cwd(), p);
56  
-        }),
57  
-        tracker = track.createTracker(function (tracker) {
58  
-            if (tracker.unfinished()) {
59  
-                console.log('');
60  
-                console.log(error(bold(
61  
-                    'FAILURES: Undone tests (or their setups/teardowns): '
62  
-                )));
63  
-                names = tracker.names();
64  
-                for (i; i < names.length; i += 1) {
65  
-                    console.log('- ' + names[i]);
66  
-                }
67  
-                console.log('');
68  
-                console.log('To fix this, make sure all tests call test.done()');
69  
-                process.reallyExit(tracker.unfinished());
70  
-            }
71  
-        });
72  
-
73  
-    nodeunit.runFiles(paths, {
74  
-        testspec: options.testspec,
75  
-        moduleStart: function (name) {
76  
-            console.log('\n' + bold(name));
77  
-        },
78  
-        testDone: function (name, assertions) {
79  
-            tracker.remove(name);
80  
-
81  
-            if (!assertions.failures()) {
82  
-                console.log('✔ ' + name);
83  
-            } else {
84  
-                console.log(error('✖ ' + name) + '\n');
85  
-                assertions.forEach(function (a) {
86  
-                    if (a.failed()) {
87  
-                        a = utils.betterErrors(a);
88  
-                        if (a.error instanceof AssertionError && a.message) {
89  
-                            console.log('Assertion Message: ' + assertion_message(a.message));
90  
-                        }
91  
-                        console.log(a.error.stack + '\n');
92  
-                    }
93  
-                });
94  
-            }
95  
-        },
96  
-        done: function (assertions, end) {
97  
-            end = end || new Date().getTime();
98  
-            var duration = end - start;
99  
-            if (assertions.failures()) {
100  
-                console.log('\n' + bold(error('FAILURES: ')) + assertions.failures() + '/' + assertions.length + ' assertions failed (' + assertions.duration + 'ms)');
101  
-                process.exit(1);
102  
-            } else {
103  
-                console.log('\n' + bold(ok('OK: ')) + assertions.length + ' assertions (' + assertions.duration + 'ms)');
104  
-            }
105  
-        },
106  
-        testStart: function (name) {
107  
-            tracker.put(name);
108  
-        }
109  
-    });
110  
-}
111  
-
112  
-function runTests(error, stdout, stderr) {
113  
-    var tests = stdout.trim().split("\n");
114  
-    if (tests.length && tests[0] !== '') {
115  
-        run(tests);
116  
-    }
117  
-}
118  
-
119  
-l = config.pathIgnore.length;
120  
-for (i = 0; i < l; i += 1) {
121  
-    ignore += ' ! -path "' + config.pathIgnore[i] + '"';
122  
-}
123  
-
124  
-child_process.exec('find . -name "*.test.js" ' + ignore, { cwd: config.root }, runTests);

0 notes on commit c526245

Please sign in to comment.
Something went wrong with that request. Please try again.