Skip to content
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

Initial tests for Dynamic Imports #1588

Merged
merged 28 commits into from Oct 4, 2018
Merged

Initial tests for Dynamic Imports #1588

merged 28 commits into from Oct 4, 2018

Conversation

rwaldron
Copy link
Contributor

@rwaldron rwaldron commented Jun 5, 2018

This is not ready for in depth review yet

Ref #1164

@dnalborczyk
Copy link
Contributor

dnalborczyk commented Aug 21, 2018

hey guys, sorry for hijacking this PR.

we're trying to make esm https://github.com/standard-things/esm (a node module supporting ES modules, dynamic import, and also a bridge to commonjs) ECMA-262 compliant as much as possible, and we are running a selection of test262 tests, mainly everything from module-code, import and export.

we also started running against this branch/PR to get some test coverage for dynamic import, although we know it might be not in it's final stages, and hasn't been reviewed yet.

there are a couple of tests involving import(''), and I was wondering how the result should be evaluated? meaning, what determines the test to be successful? since browsers, and node --experimental-modules, as well as esm are returning a rejected Promise not being able to find a module.

for example: module-code/dynamic-import/syntax-nested-arrow-assignment-expression-empty-str-arg.js

any hints or pointers are much appreciated. thank you in advance!

@ljharb
Copy link
Member

ljharb commented Aug 21, 2018

Since it’s a URL, there’s no reason that an empty string necessarily won’t resolve to a module.

@leobalter
Copy link
Member

Rick is out until September and I didn't have the chance to review this PR yet. I'm not sure at what point this PR is still a WIP with parts not done yet and I'm afraid I could be over reviewing things Rick already has plans to change.

My current work efforts are based on class fields related stuff but I hope we can be back to this PR anytime.

@dnalborczyk
Copy link
Contributor

@ljharb thank you, good point. I 'm not sure about the intricacies of dynamic imports, but I thought the test-262 suite is conclusive, and would contain everything needed to run a test. meaning, either I would assume a flag as some indicator, or some harness helper method, or the expected '' module (although I'm not sure how this can be accomplished).

@leobalter makes sense, no worries! it can wait, there's no rush. thank you for getting back though!

Meanwhile I might just blacklist those tests for the time being, or find another temporary workaround, e.g. parsing for import(''), and expect a rejected Promise.

@ljharb
Copy link
Member

ljharb commented Aug 21, 2018

Module loading is engine-specific and it’d be very hard to cover this fully with test262.

@rwaldron
Copy link
Contributor Author

Module loading is engine-specific and it’d be very hard to cover this fully with test262.

Presently we use engine-specific machinery, provided via eshost runtime definitions, to ensure that module loading operations occur within the scope of each host's capabilities. This is how both module code and dynamic import test material is executed.

@rwaldron rwaldron changed the title WIP: Dynamic Imports: initial cases, templates, non-generated tests and fixtures WIP: Dynamic Imports Sep 12, 2018
@leobalter
Copy link
Member

I just rebased the branch to verify the CI again. No other changes introduced here so far.

@rwaldron
Copy link
Contributor Author

rwaldron commented Oct 2, 2018

@dnalborczyk I think your question is more appropriate for the proposal/authors.

Meanwhile I might just blacklist those tests for the time being, or find another temporary workaround, e.g. parsing for import(''), and expect a rejected Promise.

"parsing for import('')", and evaluating what it returns are two very distinct aspects of the feature, which occur during different phases of a JS program's lifetime.

@leobalter
Copy link
Member

leobalter commented Oct 3, 2018

I finally fixed the duplicate tests, they should pass on the CI process now.

git grep -h -E 'path\: (.*)' src/dynamic-import/ | sort | uniq -d should be helpful as a future reference

@jdalton
Copy link
Member

jdalton commented Oct 3, 2018

@leobalter The file module-code/dynamic-import/catch/nested-arrow-import-catch-instn-iee-err-ambiguous-import.js is trying to import a missing file (maybe a path mixup)

@leobalter
Copy link
Member

Thanks for catching this up. This is still WIP but you definitely caught some commit mixup. I’ll restore this file tomorrow.

Please, Let me know if you find anything else from the tests. Looking forward to complete this coverage.

@jdalton
Copy link
Member

jdalton commented Oct 4, 2018

Np. There's a couple more to investigate for missing files:

test/language/module-code/dynamic-import/catch/nested-async-function-await-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/nested-async-function-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/nested-async-function-return-await-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/nested-block-import-catch-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/nested-block-labeled-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/nested-do-while-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/nested-else-import-catch-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/nested-function-import-catch-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/nested-if-import-catch-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/nested-while-import-catch-instn-iee-err-ambiguous-import.js
test/language/module-code/dynamic-import/catch/top-level-import-catch-instn-iee-err-ambiguous-import.js

@leobalter
Copy link
Member

@jdalton this should be fixed for now

@leobalter
Copy link
Member

ok, with the latest commits I'm able to run all the tests just OK w/ JSC and V8.

[~/dev/test262] dynamic-import
test262-harness --hostType=jsc --hostPath=`which jsc` -- 'test/language/module-code/dynamic-import/**/*'
Ran 272 tests
272 passed
0 failed
[~/dev/test262] dynamic-import
test262-harness --hostType=d8 --hostPath=`which v8` -- 'test/language/module-code/dynamic-import/**/*'
Ran 272 tests
272 passed
0 failed

@leobalter
Copy link
Member

I'm also migrating the checklist to #1164

@leobalter leobalter changed the title WIP: Dynamic Imports Initial tests for Dynamic Imports Oct 4, 2018
@leobalter
Copy link
Member

Everything should be all set for an initial merge and get feedback from implementations while we continue working on the missing coverage found (see #1164).

@rwaldron ok to land this from your side?

@rwaldron
Copy link
Contributor Author

rwaldron commented Oct 4, 2018

Just a note to test262-harness users: you MUST be upgraded to >=test262-harness@4.5.0 for these tests.

@rwaldron rwaldron merged commit 8e8a593 into master Oct 4, 2018
@leobalter leobalter deleted the dynamic-import branch October 4, 2018 20:16
await import('./eval-self-once-script.js');

assert.sameValue(global.evaluated, 2, 'global property was defined and incremented only once');
}).then($DONE, $DONE);
Copy link
Member

@jdalton jdalton Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ The global.evaluated value should be 1 and not 2.

Update:

Is this a dup of test/language/module-code/dynamic-import/eval-self-once-module.js?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended to be this way. It's a very similar test but it is evaluated as a script and it loads itself again following this:

Success path

  The completion value of any subsequent call to HostResolveImportedModule after
  FinishDynamicImport has completed, given the arguments referencingScriptOrModule
  and specifier, must be a module which has already been evaluated, i.e. whose
  Evaluate concrete method has already been called and returned a normal completion.

you can find this normative text here: https://tc39.github.io/proposal-dynamic-import/#sec-hostimportmoduledynamically

a script file loading it self ends up being evaluated twice. The first time it was not evaluated as a Module Record or using HostResolveImportedModule. This is tricky.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the info in the metadata says the file is meant to run as a script code (strict or non strict) and not as a module code, which has a different evaluation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description of the assert should probably be changed

'global property was defined and incremented only once'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdalton thanks for providing such quick feedback!

includes: [fnGlobalObject.js]
flags: [async]
flags: [async, module]
Copy link
Member

@jdalton jdalton Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this test was renamed the resource it's loading wasn't (in source of eval-self-once-module).

Update:

Fixed in another commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that, I left the changes in the editor without saving to the file and pushed the other commit.


---*/

if (true) import('./eval-gtbndng-indirect-update-dflt_FIXTURE.js');
Copy link
Member

@jdalton jdalton Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ Based on INTERPRETING async flagged tests should print 'Test262:AsyncTestComplete' or 'Test262:AsyncTestFailure: ' + reason by way of doneprintHandle. Without printing a complete or fail the interpretation can hit a test timeout and mark it as a test failure.

Tests affected:

test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-gtbndng-indirect-update-dflt.js
test/language/module-code/dynamic-import/usage/nested-if-braceless-eval-gtbndng-indirect-update.js
test/language/module-code/dynamic-import/usage/nested-if-braceless-returns-promise.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I think these are all from my original batch of generated tests, which definitely need work. Please keep the feedback and review coming <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants