vulcan 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data/README.md +1 -80
  2. data/lib/vulcan/cli.rb +12 -33
  3. data/lib/vulcan/version.rb +1 -1
  4. data/server/bin/make +3 -1
  5. data/server/lib/spawner.js +4 -9
  6. data/server/node_modules/connect-form/node_modules/formidable/Readme.md +2 -13
  7. data/server/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js +7 -19
  8. data/server/node_modules/connect-form/node_modules/formidable/lib/multipart_parser.js +1 -12
  9. data/server/node_modules/connect-form/node_modules/formidable/package.json +1 -1
  10. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +10 -0
  11. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +9 -0
  12. data/server/node_modules/connect-form/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +1 -1
  13. data/server/node_modules/cradle/lib/cradle.js +1 -0
  14. data/server/node_modules/cradle/node_modules/vows/LICENSE +20 -0
  15. data/server/node_modules/cradle/node_modules/vows/Makefile +7 -0
  16. data/server/node_modules/cradle/node_modules/vows/README.md +39 -0
  17. data/server/node_modules/cradle/node_modules/vows/bin/vows +515 -0
  18. data/server/node_modules/cradle/node_modules/vows/lib/assert/error.js +27 -0
  19. data/server/node_modules/cradle/node_modules/vows/lib/assert/macros.js +215 -0
  20. data/server/node_modules/cradle/node_modules/vows/lib/assert/utils.js +77 -0
  21. data/server/node_modules/cradle/node_modules/vows/lib/vows.js +193 -0
  22. data/server/node_modules/cradle/node_modules/vows/lib/vows/console.js +131 -0
  23. data/server/node_modules/cradle/node_modules/vows/lib/vows/context.js +55 -0
  24. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/file.js +29 -0
  25. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-foot.html +2 -0
  26. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-head.html +61 -0
  27. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-html.js +54 -0
  28. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-json.js +54 -0
  29. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-plain.js +38 -0
  30. data/server/node_modules/cradle/node_modules/vows/lib/vows/extras.js +28 -0
  31. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/dot-matrix.js +67 -0
  32. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/json.js +16 -0
  33. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/silent.js +8 -0
  34. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/spec.js +44 -0
  35. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/watch.js +39 -0
  36. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/xunit.js +90 -0
  37. data/server/node_modules/cradle/node_modules/vows/lib/vows/suite.js +319 -0
  38. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/LICENSE +20 -0
  39. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/Makefile +4 -0
  40. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/README.md +72 -0
  41. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/lib/eyes.js +233 -0
  42. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/package.json +14 -0
  43. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/test/eyes-test.js +55 -0
  44. data/server/node_modules/cradle/node_modules/vows/package.json +14 -0
  45. data/server/node_modules/cradle/node_modules/vows/test/assert-test.js +135 -0
  46. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/failing.js +18 -0
  47. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/log.js +18 -0
  48. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/passing.js +17 -0
  49. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/stderr.js +18 -0
  50. data/server/node_modules/cradle/node_modules/vows/test/isolate-test.js +140 -0
  51. data/server/node_modules/cradle/node_modules/vows/test/testInherit.js +133 -0
  52. data/server/node_modules/cradle/node_modules/vows/test/vows-error-test.js +51 -0
  53. data/server/node_modules/cradle/node_modules/vows/test/vows-test.js +374 -0
  54. data/server/node_modules/cradle/package.json +3 -3
  55. data/server/node_modules/cradle/test/cache-test.js +7 -6
  56. data/server/node_modules/cradle/test/cradle-test.js +5 -4
  57. data/server/node_modules/cradle/test/response-test.js +6 -5
  58. data/server/node_modules/express/History.md +1 -53
  59. data/server/node_modules/express/Makefile +9 -3
  60. data/server/node_modules/express/Readme.md +1 -3
  61. data/server/node_modules/express/bin/express +66 -65
  62. data/server/node_modules/express/lib/express.js +1 -1
  63. data/server/node_modules/express/lib/request.js +9 -23
  64. data/server/node_modules/express/lib/response.js +2 -3
  65. data/server/node_modules/express/lib/utils.js +0 -13
  66. data/server/node_modules/express/lib/view.js +16 -19
  67. data/server/node_modules/express/lib/view/view.js +1 -2
  68. data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
  69. data/server/node_modules/express/node_modules/connect/lib/http.js +0 -2
  70. data/server/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js +31 -135
  71. data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +1 -5
  72. data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +2 -2
  73. data/server/node_modules/express/node_modules/connect/lib/middleware/static.js +21 -26
  74. data/server/node_modules/express/node_modules/connect/lib/middleware/staticCache.js +38 -91
  75. data/server/node_modules/express/node_modules/connect/lib/middleware/vhost.js +1 -1
  76. data/server/node_modules/express/node_modules/connect/lib/utils.js +4 -11
  77. data/server/node_modules/express/node_modules/connect/package.json +6 -7
  78. data/server/node_modules/express/node_modules/connect/test.js +31 -44
  79. data/server/node_modules/express/node_modules/mime/index.js +1 -0
  80. data/server/node_modules/express/node_modules/mime/mime.js +3 -3
  81. data/server/node_modules/express/node_modules/mime/{types/mime.types → mime.types} +0 -0
  82. data/server/node_modules/express/node_modules/mime/{types/node.types → node.types} +0 -17
  83. data/server/node_modules/express/node_modules/mime/package.json +10 -21
  84. data/server/node_modules/express/node_modules/mime/test.js +3 -2
  85. data/server/node_modules/express/node_modules/qs/History.md +0 -11
  86. data/server/node_modules/express/node_modules/qs/Makefile +3 -1
  87. data/server/node_modules/express/node_modules/qs/Readme.md +4 -2
  88. data/server/node_modules/express/node_modules/qs/lib/querystring.js +74 -100
  89. data/server/node_modules/express/node_modules/qs/package.json +2 -9
  90. data/server/node_modules/express/node_modules/qs/support/expresso/History.md +128 -0
  91. data/server/node_modules/express/node_modules/qs/support/expresso/Makefile +53 -0
  92. data/server/node_modules/express/node_modules/qs/support/expresso/Readme.md +61 -0
  93. data/server/node_modules/express/node_modules/qs/support/expresso/bin/expresso +856 -0
  94. data/server/node_modules/express/node_modules/qs/support/expresso/docs/api.html +1080 -0
  95. data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.html +377 -0
  96. data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.md +290 -0
  97. data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
  98. data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
  99. data/server/node_modules/express/node_modules/qs/support/expresso/lib/bar.js +4 -0
  100. data/server/node_modules/express/node_modules/qs/support/expresso/lib/foo.js +16 -0
  101. data/server/node_modules/express/node_modules/qs/support/expresso/package.json +12 -0
  102. data/server/node_modules/express/node_modules/qs/support/expresso/test/assert.test.js +91 -0
  103. data/server/node_modules/express/node_modules/qs/support/expresso/test/async.test.js +12 -0
  104. data/server/node_modules/express/node_modules/qs/support/expresso/test/bar.test.js +13 -0
  105. data/server/node_modules/express/node_modules/qs/support/expresso/test/foo.test.js +14 -0
  106. data/server/node_modules/express/node_modules/qs/support/expresso/test/http.test.js +146 -0
  107. data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
  108. data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
  109. data/server/node_modules/express/node_modules/qs/support/should/History.md +22 -0
  110. data/server/node_modules/express/node_modules/qs/support/should/Makefile +6 -0
  111. data/server/node_modules/express/node_modules/qs/support/should/Readme.md +248 -0
  112. data/server/node_modules/express/node_modules/qs/support/should/examples/runner.js +53 -0
  113. data/server/node_modules/express/node_modules/qs/support/should/index.js +2 -0
  114. data/server/node_modules/express/node_modules/qs/support/should/lib/eql.js +91 -0
  115. data/server/node_modules/express/node_modules/qs/support/should/lib/should.js +548 -0
  116. data/server/node_modules/express/node_modules/qs/support/should/package.json +8 -0
  117. data/server/node_modules/express/node_modules/qs/support/should/test/should.test.js +358 -0
  118. data/server/node_modules/express/node_modules/qs/test/{parse.js → parse.test.js} +2 -1
  119. data/server/node_modules/express/node_modules/qs/test/{stringify.js → stringify.test.js} +0 -0
  120. data/server/node_modules/express/package.json +8 -9
  121. data/server/node_modules/node-uuid/README.md +67 -166
  122. data/server/node_modules/node-uuid/package.json +3 -5
  123. data/server/node_modules/node-uuid/{benchmark → test}/benchmark-native.c +0 -0
  124. data/server/node_modules/node-uuid/test/benchmark.js +27 -0
  125. data/server/node_modules/node-uuid/test/test.html +0 -3
  126. data/server/node_modules/node-uuid/test/test.js +57 -214
  127. data/server/node_modules/node-uuid/uuid.js +56 -225
  128. data/server/node_modules/restler/README.md +7 -20
  129. data/server/node_modules/restler/bin/restler +1 -1
  130. data/server/node_modules/restler/lib/multipartform.js +8 -9
  131. data/server/node_modules/restler/lib/restler.js +22 -64
  132. data/server/node_modules/restler/package.json +2 -2
  133. data/server/node_modules/restler/test/restler.js +2 -22
  134. data/server/node_modules/restler/test/test_helper.js +1 -20
  135. data/server/package.json +10 -10
  136. data/server/web.js +7 -30
  137. metadata +96 -89
  138. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/file/plain.txt +0 -1
  139. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
  140. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/js/no-filename.js +0 -3
  141. data/server/node_modules/express/node_modules/connect/node_modules/formidable/Makefile +0 -14
  142. data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +0 -286
  143. data/server/node_modules/express/node_modules/connect/node_modules/formidable/TODO +0 -3
  144. data/server/node_modules/express/node_modules/connect/node_modules/formidable/benchmark/bench-multipart-parser.js +0 -70
  145. data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/post.js +0 -43
  146. data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/upload.js +0 -48
  147. data/server/node_modules/express/node_modules/connect/node_modules/formidable/index.js +0 -1
  148. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/file.js +0 -61
  149. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +0 -377
  150. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/index.js +0 -3
  151. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js +0 -312
  152. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js +0 -25
  153. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js +0 -6
  154. data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +0 -22
  155. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js +0 -19
  156. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt +0 -1
  157. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt +0 -1
  158. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
  159. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md +0 -3
  160. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
  161. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
  162. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
  163. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
  164. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
  165. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
  166. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
  167. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js +0 -3
  168. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +0 -21
  169. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
  170. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js +0 -72
  171. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js +0 -89
  172. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js +0 -24
  173. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js +0 -80
  174. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js +0 -104
  175. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +0 -715
  176. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +0 -50
  177. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js +0 -45
  178. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js +0 -72
  179. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js +0 -2
  180. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js +0 -63
  181. data/server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js +0 -47
  182. data/server/node_modules/express/node_modules/mkdirp/LICENSE +0 -21
  183. data/server/node_modules/express/node_modules/mkdirp/README.markdown +0 -21
  184. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js +0 -6
  185. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js.orig +0 -6
  186. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js.rej +0 -19
  187. data/server/node_modules/express/node_modules/mkdirp/index.js +0 -20
  188. data/server/node_modules/express/node_modules/mkdirp/package.json +0 -23
  189. data/server/node_modules/express/node_modules/mkdirp/test/mkdirp.js +0 -28
  190. data/server/node_modules/express/node_modules/mkdirp/test/race.js +0 -41
  191. data/server/node_modules/express/node_modules/mkdirp/test/rel.js +0 -32
  192. data/server/node_modules/express/node_modules/qs/test/mocha.opts +0 -2
  193. data/server/node_modules/express/testing/foo/app.js +0 -35
  194. data/server/node_modules/express/testing/foo/package.json +0 -9
  195. data/server/node_modules/express/testing/foo/public/stylesheets/style.css +0 -8
  196. data/server/node_modules/express/testing/foo/routes/index.js +0 -10
  197. data/server/node_modules/express/testing/foo/views/index.jade +0 -2
  198. data/server/node_modules/express/testing/foo/views/layout.jade +0 -6
  199. data/server/node_modules/express/testing/index.js +0 -43
  200. data/server/node_modules/express/testing/public/test.txt +0 -2971
  201. data/server/node_modules/express/testing/views/page.html +0 -1
  202. data/server/node_modules/express/testing/views/page.jade +0 -3
  203. data/server/node_modules/express/testing/views/test.md +0 -1
  204. data/server/node_modules/express/testing/views/user/index.jade +0 -1
  205. data/server/node_modules/express/testing/views/user/list.jade +0 -1
  206. data/server/node_modules/node-uuid/benchmark/README.md +0 -53
  207. data/server/node_modules/node-uuid/benchmark/bench.gnu +0 -174
  208. data/server/node_modules/node-uuid/benchmark/bench.sh +0 -34
  209. data/server/node_modules/node-uuid/benchmark/benchmark.js +0 -84
  210. data/server/node_modules/node-uuid/test/benchmark-native +0 -0
  211. data/server/node_modules/node-uuid/test/compare_v1.js +0 -63
@@ -0,0 +1,515 @@
1
+ #!/usr/bin/env node
2
+
3
+ var path = require('path'),
4
+ fs = require('fs'),
5
+ util = require('util'),
6
+ events = require('events');
7
+
8
+ //
9
+ // Attempt to load Coffee-Script. If it's not available, continue on our
10
+ // merry way, if it is available, set it up so we can include `*.coffee`
11
+ // scripts and start searching for them.
12
+ //
13
+ var fileExt, specFileExt;
14
+
15
+ try {
16
+ var coffee = require('coffee-script');
17
+ if (require.extensions) {
18
+ require.extensions['.coffee'] = function (module, filename) {
19
+ var content = coffee.compile(fs.readFileSync(filename, 'utf8'));
20
+ return module._compile(content, filename);
21
+ };
22
+ } else {
23
+ require.registerExtension('.coffee', function (content) { return coffee.compile(content) });
24
+ }
25
+ fileExt = /\.(js|coffee)$/;
26
+ specFileExt = /[.-](test|spec)\.(js|coffee)$/;
27
+ } catch (_) {
28
+ fileExt = /\.js$/;
29
+ specFileExt = /[.-](test|spec)\.js$/;
30
+ }
31
+
32
+ var inspect = require('eyes').inspector({
33
+ stream: null,
34
+ styles: { string: 'grey', regexp: 'grey' }
35
+ });
36
+
37
+ var vows = require('../lib/vows');
38
+ var cutils = require('../lib/vows/console');
39
+ var stylize = require('../lib/vows/console').stylize;
40
+ var _reporter = require('../lib/vows/reporters/dot-matrix'), reporter = {
41
+ name: _reporter.name
42
+ };
43
+ var _coverage;
44
+
45
+ var help = [
46
+ "usage: vows [FILE, ...] [options]",
47
+ "",
48
+ "options:",
49
+ " -v, --verbose Enable verbose output",
50
+ " -w, --watch Watch mode",
51
+ " -s, --silent Don't report",
52
+ " -i, --isolate Run each test in it's own vows process",
53
+ " -m PATTERN Only run tests matching the PATTERN string",
54
+ " -r PATTERN Only run tests matching the PATTERN regexp",
55
+ " --json Use JSON reporter",
56
+ " --spec Use Spec reporter",
57
+ " --dot-matrix Use Dot-Matrix reporter",
58
+ " --xunit Use xUnit reporter",
59
+ " --cover-plain Print plain coverage map if detected",
60
+ " --cover-html Write coverage map to \"coverage.html\"",
61
+ " --cover-json Write unified coverage map to \"coverage.json\"",
62
+ //" --no-color Don't use terminal colors",
63
+ " --version Show version",
64
+ " -h, --help You're staring at it"
65
+ ].join('\n');
66
+
67
+ var options = {
68
+ reporter: reporter,
69
+ matcher: /.*/,
70
+ watch: false,
71
+ coverage: false,
72
+ isolate: false
73
+ };
74
+
75
+ var files = [];
76
+
77
+ // Get rid of process runner
78
+ // ('node' in most cases)
79
+ var arg, args = [], argv = process.argv.slice(2);
80
+
81
+ // Current directory index,
82
+ // and path of test folder.
83
+ var root, testFolder;
84
+
85
+ //
86
+ // Parse command-line parameters
87
+ //
88
+ while (arg = argv.shift()) {
89
+ if (arg === __filename) { continue }
90
+
91
+ if (arg[0] !== '-') {
92
+ args.push(arg);
93
+ } else {
94
+ arg = arg.match(/^--?(.+)/)[1];
95
+
96
+ if (arg[0] === 'r') {
97
+ options.matcher = new(RegExp)(argv.shift());
98
+ } else if (arg[0] === 'm') {
99
+ options.matcher = (function (str) { // Create an escaped RegExp
100
+ var specials = '. * + ? | ( ) [ ] { } \\ ^ ? ! = : $'.split(' ').join('|\\'),
101
+ regex = new(RegExp)('(\\' + specials + ')', 'g');
102
+ return new(RegExp)(str.replace(regex, '\\$1'));
103
+ })(argv.shift());
104
+ } else if (arg in options) {
105
+ options[arg] = true;
106
+ } else {
107
+ switch (arg) {
108
+ case 'json':
109
+ _reporter = require('../lib/vows/reporters/json');
110
+ break;
111
+ case 'spec':
112
+ _reporter = require('../lib/vows/reporters/spec');
113
+ break;
114
+ case 'dot-matrix':
115
+ _reporter = require('../lib/vows/reporters/dot-matrix');
116
+ break;
117
+ case 'silent':
118
+ case 's':
119
+ _reporter = require('../lib/vows/reporters/silent');
120
+ break;
121
+ case 'xunit':
122
+ _reporter = require('../lib/vows/reporters/xunit');
123
+ break;
124
+ case 'cover-plain':
125
+ options.coverage = true;
126
+ _coverage = require('../lib/vows/coverage/report-plain');
127
+ break;
128
+ case 'cover-html':
129
+ options.coverage = true;
130
+ _coverage = require('../lib/vows/coverage/report-html');
131
+ break;
132
+ case 'cover-json':
133
+ options.coverage = true;
134
+ _coverage = require('../lib/vows/coverage/report-json');
135
+ break;
136
+ case 'verbose':
137
+ case 'v':
138
+ options.verbose = true;
139
+ break;
140
+ case 'watch':
141
+ case 'w':
142
+ options.watch = true;
143
+ break;
144
+ case 'supress-stdout':
145
+ options.supressStdout = true;
146
+ break;
147
+ case 'isolate':
148
+ case 'i':
149
+ options.isolate = true;
150
+ break;
151
+ case 'no-color':
152
+ options.nocolor = true;
153
+ break;
154
+ case 'no-error':
155
+ options.error = false;
156
+ break;
157
+ case 'version':
158
+ console.log('vows ' + vows.version);
159
+ process.exit(0);
160
+ case 'help':
161
+ case 'h':
162
+ console.log(help);
163
+ process.exit(0);
164
+ break;
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+ if (options.supressStdout) {
171
+ _reporter.setStream && _reporter.setStream(process.stdout);
172
+ process.stdout = fs.createWriteStream('/dev/null');
173
+ }
174
+
175
+ if (options.watch) {
176
+ options.reporter = reporter = require('../lib/vows/reporters/watch');
177
+ }
178
+
179
+ msg('bin', 'argv', args);
180
+ msg('bin', 'options', { reporter: options.reporter.name, matcher: options.matcher });
181
+
182
+ if (args.length === 0 || options.watch) {
183
+ msg('bin', 'discovering', 'folder structure');
184
+ root = fs.readdirSync('.');
185
+
186
+ if (root.indexOf('test') !== -1) {
187
+ testFolder = 'test';
188
+ } else if (root.indexOf('spec') !== -1) {
189
+ testFolder = 'spec';
190
+ } else {
191
+ abort("runner", "couldn't find test folder");
192
+ }
193
+ msg('bin', 'discovered', "./" + testFolder);
194
+
195
+ if (args.length === 0) {
196
+ args = paths(testFolder).filter(function (f) {
197
+ return new(RegExp)('-' + testFolder + '.(js|coffee)$').test(f);
198
+ });
199
+
200
+ if (options.watch) {
201
+ args = args.concat(paths('lib'),
202
+ paths('src'));
203
+ }
204
+ }
205
+ }
206
+
207
+ if (! options.watch) {
208
+ reporter.report = function (data, filename) {
209
+ switch (data[0]) {
210
+ case 'subject':
211
+ case 'vow':
212
+ case 'context':
213
+ case 'error':
214
+ _reporter.report(data, filename);
215
+ break;
216
+ case 'end':
217
+ (options.verbose || _reporter.name === 'json') &&
218
+ _reporter.report(data);
219
+ break;
220
+ case 'finish':
221
+ options.verbose ?
222
+ _reporter.print('\n')
223
+ :
224
+ _reporter.print(' ');
225
+ break;
226
+ }
227
+ };
228
+ reporter.reset = function () { _reporter.reset && _reporter.reset() };
229
+ reporter.print = _reporter.print;
230
+
231
+ files = args.map(function (a) {
232
+ return (!a.match(/^\//))
233
+ ? path.join(process.cwd(), a.replace(fileExt, ''))
234
+ : a.replace(fileExt, '');
235
+ });
236
+
237
+ runSuites(importSuites(files), function (results) {
238
+ var status = results.errored ? 2 : (results.broken ? 1 : 0);
239
+
240
+ !options.verbose && _reporter.print('\n');
241
+ msg('runner', 'finish');
242
+ _reporter.report(['finish', results], {
243
+ write: function (str) {
244
+ util.print(str.replace(/^\n\n/, '\n'));
245
+ }
246
+ });
247
+ try {
248
+ if (options.coverage === true && _$jscoverage !== undefined) {
249
+ _coverage.report(_$jscoverage);
250
+ }
251
+ } catch (err) {
252
+ // ignore the undefined jscoverage
253
+ }
254
+ if (process.stdout.write('')) { // Check if stdout is drained
255
+ process.exit(status);
256
+ } else {
257
+ process.stdout.on('drain', function () {
258
+ process.exit(status);
259
+ });
260
+ }
261
+ });
262
+ } else {
263
+ //
264
+ // Watch mode
265
+ //
266
+ (function () {
267
+ var pendulum = [
268
+ '. ', '.. ', '... ', ' ...',
269
+ ' ..', ' .', ' .', ' ..',
270
+ '... ', '.. ', '. '
271
+ ];
272
+ var strobe = ['.', ' '];
273
+ var status,
274
+ cue,
275
+ current = 0,
276
+ running = 0,
277
+ lastRun,
278
+ colors = ['32m', '33m', '31m'],
279
+ timer = setInterval(tick, 100);
280
+
281
+ process.on('uncaughtException', cleanup);
282
+ process.on('exit', cleanup);
283
+ process.on('SIGINT', function () {
284
+ process.exit(0);
285
+ });
286
+ process.on('SIGQUIT', function () {
287
+ changed();
288
+ });
289
+
290
+ cursorHide();
291
+
292
+ // Run every 100ms
293
+ function tick() {
294
+ if (running && (cue !== strobe)) {
295
+ cue = strobe, current = 0;
296
+ } else if (!running && (cue !== pendulum)) {
297
+ cue = pendulum, current = 0;
298
+ }
299
+
300
+ eraseLine();
301
+ lastRun && !running && esc(colors[status.errored ? 2 : (status.broken ? 1 : 0)]);
302
+ print(cue[current]);
303
+
304
+ if (current == cue.length - 1) { current = -1 }
305
+
306
+ current ++;
307
+ esc('39m');
308
+ cursorRestore();
309
+ }
310
+
311
+ //
312
+ // Utility functions
313
+ //
314
+ function print(str) { util.print(str) }
315
+ function esc(str) { print("\x1b[" + str) }
316
+ function eraseLine() { esc("0K") }
317
+ function cursorRestore() { esc("0G") }
318
+ function cursorHide() { esc("?25l") }
319
+ function cursorShow() { esc("?25h") }
320
+ function cleanup() { eraseLine(), cursorShow(), clearInterval(timer), print('\n') }
321
+
322
+ //
323
+ // Called when a file has been modified.
324
+ // Run the matching tests and change the status.
325
+ //
326
+ function changed(file) {
327
+ status = { honored: 0, broken: 0, errored: 0, pending: 0 };
328
+
329
+ msg('watcher', 'detected change in', file);
330
+
331
+ file = (specFileExt.test(file) ? path.join(testFolder, file)
332
+ : path.join(testFolder, file + '-' + testFolder));
333
+
334
+ try {
335
+ fs.statSync(file);
336
+ } catch (e) {
337
+ msg('watcher', 'no equivalence found, running all tests.');
338
+ file = null;
339
+ }
340
+
341
+ var files = (specFileExt.test(file) ? [file] : paths(testFolder)).map(function (p) {
342
+ return path.join(process.cwd(), p);
343
+ }).map(function (p) {
344
+ var cache = require.main.moduleCache || require.cache;
345
+ if (cache[p]) { delete(cache[p]) }
346
+ return p;
347
+ }).map(function (p) {
348
+ return p.replace(fileExt, '');
349
+ });
350
+
351
+ running ++;
352
+
353
+ runSuites(importSuites(files), function (results) {
354
+ delete(results.time);
355
+ print(cutils.result(results).join('') + '\n\n');
356
+ lastRun = new(Date);
357
+ status = results;
358
+ running --;
359
+ });
360
+ }
361
+
362
+ msg('watcher', 'watching', args);
363
+
364
+ //
365
+ // Watch all relevant files,
366
+ // and call `changed()` on change.
367
+ //
368
+ args.forEach(function (p) {
369
+ fs.watchFile(p, function (current, previous) {
370
+ if (new(Date)(current.mtime).valueOf() ===
371
+ new(Date)(previous.mtime).valueOf()) { return }
372
+ else {
373
+ changed(p);
374
+ }
375
+ });
376
+ });
377
+ })();
378
+ }
379
+
380
+ function runSuites(suites, callback) {
381
+ var results = {
382
+ honored: 0,
383
+ broken: 0,
384
+ errored: 0,
385
+ pending: 0,
386
+ total: 0,
387
+ time: 0
388
+ };
389
+ reporter.reset();
390
+
391
+ (function run(suites, callback) {
392
+ var suite = suites.shift();
393
+ if (suite) {
394
+ msg('runner', "running", suite.subject + ' ', options.watch ? false : true);
395
+ suite.run(options, function (result) {
396
+ Object.keys(result).forEach(function (k) {
397
+ results[k] += result[k];
398
+ });
399
+ run(suites, callback);
400
+ });
401
+ } else {
402
+ callback(results);
403
+ }
404
+ })(suites, callback);
405
+ }
406
+
407
+ function importSuites(files) {
408
+ msg(options.watcher ? 'watcher' : 'runner', 'loading', files);
409
+
410
+ var spawn = require('child_process').spawn;
411
+
412
+ function cwdname(f) {
413
+ return f.replace(process.cwd() + '/', '') + '.js';
414
+ }
415
+
416
+ function wrapSpawn(f) {
417
+ f = cwdname(f);
418
+ return function (options, callback) {
419
+ var args = [process.argv[1], '--json', '--supress-stdout', f],
420
+ p = spawn(process.argv[0], args),
421
+ result;
422
+
423
+ p.on('exit', function (code) {
424
+ callback(
425
+ !result ?
426
+ {errored: 1, total: 1}
427
+ :
428
+ result
429
+ );
430
+ });
431
+
432
+ var buffer = [];
433
+ p.stdout.on('data', function (data) {
434
+ data = data.toString().split(/\n/g);
435
+ if (data.length == 1) {
436
+ buffer.push(data[0]);
437
+ } else {
438
+ data[0] = buffer.concat(data[0]).join('');
439
+ buffer = [data.pop()];
440
+
441
+ data.forEach(function (data) {
442
+ if (data) {
443
+ data = JSON.parse(data);
444
+ if (data && data[0] === 'finish') {
445
+ result = data[1];
446
+ } else {
447
+ reporter.report(data);
448
+ }
449
+ }
450
+ });
451
+ }
452
+ });
453
+
454
+ p.stderr.pipe(process.stderr);
455
+ }
456
+ }
457
+
458
+ return files.reduce(options.isolate ? function (suites, f) {
459
+ return suites.concat({
460
+ run: wrapSpawn(f)
461
+ });
462
+ } : function (suites, f) {
463
+ var obj = require(f);
464
+ return suites.concat(Object.keys(obj).map(function (s) {
465
+ obj[s]._filename = cwdname(f);
466
+ return obj[s];
467
+ }));
468
+ }, [])
469
+ }
470
+
471
+ //
472
+ // Recursively traverse a hierarchy, returning
473
+ // a list of all relevant .js files.
474
+ //
475
+ function paths(dir) {
476
+ var paths = [];
477
+
478
+ try { fs.statSync(dir) }
479
+ catch (e) { return [] }
480
+
481
+ (function traverse(dir, stack) {
482
+ stack.push(dir);
483
+ fs.readdirSync(stack.join('/')).forEach(function (file) {
484
+ var path = stack.concat([file]).join('/'),
485
+ stat = fs.statSync(path);
486
+
487
+ if (file[0] == '.' || file === 'vendor') {
488
+ return;
489
+ } else if (stat.isFile() && fileExt.test(file)) {
490
+ paths.push(path);
491
+ } else if (stat.isDirectory()) {
492
+ traverse(file, stack);
493
+ }
494
+ });
495
+ stack.pop();
496
+ })(dir || '.', []);
497
+
498
+ return paths;
499
+ }
500
+
501
+ function msg(cmd, subject, str, p) {
502
+ if (options.verbose) {
503
+ util[p ? 'print' : 'puts']( stylize('vows ', 'green')
504
+ + stylize(cmd, 'bold')
505
+ + ' ' + subject + ' '
506
+ + (str ? (typeof(str) === 'string' ? str : inspect(str)) : '')
507
+ );
508
+ }
509
+ }
510
+
511
+ function abort(cmd, str) {
512
+ console.log(stylize('vows ', 'red') + stylize(cmd, 'bold') + ' ' + str);
513
+ console.log(stylize('vows ', 'red') + stylize(cmd, 'bold') + ' exiting');
514
+ process.exit(-1);
515
+ }