simplified test file skipping (#4996) (#5003)

simplified test file skipping (#4996)
This commit is contained in:
Robert de Forest 2018-03-12 19:03:44 -07:00 committed by Geoffrey Booth
parent 820942c3d0
commit 5a43b2d7c5
3 changed files with 17 additions and 14 deletions

View File

@ -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 isnt supported.
files = files.filter (filename) -> filename isnt 'async.coffee'
# Run every test in the `test` folder, recording failures, except for files
# were 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

View 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 dont 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 dont 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`.

View File

@ -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()