mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
simplified test file skipping (#4996)
This commit is contained in:
parent
820942c3d0
commit
5a43b2d7c5
3 changed files with 17 additions and 14 deletions
22
Cakefile
22
Cakefile
|
@ -425,12 +425,6 @@ runTests = (CoffeeScript) ->
|
|||
catch err
|
||||
onFail description, fn, err
|
||||
|
||||
global.supportsAsync = try
|
||||
new Function('async () => {}')()
|
||||
yes
|
||||
catch
|
||||
no
|
||||
|
||||
helpers.extend global, require './test/support/helpers'
|
||||
|
||||
# When all the tests have run, collect and print errors.
|
||||
|
@ -448,10 +442,18 @@ runTests = (CoffeeScript) ->
|
|||
console.log " #{source}" if source
|
||||
return
|
||||
|
||||
# Run every test in the `test` folder, recording failures.
|
||||
files = fs.readdirSync 'test'
|
||||
unless global.supportsAsync # Except for async tests, if async isn’t supported.
|
||||
files = files.filter (filename) -> filename isnt 'async.coffee'
|
||||
# Run every test in the `test` folder, recording failures, except for files
|
||||
# we’re skipping because the features to be tested are unsupported in the
|
||||
# current Node runtime.
|
||||
testFilesToSkip = []
|
||||
skipUnless = (featureDetect, filenames) ->
|
||||
unless (try new Function featureDetect)
|
||||
testFilesToSkip = testFilesToSkip.concat filenames
|
||||
skipUnless 'async () => {}', ['async.coffee', 'async_iterators.coffee']
|
||||
skipUnless 'async function* generator() { yield 42; }', ['async_iterators.coffee']
|
||||
skipUnless 'var a = 2 ** 2; a **= 3', ['exponentiation.coffee']
|
||||
files = fs.readdirSync('test').filter (filename) ->
|
||||
filename not in testFilesToSkip
|
||||
|
||||
startTime = Date.now()
|
||||
for file in files when helpers.isCoffee file
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# Functions that contain the `await` keyword will compile into async functions,
|
||||
# supported by Node 7.6+, Chrome 55+, Firefox 52+, Safari 10.1+ and Edge.
|
||||
# But runtimes that don’t support the `await` keyword will throw an error,
|
||||
# even if we put `return unless global.supportsAsync` at the top of this file.
|
||||
# Therefore we need to prevent runtimes which will choke on such code from even
|
||||
# But runtimes that don’t support the `await` keyword will throw an error just
|
||||
# from parsing this file, even without executing it, even if we put
|
||||
# `return unless try new Function 'async () => {}'` at the top of this file.
|
||||
# Therefore we need to prevent runtimes which will choke on such code from
|
||||
# parsing it, which is handled in `Cakefile`.
|
||||
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ testRepl "keeps running after runtime error", (input, output) ->
|
|||
eq 'undefined', output.lastWrite()
|
||||
|
||||
testRepl "#4604: wraps an async function", (input, output) ->
|
||||
return unless global.supportsAsync
|
||||
return unless try new Function 'async () => {}' # Feature detect support for async functions.
|
||||
input.emitLine 'await new Promise (resolve) -> setTimeout (-> resolve 33), 10'
|
||||
setTimeout ->
|
||||
eq '33', output.lastWrite()
|
||||
|
|
Loading…
Reference in a new issue