Skip to content

simplify skipping unsupported tests (#4996) #4997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
18 changes: 10 additions & 8 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ header = """
# Used in folder names like `docs/v1`.
majorVersion = parseInt CoffeeScript.VERSION.split('.')[0], 10

# Patterns of names of test files which depend on currently absent features
testFilesToSkip = [
/async/ unless try new Function 'async () => {}'
/async_iterators/ unless try new Function 'async () * => {}'
/exponent_ops/ unless try new Function 'x = 3; x **= 2 ** 2; return x === 81'
].filter _.identity

featuresPresentFor = (fileName) ->
not testFilesToSkip.find (filePattern) -> fileName.match filePattern

# Log a message with a color.
log = (message, color, explanation) ->
Expand Down Expand Up @@ -425,12 +434,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.
Expand All @@ -450,8 +453,7 @@ runTests = (CoffeeScript) ->

# 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'
.filter featuresPresentFor

startTime = Date.now()
for file in files when helpers.isCoffee file
Expand Down