Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update tests to put run command at top, and use new style

Doing things this way prevents the file being run from being run twice.
  • Loading branch information...
commit 6cc8532455d60640f9bed1862d08eefee67eda7a 1 parent 0643a38
authored October 29, 2010
2  test/test-all_passing.js
... ...
@@ -1,5 +1,5 @@
1 1
 if (module == require.main) {
2  
-  return require('../lib/async_testing').run(__filename, process.ARGV);
  2
+  return require('../lib/async_testing').run(process.ARGV);
3 3
 }
4 4
 
5 5
 module.exports = {
7  test/test-async_assertions.js
... ...
@@ -1,3 +1,6 @@
  1
+if (module == require.main) {
  2
+  return require('../lib/async_testing').run(process.ARGV);
  3
+}
1 4
 
2 5
 module.exports = {
3 6
   'test success': function(test) {
@@ -46,7 +49,3 @@ module.exports = {
46 49
       }, 500);
47 50
   }
48 51
 }
49  
-
50  
-if (module == require.main) {
51  
-  require('../lib/async_testing').run(__filename, process.ARGV);
52  
-}
14  test/test-custom_assertions.js
... ...
@@ -1,6 +1,10 @@
1  
-var async_testing = require('../lib/async_testing')
2  
-  , assert = require('assert')
3  
-  ;
  1
+var async_testing = require('../lib/async_testing');
  2
+
  3
+if (module == require.main) {
  4
+  return async_testing.run(process.ARGV);
  5
+}
  6
+
  7
+var assert = require('assert');
4 8
 
5 9
 async_testing.registerAssertion('isTwo', 
6 10
   function isTwo(actual, message) {
@@ -20,7 +24,3 @@ module.exports = {
20 24
     test.finish();
21 25
   }
22 26
 }
23  
-
24  
-if (module == require.main) {
25  
-  require('../lib/async_testing').run(__filename, process.ARGV);
26  
-}
3  test/test-error_async.js
... ...
@@ -1,6 +1,5 @@
1 1
 if (module == require.main) {
2  
-  // if this module is the script being run, then run the tests:
3  
-  return require('../lib/async_testing').run(__filename, process.ARGV);
  2
+  return require('../lib/async_testing').run(process.ARGV);
4 3
 }
5 4
 
6 5
 module.exports =
2  test/test-error_outside_suite.js
... ...
@@ -1,5 +1,5 @@
1 1
 if (module == require.main) {
2  
-  return require('../lib/async_testing').run(__filename, process.ARGV);
  2
+  return require('../lib/async_testing').run(process.ARGV);
3 3
 }
4 4
 
5 5
 throw new Error();
7  test/test-error_sync.js
... ...
@@ -1,10 +1,9 @@
  1
+if (module == require.main) {
  2
+  return require('../lib/async_testing').run(process.ARGV);
  3
+}
1 4
 
2 5
 module.exports = {
3 6
   'test sync error': function(test) {
4 7
     throw new Error();
5 8
   }
6 9
 }
7  
-
8  
-if (module == require.main) {
9  
-  require('../lib/async_testing').run(__filename, process.ARGV);
10  
-}
2  test/test-error_syntax.js
... ...
@@ -1 +1 @@
1  
-jfksdl '
  1
+'
7  test/test-error_uncaught_exception_handler.js
... ...
@@ -1,3 +1,6 @@
  1
+if (module == require.main) {
  2
+  return require('../lib/async_testing').run(process.ARGV);
  3
+}
1 4
 
2 5
 module.exports = {
3 6
   'test sync error error again': function(test) {
@@ -10,7 +13,3 @@ module.exports = {
10 13
     throw e;
11 14
   }
12 15
 }
13  
-
14  
-if (module == require.main) {
15  
-  require('../lib/async_testing').run(__filename, process.ARGV);
16  
-}
10  test/test-overview.js
... ...
@@ -1,9 +1,11 @@
  1
+var async_testing = require('../lib/async_testing')
  2
+  , wrap = async_testing.wrap
  3
+  ;
  4
+
1 5
 if (module == require.main) {
2  
-  // if this module is the script being run, then run the tests:
3  
-  return require('../lib/async_testing').run(__filename, process.ARGV);
  6
+  return require('../lib/async_testing').run(process.ARGV);
4 7
 }
5 8
 
6  
-var wrap = require('../lib/async_testing').wrap; 
7 9
 
8 10
 var suiteSetupCount = 0;
9 11
 
@@ -125,4 +127,4 @@ module.exports =
125 127
           done();
126 128
         }
127 129
       })
128  
-};
  130
+}
1  test/test-parseRunArguments.js → test/test-parse_run_arguments.js
@@ -163,4 +163,3 @@ module.exports =
163 163
       test.finish();
164 164
     }
165 165
   };
166  
-
7  test/test-sub_suites.js
... ...
@@ -1,3 +1,6 @@
  1
+if (module == require.main) {
  2
+  return require('../lib/async_testing').run(process.ARGV);
  3
+}
1 4
 
2 5
 module.exports =
3 6
   { 'sub-suite A':
@@ -41,7 +44,3 @@ module.exports =
41 44
       }
42 45
     }
43 46
   };
44  
-
45  
-if (module == require.main) {
46  
-  require('../lib/async_testing').run(__filename, process.ARGV);
47  
-}
7  test/test-sync_assertions.js
... ...
@@ -1,3 +1,6 @@
  1
+if (module == require.main) {
  2
+  return require('../lib/async_testing').run(process.ARGV);
  3
+}
1 4
 
2 5
 module.exports = {
3 6
   'test success': function(test) {
@@ -34,7 +37,3 @@ module.exports = {
34 37
     test.finish();
35 38
   }
36 39
 };
37  
-
38  
-if (module == require.main) {
39  
-  require('../lib/async_testing').run(__filename, process.ARGV);
40  
-}
8  test/test-uncaught_exception_handlers.js
... ...
@@ -1,3 +1,7 @@
  1
+if (module == require.main) {
  2
+  return require('../lib/async_testing').run(process.ARGV);
  3
+}
  4
+
1 5
 module.exports = {
2 6
   'test catch sync error': function(test) {
3 7
     var e = new Error();
@@ -75,7 +79,3 @@ module.exports = {
75 79
       }, 500);
76 80
   }
77 81
 }
78  
-
79  
-if (module == require.main) {
80  
-  require('../lib/async_testing').run(__filename, process.ARGV);
81  
-}
4  test/test-wrap_tests.js
@@ -2,6 +2,10 @@ var async_testing = require('../lib/async_testing')
2 2
   , wrap = async_testing.wrap
3 3
   ;
4 4
 
  5
+if (module == require.main) {
  6
+  return async_testing.run(process.ARGV);
  7
+}
  8
+
5 9
 var extra1 = {}, extra2 = {};
6 10
 
7 11
 module.exports = {

0 notes on commit 6cc8532

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