-
-
Notifications
You must be signed in to change notification settings - Fork 1
Handle bonus tests in run script #15
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ json = (require 'dkjson').use_lpeg! | |
| getopt = require 'alt_getopt' | ||
| local verbose | ||
|
|
||
| import p from require 'moon' | ||
| -- import p from require 'moon' | ||
|
|
||
|
|
||
| -- ----------------------------------------------------------- | ||
|
|
@@ -47,12 +47,12 @@ validate = (args) -> | |
| -- ----------------------------------------------------------- | ||
| run_tests = (slug, dir) -> | ||
| ok, err = lfs.chdir dir | ||
| assert ok, err | ||
| assert ok, "run_tests: cannot change to directory #{dir}: #{err}" | ||
|
|
||
| -- unskip tests | ||
| cmd = "perl -i.bak -pe 's{^\\s*\\Kpending\\b}{it}' *_spec.moon" | ||
| ok, result_type, status = os.execute cmd | ||
| assert ok | ||
| assert ok, "run_tests: failed to unskip tests with command #{cmd}: #{result_type} #{status}" | ||
|
|
||
| -- launch `busted` | ||
| fh = io.popen 'busted -o json', 'r' | ||
|
|
@@ -114,14 +114,15 @@ run_tests = (slug, dir) -> | |
| name: test.element.name, | ||
| message: test.trace.message, | ||
| } | ||
|
|
||
|
|
||
| -- p results | ||
| results | ||
|
|
||
|
|
||
| -- ----------------------------------------------------------- | ||
| get_test_bodies = (slug, dir) -> | ||
| ok, err = lfs.chdir dir | ||
| assert ok, err | ||
| assert ok, "get_test_bodies: cannot change to directory #{dir}: #{err}" | ||
|
|
||
| order = {} | ||
| bodies = {} | ||
|
|
@@ -139,6 +140,9 @@ get_test_bodies = (slug, dir) -> | |
| in_test = false | ||
|
|
||
| for line in fh\lines! | ||
| -- do not look for any tests after this line, they won't run in test environment | ||
| break if line\match '-- The next tests are optional.' | ||
|
|
||
| if line\match '^%s+describe ' | ||
| if test_name | ||
| bodies[test_name] = table.concat test_body, '\n' | ||
|
|
@@ -160,13 +164,14 @@ get_test_bodies = (slug, dir) -> | |
|
|
||
| fh\close! | ||
| bodies[test_name] = table.concat test_body, '\n' | ||
| -- p {:order, :bodies} | ||
| order, bodies | ||
|
|
||
|
|
||
| -- ----------------------------------------------------------- | ||
| write_results = (slug, test_results, names, bodies, dir) -> | ||
| ok, err = lfs.chdir dir | ||
| assert ok, "#{err}: #{dir}" | ||
| assert ok, "write_results: cannot change to directory #{dir}: #{err}" | ||
|
|
||
| results = version: 2, status: nil, tests: {} | ||
|
|
||
|
|
@@ -179,7 +184,11 @@ write_results = (slug, test_results, names, bodies, dir) -> | |
| status = 'pass' | ||
| for name in *names | ||
| test = test_results[name] | ||
| assert test, "no test result for #{name}" | ||
| if not test | ||
| status = 'error' | ||
| results.message = "missing test result for #{name}" | ||
| break | ||
|
Comment on lines
+187
to
+190
Contributor
Author
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. That assertion was causing tests to error out with "An error occurred while running your tests.". I need to properly return the test results with a more appropriate message. |
||
|
|
||
| status = 'fail' if test.status != 'pass' | ||
| test.test_code = bodies[name] | ||
| table.insert results.tests, test | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is the main fix. Bonus tests reside below this marker. They are not run in the test runner, and the runner complains (down below on line 187) if the test output does not match the test bodies.