-
Notifications
You must be signed in to change notification settings - Fork 2k
simplified test file skipping (#4996) #5003
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
Changes from 6 commits
c96f07e
8188dda
53abbe9
4c6fe65
7774864
0661ae8
26391af
2f4ebde
3fc6d46
2320b6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,24 @@ header = """ | |
# Used in folder names like `docs/v1`. | ||
majorVersion = parseInt CoffeeScript.VERSION.split('.')[0], 10 | ||
|
||
# CoffeeScript supports a range of major versions of NodeJS. Major versions of | ||
# NodeJS differ in the features they support. CoffeeScript features which | ||
# depend on features which are not available across all supported NodeJS | ||
# versions need only be tested against versions of NodeJS which provide the | ||
# required feature. The purpose of the `testFilesToSkip` array is to exempt | ||
# files which test features not available within the NodeJS runtime currently | ||
# under test. | ||
testFilesToSkip = [] | ||
|
||
# The `skipUnless` function adds file names to the `testFilesToSkip` array | ||
# when the feature(s) the file(s) depend on are not available. | ||
skipUnless = (code, names...) -> | ||
unless (try new Function code) | ||
testFilesToSkip = testFilesToSkip.concat names | ||
|
||
skipUnless 'async () => {}', 'async.coffee' | ||
skipUnless 'async () * => {}', 'async_iterators.coffee' | ||
skipUnless 'x = 3; x **= 2 ** 2; return x === 81', 'exponent_ops.coffee' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rdeforest If you don’t mind just changing this section so that the second parameters are arrays, and the first one is both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done and done. I also made the third test multi-line to serve as an example. I hope you agree it's an improvement. |
||
|
||
# Log a message with a color. | ||
log = (message, color, explanation) -> | ||
|
@@ -425,12 +443,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. | ||
|
@@ -450,8 +462,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 (filename) -> filename not in testFilesToSkip | ||
|
||
startTime = Date.now() | ||
for file in files when helpers.isCoffee file | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, if async functions aren’t supported, we should be skipping
async.coffee
andasync_iterators.coffee
both. It’s irrelevant in this case because you have the second check below, but if we’re thinking of this code as being self-documenting—i.e., ”the files to skip when this test fails are…”—then the second argument should be['async.coffee', 'async_iterators.coffee']
.Also I’m not sure how scalable this style is, when we add a test that isn’t < 60 characters or so, but we can worry about that when that day comes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's easy to re-factor for widely-applicable tests
Or we could get really wild...
Can you tell I <3 CoffeeScript? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. 😄 We try to make the CoffeeScript codebase a “best practices” example of how to write CoffeeScript, so code golf isn’t exactly what we’re going for. 😄 I think something as simple as making the second argument an array is probably sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my Perl roots showing. Sorry about that. :) As you said, we can cross that bridge when we come to it.