tc39 / eshost

A uniform wrapper around a multitude of ECMAScript hosts. CLI: https://github.com/bterlson/eshost-cli
Other
142 stars 36 forks source link

Allow a transpiler to be provided for an agent #19

Closed littledan closed 7 years ago

littledan commented 7 years ago

The purpose of this change is to allow transpilation, e.g., with Babel, e.g., to run test262 tests, as in this tree https://github.com/littledan/test262-harness/tree/babel

jugglinmike commented 7 years ago

I think this patch justifies a refactoring in the test environment, but it will be safer to do that in a follow-up commit that has no change to application logic.

One minor change I would suggest is generalizing the option name. Although the use case @littledan has in mind is "transpilation" with Babel, I think this functionality would be equally useful in vetting JavaScript minifiers. The expectation is slightly different (i.e. that it doesn't effect test results), but the usage would be the same.

So what do you think about calling this transform instead of transpile?

Whatever we name the new option, could you please add documentation for it in the relevant section of the project's README.md file?

littledan commented 7 years ago

@jugglinmike Thanks for your comments; applied.

littledan commented 7 years ago

cc @bterlson

bterlson commented 7 years ago

Looks good. Re: tests, I suppose I should just merge modules with partial support, or separate out the test refactorings from that branch.

jugglinmike commented 7 years ago

gh-24 introduced changes that cause this patch to fail in the continuous integration environment. The quickest fix would be to rebase this branch and apply this patch:

diff --git a/test/runify.js b/test/runify.js
index 826e71f..9609709 100644
--- a/test/runify.js
+++ b/test/runify.js
@@ -368,6 +368,11 @@ hosts.forEach(function (record) {
     function transform(x) { return `print("${x}")`; }

     before(function() {
+      if (process.env['ESHOST_SKIP_' + host.toUpperCase()]) {
+        this.skip();
+        return;
+      }
+
       let options = { hostPath: host, transform }
       return runify.createAgent(type, options).then(a => agent = a);
     });

It's highly duplicative of existing logic and further justification for refactoring that test logic. But it should do in a pinch.

@littledan You've been quite patient with all this, and I'd be happy to apply this on your behalf. I don't think there's anything particularly controversial here, but I prefer to err on the side of caution when it comes to rebasing the work of others. Let me know!

littledan commented 7 years ago

Feel free to do this rebase for me; if you don't have time, I'll get back to it later in the week.

jugglinmike commented 7 years ago

Got it. I've submitted an updated version at gh-27.

dilijev commented 7 years ago

27 has been merged.