Test builder: introduce CLI options for specific sub-tasks#419
Test builder: introduce CLI options for specific sub-tasks#419rossberg merged 6 commits intoWebAssembly:masterfrom
Conversation
- build the pure JS tests with --js out_dir - build the WPT tests with --html out_dir - build the front page with --front out_dir
To determine that a file contains a testharness Web Platform test case, the runner looks for an instance of a <script src=/resources/testharness.js>. So we use this URI when generating the WPT test cases. In this mode, the testharness files don't need to be generated, since the WPT server serves them. The harness files aren't desired for the pure JS environment as well, since the JS shell has to provide a shim mimicking the testharness.js APIs.
205af8c to
a127881
Compare
|
(not a work-in-progress anymore) So let me recap: the script has been specialized for different separate objectives, instead of generating everything at once:
@mtrofin and/or @rossberg-chromium and/or anybody who'd want to, can you please have a look? Happy to answer any questions. |
automatically generated. The WPT harness has a way to generate an expectation file specifying which tests are known to be failing, and which ones are known to be passing. However, to use this feature, it must have a unique identifier for each combination of (file, test). To handle this, we generate a unique test number for each call to test() in the wast harness.
| def convert_one_wast_file(inputs): | ||
| wast_file, js_file = inputs | ||
| print('Compiling {} to JS...'.format(wast_file)) | ||
| return run(WASM_EXEC, wast_file, '-h', '-o', js_file) |
There was a problem hiding this comment.
The output JS file is intended to be used in both a pure JS environment (shell) and the WPT environment; the WPT environment redefines all the testing primitives, as you know.
There was a problem hiding this comment.
Er, sorry, never mind, I was confusing -h with --help. :)
test/build.py
Outdated
| for wast_file in glob.glob(os.path.join(WAST_DIR, '*.wast')): | ||
| for wast_file in glob.glob(os.path.join(WAST_TESTS_DIR, '*.wast')): | ||
| # Don't try to compile tests that are supposed to fail. | ||
| if 'fail.wast' in wast_file: |
There was a problem hiding this comment.
The runner in test/core checks for .fail., probably should be in sync.
There was a problem hiding this comment.
I see that, but this script doesn't call the run.py script which is in test/core. Are you suggesting to use it, or to implement specific logic that tests that the result is incorrect indeed? (the latter doesn't seem too valuable, because we can't specifically check that the failure happens at compile/instanciation/runtime)
Or something else?
There was a problem hiding this comment.
Much simpler: only suggesting to use the same condition to identify failure tests, i.e., test for the same substring.
test/harness/index.js
Outdated
| assert_true(e instanceof WebAssembly.CompileError, "expected invalid failure:"); | ||
| } | ||
| }, "A wast module that should be invalid or malformed."); | ||
| }, testNum() + "A wast module that should be invalid or malformed."); |
There was a problem hiding this comment.
Instead of doing this at every call site to test, why not do it inside test (or define a wrapper)?
rossberg
left a comment
There was a problem hiding this comment.
Thanks, lgtm, only a couple of small suggestions.
e628319 to
350ddaa
Compare
|
Thanks for the review, I've updated the PR. |
|
Thanks. I'll give @mtrofin a chance to comment too before merging. |
|
Apologies for only getting on this just now. I only have a nit comment (a typo). If you didn't mind, I'd like our colleague Eric Holk to take a peek, too - he has integrated this in our tree & CQ, and is, by now, way more familiar with it all than I am. I pointed him this way. Thanks! |
|
@mtrofin I haven't found your comment about the typo; could it be that it were not submitted? Thanks for the review! |
test/harness/index.js
Outdated
| let instanciated = err === null; | ||
| assert_true(instanciated, err); | ||
| }, testNum() + "module successfully instanciated"); | ||
| }, "module successfully instanciated"); |
There was a problem hiding this comment.
s/instanciated/instantiated
350ddaa to
9a43b19
Compare
| 'use strict'; | ||
|
|
||
| // WPT's assert_throw uses a list of predefined, hardcoded know errors. Since | ||
| let testNum = (function() { |
There was a problem hiding this comment.
Is this function to provide the stable test id (#415)? If we inserted a new test in the middle somewhere, this would lead to changing all the numbers afterwards, right? It'd be nice if we had an ID that was robust against that, although that probably leads to hardcoding all the IDs, which gets ugly. This function, as is, is definitely a helpful improvement though.
There was a problem hiding this comment.
It doesn't really provide a stable test identifier for all the test cases, but it does for all the ones that are automatically generated from the wast core tests. js-api and HTML tests still manage their id by themselves.
This is needed by the WPT harness. The wptrunner has the ability to automatically generate expectation files, which encode whether a single test is known to be passing or failing when run in a specific browser. For this to work, the (filename, test_id) couple needs to be unique, which makes sense. This is the reason why I've added the unique test id.
|
|
||
| function assert_soft_invalid(bytes) { | ||
| test(() => { | ||
| uniqueTest(() => { |
There was a problem hiding this comment.
What about switching the order of the arguments to uniqueTest? I'd find it easier to read if the test name came before the code for the test.
There was a problem hiding this comment.
I liked the consistency with the WPT test function, which takes arguments in the same order. I don't have a strong opinion though, so I am alright with changing it, if you strongly prefer it.
There was a problem hiding this comment.
Consistency with WPT test seems like a good enough reason. I prefer having the name first, but I think consistency is a stronger argument than my personal preferences, so I'd leave this as is.
This should allow us building only interesting subsets of tests for different purposes:
I need to make sure this will interact well at least with Spidermonkey and the webassembly website gh-pages before asking for review. If other browser vendors could confirm this fits their workflow too, this would be great.