Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 306 lines (259 sloc) 10.731 kB
88847df @jashkenas tests are now passing on symbology
authored
1 fs = require 'fs'
bb05e07 @jashkenas light refactors + tweaks
authored
2 path = require 'path'
9e5ffae @xixixao Use actual _.template instead of custom one
xixixao authored
3 _ = require 'underscore'
88847df @jashkenas tests are now passing on symbology
authored
4 CoffeeScript = require './lib/coffee-script'
5 {spawn, exec} = require 'child_process'
1a83544 @spinda Modify extension handling to allow for .coffee.md
spinda authored
6 helpers = require './lib/coffee-script/helpers'
2f389f1 @jashkenas beginnings of a build script
authored
7
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
8 # ANSI Terminal Colors.
0ded5b3 @disnet removing old changes
disnet authored
9 bold = red = green = reset = ''
8a98cb3 @jashkenas Fixes #2531. Allow colors where Node says that colors are available.
authored
10 unless process.env.NODE_DISABLE_COLORS
3a694d7 @geraldalewis Issue #1547 'use strict' octal escape sequences prohibited
geraldalewis authored
11 bold = '\x1B[0;1m'
12 red = '\x1B[0;31m'
13 green = '\x1B[0;32m'
14 reset = '\x1B[0m'
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
15
2c7f6d8 @jashkenas switching to UglifyJS for browser version of CoffeeScript.
authored
16 # Built file header.
17 header = """
18 /**
19 * CoffeeScript Compiler v#{CoffeeScript.VERSION}
20 * http://coffeescript.org
21 *
c44d9ae @jashkenas CoffeeScript 1.0.1
authored
22 * Copyright 2011, Jeremy Ashkenas
2c7f6d8 @jashkenas switching to UglifyJS for browser version of CoffeeScript.
authored
23 * Released under the MIT License
24 */
25 """
26
b2e17c3 @spinda Hoist build function to top level of Cakefile
spinda authored
27 # Build the CoffeeScript language from source.
28 build = (cb) ->
29 files = fs.readdirSync 'src'
30 files = ('src/' + file for file in files when file.match(/\.(lit)?coffee$/))
31 run ['-c', '-o', 'lib/coffee-script'].concat(files), cb
32
448ed36 @jashkenas got a build script for rebuilding the compiler, too
authored
33 # Run a CoffeeScript through our node/coffee interpreter.
d2d02bf @michaelficarra Cakefile: build:full exits unsuccessfully when tests or builds fail;
michaelficarra authored
34 run = (args, cb) ->
7e32c32 @hickford build on Windows - fix spawn command by calling node explicitly
hickford authored
35 proc = spawn 'node', ['bin/coffee'].concat(args)
26a115a @jashkenas Removing the mixed-in sys/util module. Switching from 'puts' to conso…
authored
36 proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
d2d02bf @michaelficarra Cakefile: build:full exits unsuccessfully when tests or builds fail;
michaelficarra authored
37 proc.on 'exit', (status) ->
38 process.exit(1) if status != 0
39 cb() if typeof cb is 'function'
2f389f1 @jashkenas beginnings of a build script
authored
40
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
41 # Log a message with a color.
88847df @jashkenas tests are now passing on symbology
authored
42 log = (message, color, explanation) ->
26a115a @jashkenas Removing the mixed-in sys/util module. Switching from 'puts' to conso…
authored
43 console.log color + message + reset + ' ' + (explanation or '')
e4db6d4 @jashkenas Updated Cakefile from Tim_Smart with colorized, explained 'cake install'
authored
44
9e5ffae @xixixao Use actual _.template instead of custom one
xixixao authored
45 codeFor = ->
46 counter = 0
47 hljs = require 'highlight.js'
48 hljs.configure classPrefix: ''
49 (file, executable = false, showLoad = true) ->
50 counter++
51 return unless fs.existsSync "documentation/js/#{file}.js"
52 cs = fs.readFileSync "documentation/coffee/#{file}.coffee", 'utf-8'
53 js = fs.readFileSync "documentation/js/#{file}.js", 'utf-8'
54 js = js.replace /^\/\/ generated.*?\n/i, ''
55
56 cshtml = "<pre><code>#{hljs.highlight('coffeescript', cs).value}</code></pre>"
57 jshtml = "<pre><code>#{hljs.highlight('javascript', js).value}</code></pre>"
58 append = if executable is yes then '' else "alert(#{executable});"
59 if executable and executable != yes
60 cs.replace /(\S)\s*\Z/m, "$1\n\nalert #{executable}"
61 run = if executable is true then 'run' else "run: #{executable}"
62 name = "example#{counter}"
63 script = "<script>window.#{name} = #{JSON.stringify cs}</script>"
64 load = if showLoad then "<div class='minibutton load' onclick='javascript: loadConsole(#{name});'>load</div>" else ''
65 button = if executable then "<div class='minibutton ok' onclick='javascript: #{js};#{append}'>#{run}</div>" else ''
66 "<div class='code'>#{cshtml}#{jshtml}#{script}#{load}#{button}<br class='clear' /></div>"
67
09446ad @davidchambers changelog: add anchor to each section
davidchambers authored
68 monthNames = [
69 'January'
70 'February'
71 'March'
72 'April'
73 'May'
74 'June'
75 'July'
76 'August'
77 'September'
78 'October'
79 'November'
80 'December'
81 ]
82
83 formatDate = (date) ->
84 date.replace /^(\d\d\d\d)-(\d\d)-(\d\d)$/, (match, $1, $2, $3) ->
85 "#{monthNames[$2 - 1]} #{+$3}, #{$1}"
86
87 releaseHeader = (date, version, prevVersion) -> """
88 <div class="anchor" id="#{version}"></div>
81e2253 @davidchambers changelog: replace inline CSS
davidchambers authored
89 <b class="header">
f076409 @jashkenas now that github supports renames, coffeescript, not coffee-script
authored
90 #{prevVersion and "<a href=\"https://github.com/jashkenas/coffeescript/compare/#{prevVersion}...#{version}\">#{version}</a>" or version}
c9e87f3 @davidchambers changelog: use time elements for release dates
davidchambers authored
91 <span class="timestamp"> &mdash; <time datetime="#{date}">#{formatDate date}</time></span>
09446ad @davidchambers changelog: add anchor to each section
davidchambers authored
92 </b>
93 """
94
5c7526a @jashkenas moving some of the fs methods over to sync methods, where it's alrigh…
authored
95 option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`'
17ea48c @jashkenas first draft of options for Cakefiles, using optparse.coffee, as well …
authored
96
97 task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options) ->
88847df @jashkenas tests are now passing on symbology
authored
98 base = options.prefix or '/usr/local'
9df3e6a @jashkenas first step towards requiring #{ ... } interpolation -- removing naked…
authored
99 lib = "#{base}/lib/coffee-script"
100 bin = "#{base}/bin"
88847df @jashkenas tests are now passing on symbology
authored
101 node = "~/.node_libraries/coffee-script"
26a115a @jashkenas Removing the mixed-in sys/util module. Switching from 'puts' to conso…
authored
102 console.log "Installing CoffeeScript to #{lib}"
103 console.log "Linking to #{node}"
104 console.log "Linking 'coffee' to #{bin}/coffee"
0490cb2 @jashkenas added experimental (but working) method to install CoffeeScript: 'sud…
authored
105 exec([
9df3e6a @jashkenas first step towards requiring #{ ... } interpolation -- removing naked…
authored
106 "mkdir -p #{lib} #{bin}"
ab5728c @michaelficarra fix cake install; related: #3395, #3393
michaelficarra authored
107 "cp -rf bin lib LICENSE README.md package.json src #{lib}"
6d3f272 @jashkenas ln -sfn ... part of Issue #971
authored
108 "ln -sfn #{lib}/bin/coffee #{bin}/coffee"
109 "ln -sfn #{lib}/bin/cake #{bin}/cake"
ce4e00e @jashkenas mistaken camelCase 'nodeLibraries' from the great under_score purge .…
authored
110 "mkdir -p ~/.node_libraries"
ab17f41 @gfxmonk Moved src/*.coffee under src/coffee-script/ so that lib can be added …
gfxmonk authored
111 "ln -sfn #{lib}/lib/coffee-script #{node}"
93f644f @jashkenas finishing the second half of prefix installs. Using readLink to refer…
authored
112 ].join(' && '), (err, stdout, stderr) ->
02e94cd @jashkenas removing forgotten print's
authored
113 if err then console.log stderr.trim() else log 'done', green
93f644f @jashkenas finishing the second half of prefix installs. Using readLink to refer…
authored
114 )
0490cb2 @jashkenas added experimental (but working) method to install CoffeeScript: 'sud…
authored
115
116
b2e17c3 @spinda Hoist build function to top level of Cakefile
spinda authored
117 task 'build', 'build the CoffeeScript language from source', build
bedc005 @jashkenas Adding a CoffeeScript equivalent to Rake/Make/Jake (Cake, naturally),…
authored
118
0ded5b3 @disnet removing old changes
disnet authored
119 task 'build:full', 'rebuild the source twice, and run the tests', ->
d2d02bf @michaelficarra Cakefile: build:full exits unsuccessfully when tests or builds fail;
michaelficarra authored
120 build ->
121 build ->
c88cb5c @michaelficarra Another attempt to fix #1580... still haven't come up with a good way to
michaelficarra authored
122 csPath = './lib/coffee-script'
7f8b56e @troels Use the newly compiled code when running tests under build:full
troels authored
123 csDir = path.dirname require.resolve csPath
124
125 for mod of require.cache when csDir is mod[0 ... csDir.length]
126 delete require.cache[mod]
127
0ded5b3 @disnet removing old changes
disnet authored
128 unless runTests require csPath
e5b77b1 @michaelficarra fixes #580 by `delete`ing the compiler from `require.cache` and `requ…
michaelficarra authored
129 process.exit 1
bcf7b3f @jashkenas CoffeeScript 0.5.5, with string interpolation and internal documentation
authored
130
131
ff25361 @jashkenas removing the build:parser -> build dependency in the Cakefile -- the …
authored
132 task 'build:parser', 'rebuild the Jison parser (run build first)', ->
1a83544 @spinda Modify extension handling to allow for .coffee.md
spinda authored
133 helpers.extend global, require('util')
e56af49 @jashkenas removing our vendor'd copy of Jison ... you should install it from NP…
authored
134 require 'jison'
333daf3 fix path to grammar file
Mike Blume authored
135 parser = require('./lib/coffee-script/grammar').parser
8c5027a fix the output path too
Mike Blume authored
136 fs.writeFile 'lib/coffee-script/parser.js', parser.generate()
2f389f1 @jashkenas beginnings of a build script
authored
137
c1427d6 @jashkenas adding a minified combined coffee-script.js. Include it on the page, …
authored
138 task 'build:browser', 'rebuild the merged script for inclusion in the browser', ->
2c7f6d8 @jashkenas switching to UglifyJS for browser version of CoffeeScript.
authored
139 code = ''
b62a90d @jashkenas Fixes #2765 -- incorrect line number in mappings
authored
140 for name in ['helpers', 'rewriter', 'lexer', 'parser', 'scope', 'nodes', 'sourcemap', 'coffee-script', 'browser']
2c7f6d8 @jashkenas switching to UglifyJS for browser version of CoffeeScript.
authored
141 code += """
7b14a6a @jashkenas Fixing browser build boilerplate.
authored
142 require['./#{name}'] = (function() {
5496a18 @michaelficarra fixes #2934
michaelficarra authored
143 var exports = {}, module = {exports: exports};
ab17f41 @gfxmonk Moved src/*.coffee under src/coffee-script/ so that lib can be added …
gfxmonk authored
144 #{fs.readFileSync "lib/coffee-script/#{name}.js"}
5496a18 @michaelficarra fixes #2934
michaelficarra authored
145 return module.exports;
7b14a6a @jashkenas Fixing browser build boilerplate.
authored
146 })();
2c7f6d8 @jashkenas switching to UglifyJS for browser version of CoffeeScript.
authored
147 """
7ae284f @jashkenas Allowing an environment variable of MINIFY=false to disable minificat…
authored
148 code = """
3564f51 @samcday Added AMD support.
samcday authored
149 (function(root) {
150 var CoffeeScript = function() {
151 function require(path){ return require[path]; }
152 #{code}
ad39150 @jashkenas Fixing crappy JS AMD code.
authored
153 return require['./coffee-script'];
3564f51 @samcday Added AMD support.
samcday authored
154 }();
155
ad39150 @jashkenas Fixing crappy JS AMD code.
authored
156 if (typeof define === 'function' && define.amd) {
157 define(function() { return CoffeeScript; });
9e3d431 @caseywebdev gh-2631 Update to uglifyjs's new API
caseywebdev authored
158 } else {
159 root.CoffeeScript = CoffeeScript;
ad39150 @jashkenas Fixing crappy JS AMD code.
authored
160 }
3564f51 @samcday Added AMD support.
samcday authored
161 }(this));
2c7f6d8 @jashkenas switching to UglifyJS for browser version of CoffeeScript.
authored
162 """
7ae284f @jashkenas Allowing an environment variable of MINIFY=false to disable minificat…
authored
163 unless process.env.MINIFY is 'false'
9e3d431 @caseywebdev gh-2631 Update to uglifyjs's new API
caseywebdev authored
164 {code} = require('uglify-js').minify code, fromString: true
2c7f6d8 @jashkenas switching to UglifyJS for browser version of CoffeeScript.
authored
165 fs.writeFileSync 'extras/coffee-script.js', header + '\n' + code
150a8a1 @jashkenas A bit more explanation of what's actually going on with build:browser
authored
166 console.log "built ... running browser tests:"
2c7f6d8 @jashkenas switching to UglifyJS for browser version of CoffeeScript.
authored
167 invoke 'test:browser'
c1427d6 @jashkenas adding a minified combined coffee-script.js. Include it on the page, …
authored
168
169
5b3ef78 @jashkenas adding a doc:source Cake task to document CoffeeScript's internals
authored
170 task 'doc:site', 'watch and continually rebuild the documentation for the website', ->
9e5ffae @xixixao Use actual _.template instead of custom one
xixixao authored
171 source = 'documentation/index.html.js'
f42329c @xixixao Use Node instead of Ruby for documentation
xixixao authored
172 exec 'bin/coffee -bc -o documentation/js documentation/coffee/*.coffee'
173
9e5ffae @xixixao Use actual _.template instead of custom one
xixixao authored
174 do renderIndex = ->
175 codeSnippetCounter = 0
09446ad @davidchambers changelog: add anchor to each section
davidchambers authored
176 rendered = _.template fs.readFileSync(source, 'utf-8'),
177 codeFor: codeFor()
178 releaseHeader: releaseHeader
9e5ffae @xixixao Use actual _.template instead of custom one
xixixao authored
179 fs.writeFileSync 'index.html', rendered
180 log "compiled", green, "#{source}"
181
bfc9d4d @sailxjx fix a spell mistake in cakefile
sailxjx authored
182 fs.watchFile source, interval: 200, renderIndex
9e5ffae @xixixao Use actual _.template instead of custom one
xixixao authored
183 log "watching..." , green
c1427d6 @jashkenas adding a minified combined coffee-script.js. Include it on the page, …
authored
184
185
5b3ef78 @jashkenas adding a doc:source Cake task to document CoffeeScript's internals
authored
186 task 'doc:source', 'rebuild the internal documentation', ->
ed92892 @michaelficarra use npm-installed docco rather than relying on globally installed docco
michaelficarra authored
187 exec 'node_modules/.bin/docco src/*.*coffee && cp -rf docs documentation && rm -r docs', (err) ->
e267226 @jashkenas commenting coffee-script.coffee for documentation
authored
188 throw err if err
5b3ef78 @jashkenas adding a doc:source Cake task to document CoffeeScript's internals
authored
189
190
a3e1693 @jashkenas waypoint -- docc'd down to the SplatNode
authored
191 task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
ed92892 @michaelficarra use npm-installed docco rather than relying on globally installed docco
michaelficarra authored
192 exec 'node_modules/.bin/docco examples/underscore.coffee && cp -rf docs documentation && rm -r docs', (err) ->
25438be @jashkenas new docs for underscore
authored
193 throw err if err
a3e1693 @jashkenas waypoint -- docc'd down to the SplatNode
authored
194
0ded5b3 @disnet removing old changes
disnet authored
195 task 'bench', 'quick benchmark of compilation time', ->
ab17f41 @gfxmonk Moved src/*.coffee under src/coffee-script/ so that lib can be added …
gfxmonk authored
196 {Rewriter} = require './lib/coffee-script/rewriter'
3355383 @jashkenas Fixes #2690 -- tweak cake bench to handle literate coffeescript
authored
197 sources = ['coffee-script', 'grammar', 'helpers', 'lexer', 'nodes', 'rewriter']
198 coffee = sources.map((name) -> fs.readFileSync "src/#{name}.coffee").join '\n'
199 litcoffee = fs.readFileSync("src/scope.litcoffee").toString()
835244f @jashkenas slight reformats to cake bench
authored
200 fmt = (ms) -> " #{bold}#{ " #{ms}".slice -4 }#{reset} ms"
bcbf9f7 @satyr "cake bench" now shows total time spent
satyr authored
201 total = 0
1a9a48c @satyr rewrote "cake bench" to time per parsing stage
satyr authored
202 now = Date.now()
bcbf9f7 @satyr "cake bench" now shows total time spent
satyr authored
203 time = -> total += ms = -(now - now = Date.now()); fmt ms
3355383 @jashkenas Fixes #2690 -- tweak cake bench to handle literate coffeescript
authored
204 tokens = CoffeeScript.tokens coffee, rewrite: no
205 littokens = CoffeeScript.tokens litcoffee, rewrite: no, literate: yes
206 tokens = tokens.concat(littokens)
bcbf9f7 @satyr "cake bench" now shows total time spent
satyr authored
207 console.log "Lex #{time()} (#{tokens.length} tokens)"
1a9a48c @satyr rewrote "cake bench" to time per parsing stage
satyr authored
208 tokens = new Rewriter().rewrite tokens
bcbf9f7 @satyr "cake bench" now shows total time spent
satyr authored
209 console.log "Rewrite#{time()} (#{tokens.length} tokens)"
1a9a48c @satyr rewrote "cake bench" to time per parsing stage
satyr authored
210 nodes = CoffeeScript.nodes tokens
bcbf9f7 @satyr "cake bench" now shows total time spent
satyr authored
211 console.log "Parse #{time()}"
3355383 @jashkenas Fixes #2690 -- tweak cake bench to handle literate coffeescript
authored
212 js = nodes.compile bare: yes
bcbf9f7 @satyr "cake bench" now shows total time spent
satyr authored
213 console.log "Compile#{time()} (#{js.length} chars)"
835244f @jashkenas slight reformats to cake bench
authored
214 console.log "total #{ fmt total }"
a3e1693 @jashkenas waypoint -- docc'd down to the SplatNode
authored
215
7987d4e @jashkenas adding a cake task to check loc
authored
216
b9c2236 @jashkenas Merging in MichaelFicarra's refactorTests branch.
authored
217 # Run the CoffeeScript test suite.
0ded5b3 @disnet removing old changes
disnet authored
218 runTests = (CoffeeScript) ->
08a5789 @michaelficarra add CoffeeScript.register method for require.extensions registration
michaelficarra authored
219 CoffeeScript.register()
b9c2236 @jashkenas Merging in MichaelFicarra's refactorTests branch.
authored
220 startTime = Date.now()
221 currentFile = null
09c23a5 @michaelficarra majorly enhanced test output
michaelficarra authored
222 passedTests = 0
b9c2236 @jashkenas Merging in MichaelFicarra's refactorTests branch.
authored
223 failures = []
a4958e7 @jashkenas whitespace
authored
224
683b3af @michaelficarra cake test: count number of complete tests that pass, not assertions
michaelficarra authored
225 global[name] = func for name, func of require 'assert'
31892e1 @jashkenas Issue #959 (and countless others) Removing the loop-block-scoped mag…
authored
226
b9c2236 @jashkenas Merging in MichaelFicarra's refactorTests branch.
authored
227 # Convenience aliases.
159150c @satyr "cake test" now wraps all of the "assert" module to update test counts
satyr authored
228 global.CoffeeScript = CoffeeScript
47bd05e @asalant REPL tests based on direct interaction with input and output stream. …
asalant authored
229 global.Repl = require './lib/coffee-script/repl'
b9c2236 @jashkenas Merging in MichaelFicarra's refactorTests branch.
authored
230
231 # Our test helper function for delimiting different test cases.
09c23a5 @michaelficarra majorly enhanced test output
michaelficarra authored
232 global.test = (description, fn) ->
b9c2236 @jashkenas Merging in MichaelFicarra's refactorTests branch.
authored
233 try
6421c86 @michaelficarra finished reorganizing test suite
michaelficarra authored
234 fn.test = {description, currentFile}
235 fn.call(fn)
683b3af @michaelficarra cake test: count number of complete tests that pass, not assertions
michaelficarra authored
236 ++passedTests
09c23a5 @michaelficarra majorly enhanced test output
michaelficarra authored
237 catch e
c407a0b @jwalton Fix reporting of errors in 'cake test'
jwalton authored
238 failures.push
239 filename: currentFile
240 error: e
241 description: description if description?
242 source: fn.toString() if fn.toString?
a4958e7 @jashkenas whitespace
authored
243
782de87 @michaelficarra updated comment for arrayEqual function, mentioning that it tests for
michaelficarra authored
244 # See http://wiki.ecmascript.org/doku.php?id=harmony:egal
5ae4e06 @michaelficarra cake test: change `eq` to use egal semantics, paralleling `arrayEq`
michaelficarra authored
245 egal = (a, b) ->
dd11528 @michaelficarra changed occurrences of deepEqual to new, self-defined arrayEqual for
michaelficarra authored
246 if a is b
247 a isnt 0 or 1/a is 1/b
5ae4e06 @michaelficarra cake test: change `eq` to use egal semantics, paralleling `arrayEq`
michaelficarra authored
248 else
249 a isnt a and b isnt b
250
251 # A recursive functional equivalence helper; uses egal for testing equivalence.
252 arrayEgal = (a, b) ->
253 if egal a, b then yes
dd11528 @michaelficarra changed occurrences of deepEqual to new, self-defined arrayEqual for
michaelficarra authored
254 else if a instanceof Array and b instanceof Array
255 return no unless a.length is b.length
5ae4e06 @michaelficarra cake test: change `eq` to use egal semantics, paralleling `arrayEq`
michaelficarra authored
256 return no for el, idx in a when not arrayEgal el, b[idx]
dd11528 @michaelficarra changed occurrences of deepEqual to new, self-defined arrayEqual for
michaelficarra authored
257 yes
258
b1300bd @michaelficarra fix typo; thanks @Nami-Doc
michaelficarra authored
259 global.eq = (a, b, msg) -> ok egal(a, b), msg ? "Expected #{a} to equal #{b}"
260 global.arrayEq = (a, b, msg) -> ok arrayEgal(a,b), msg ? "Expected #{a} to deep equal #{b}"
dd11528 @michaelficarra changed occurrences of deepEqual to new, self-defined arrayEqual for
michaelficarra authored
261
c6c988a @jashkenas Revert "Ensure test failures get fully outputted."
authored
262 # When all the tests have run, collect and print errors.
263 # If a stacktrace is available, output the compiled function source.
264 process.on 'exit', ->
265 time = ((Date.now() - startTime) / 1000).toFixed(2)
0ded5b3 @disnet removing old changes
disnet authored
266 message = "passed #{passedTests} tests in #{time} seconds#{reset}"
c6c988a @jashkenas Revert "Ensure test failures get fully outputted."
authored
267 return log(message, green) unless failures.length
268 log "failed #{failures.length} and #{message}", red
269 for fail in failures
c407a0b @jwalton Fix reporting of errors in 'cake test'
jwalton authored
270 {error, filename, description, source} = fail
c6c988a @jashkenas Revert "Ensure test failures get fully outputted."
authored
271 console.log ''
c407a0b @jwalton Fix reporting of errors in 'cake test'
jwalton authored
272 log " #{description}", red if description
c6c988a @jashkenas Revert "Ensure test failures get fully outputted."
authored
273 log " #{error.stack}", red
c407a0b @jwalton Fix reporting of errors in 'cake test'
jwalton authored
274 console.log " #{source}" if source
c6c988a @jashkenas Revert "Ensure test failures get fully outputted."
authored
275 return
276
b9c2236 @jashkenas Merging in MichaelFicarra's refactorTests branch.
authored
277 # Run every test in the `test` folder, recording failures.
d2d02bf @michaelficarra Cakefile: build:full exits unsuccessfully when tests or builds fail;
michaelficarra authored
278 files = fs.readdirSync 'test'
9d29a83 @alubbe entire generator test file is now ignored if generators are not avail…
alubbe authored
279
280 # Ignore generators test file if generators are not available
c02a403 @alubbe fixed misspelling in Cakefile
alubbe authored
281 generatorsAreAvailable = '--harmony' in process.execArgv or
282 '--harmony-generators' in process.execArgv
85c7fff @alubbe improved readability of cakefile generator check
alubbe authored
283 files.splice files.indexOf('generators.coffee'), 1 if not generatorsAreAvailable
9d29a83 @alubbe entire generator test file is now ignored if generators are not avail…
alubbe authored
284
c0aac8e @sgentle use helpers.isCoffee in test runner
sgentle authored
285 for file in files when helpers.isCoffee file
1a83544 @spinda Modify extension handling to allow for .coffee.md
spinda authored
286 literate = helpers.isLiterate file
d2d02bf @michaelficarra Cakefile: build:full exits unsuccessfully when tests or builds fail;
michaelficarra authored
287 currentFile = filename = path.join 'test', file
288 code = fs.readFileSync filename
289 try
4fb3a31 @jashkenas fixing block comment indentation
authored
290 CoffeeScript.run code.toString(), {filename, literate}
d2d02bf @michaelficarra Cakefile: build:full exits unsuccessfully when tests or builds fail;
michaelficarra authored
291 catch error
292 failures.push {filename, error}
293 return !failures.length
f360fba @sstephenson Add test:browser task for running the test suite against the merged b…
sstephenson authored
294
295
0ded5b3 @disnet removing old changes
disnet authored
296 task 'test', 'run the CoffeeScript language test suite', ->
297 runTests CoffeeScript
f360fba @sstephenson Add test:browser task for running the test suite against the merged b…
sstephenson authored
298
299
0ded5b3 @disnet removing old changes
disnet authored
300 task 'test:browser', 'run the test suite against the merged browser script', ->
f360fba @sstephenson Add test:browser task for running the test suite against the merged b…
sstephenson authored
301 source = fs.readFileSync 'extras/coffee-script.js', 'utf-8'
5236bb2 @sstephenson Remove the window hack in test:browser.
sstephenson authored
302 result = {}
9785fd0 @jashkenas Bumping site.
authored
303 global.testingBrowser = yes
5236bb2 @sstephenson Remove the window hack in test:browser.
sstephenson authored
304 (-> eval source).call result
0ded5b3 @disnet removing old changes
disnet authored
305 runTests result.CoffeeScript
Something went wrong with that request. Please try again.