-
Notifications
You must be signed in to change notification settings - Fork 482
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
RFC: Testing Module Semantics #519
Comments
Regarding the mixing of test and non-test files, I'd suggest |
From the perspective of the That said, it may also be a little harder to implement across platforms. Is it possible that a Windows-based host would have trouble with the path separator? The fix would be easy, but it would also raise the bar for getting the tests running. Maybe we could get away with a file name prefix: import * as ns from './_fixture_dep.js'; Although a suffix might be even better because it would allow for related files to appear together in lexicographically-sorted directory listings. |
Although I suppose that by using a |
Oh, thanks @littledan! GitHub's "aklein" is a doppleganger or IRC's "aklein". |
From an implementation point of view, using "./" as the prefix and requiring it to mean current directory seems fine to me (though I think it would likely also be fine to require a subdirectory there, if that was easier for the test runner). I don't have enough experience with the details of the test runner to be able to choose meaningfully between 1-3, although my inclination, too, is for something like (1). |
I'm starting to think that we don't need to specify the behavior when This calls for a tightening up of the rest of the language, though. We'll want
And extend the description of file loading:
|
For anyone following along: I've submitted a few pull requests to test this part of the spec, following the approach we've been discussing here:
I chose to demarcate non-test files with a trailing underscore ( There's a lot of code there, but I'd really appreciate it if anyone here could take a look and share some feedback! |
I don't like the convention of trailing underscore. It seems easy to miss. Leading underscore seems better, but what about a different file extension entirely? |
I'd prefer that the demarcation come after the "traditional" file name. This ensures that related files will be displayed together in most (all?) views of the file hierarchy. (For instance, the non-test-file I think there's good reason to avoid a new file extension, though: it may confuse syntax highlighters on GitHub or in contributors' editors/IDEs. Would you be satisfied with a "louder" suffix? Maybe |
Good points (though I don't think the highlighting bit is too important, it's easy to change file mode in any decent editor). _FIXTURE or something would be better in my opinion, especially now that MAX_PATH is fixed :-P |
Alrighty--I've updated the relevant pull requests to use |
@aklein @boingoing and @syg I understand you are all working on ES2015 module implementations, so if you have a moment, your input would be especially helpful here. Thanks!
Because ES2015 intentionally omits necessary details around module resolution (see HostResolveImportedModule), functional tests cannot be written based on the specification alone.
In order to author meaningful tests, Test262 contributors and runtime implementors have to come to an agreement for additional semantics. It should be clear that conformance to this contract is a prerequisite only for Test262 and not for ECMAScript compliance generally.
I recently proposed a new document named
INTERPRETNG.md
to house exactly this kind of information. If that is accepted, we can extend it with the following text:But the most contentious detail (as I see it) is resolving module specifiers. The design should be as simple as possible in order to limit the amount of custom behavior necessary to execute the tests. We can take a cue from common file system/web conventions to produce a design that can work out-of-the-box for many consumers.
Here's what I have in mind:
I think this will give authors just enough power to test the semantics while promoting a healthy file structure, and it limits the imposition on consumers. One potential issue is that it means Test262 will define non-test files alongside test files. I can think of three ways around this:
flags: [not-a-test]
)specify that loaders should resolve all modules from there.
they were valid assertion-less tests
#2
seems too onerous for implementors (it also may preclude meaningful tests since only fixture files--not test files--will be able to import themselves).#3
seems easiest for everyone, but the informality/inefficiency of it irks me. I like#1
the best.Does this sound good? Is there some detail I'm missing? Or some way what I'm proposing could be improved?
The text was updated successfully, but these errors were encountered: