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

Hook up js-interpreter-tyrant test runner for our patched interpreter #13974

Merged
merged 12 commits into from
Mar 28, 2017

Conversation

pcardune
Copy link
Contributor

Now we can patch it like crazy and have an idea of what we broke and/or fixed!

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

I've got a couple of questions but this is all looking really good.

@@ -14,6 +14,7 @@
"test:unit": "grunt unitTest",
"test:integration": "grunt integrationTest",
"test:entry": "grunt karma:entry",
"test:interpreter": "./node_modules/@code-dot-org/js-interpreter-tyrant/bin/run.js --run --diff --root ./test/interpreter --interpreter ./test/interpreter/patched-interpreter.js --progress",
Copy link
Contributor

Choose a reason for hiding this comment

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

Because you list "bin": "bin/run.js" in js-interpreter-tyrant's package.json, it will be symlinked into node_modules/.bin, which is already in the path when running an npm script. That means (I think) you can write this line as:

"test:interpreter": "run.js --run --diff --root ./test/interpreter --interpreter ./test/interpreter/patched-interpreter.js --progress",

...and probably should, as it's a little less configuration-dependent (it's possible customize the node_modules and .bin locations, though I'm not sure why you would).

This would be even nicer if you had js-interpreter-tyrant export a js-interpreter-tyrant executable instead, so it could be

"test:interpreter": "js-interpreter-tyrant --run --diff --root ./test/interpreter --interpreter ./test/interpreter/patched-interpreter.js --progress",

...as you describe in the README for that tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue here is yarn 0.16.1. It doesn't actually put the js-interpreter-tyrant script in node_modules/.bin because js-interpreter-tyrant is under the @code-dot-org scope :(. So it ends up in node_modules/@code-dot-org/.bin which doesn't make any sense and isn't in the path. This has been fixed in newer versions of yarn. So we really need to upgrade.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh, what a headache. Leave it for now. Hopefully we'll remember to clean it up after we upgrade.

@@ -34,10 +35,15 @@
"browser": {
"blockly": "./build/package/js/blockly.js"
},
"resolutions": {
"eshost": "github:pcardune/eshost#f3fa7fa",
"test262-compiler": "github:pcardune/test262-compiler#ffa0dff"
Copy link
Contributor

Choose a reason for hiding this comment

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

Two questions:

  1. It looks like the resolutions field is a yarn-specific extension of package.json. Are we no longer backwards-compatible with npm?

  2. What is customized about these repos, and do we expect to switch back to an upstream at some point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. I think I might be able to get rid of this resolutions thing actually. It should get taken care of by what is in the yarn.lock file.

  2. eshost includes a new agent definition for js-interpreter. I have an issue out asking for a better way to add new agents without having them live in the eshost repo. Haven't heard back yet :(. test262-compiler just has a small (but important) bug fix which I likewise have a pull request out for but haven't heard back yet either.

pull requests in question:

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome 👍

scope = scope.parentScope;
}
this.throwException('Unknown identifier: ' + nameStr);
return this.UNDEFINED;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious coverage report here. Does this.throwException throw a native exception? If so, should the return line be removed as unreachable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It throws an exception sometimes. The case where it doesn't is definitely not covered here!

Though frankly, this code is only really covered by integration tests, so I really need to go back and add unit tests.

@@ -0,0 +1,6 @@
#!/bin/bash
set -x
./node_modules/@code-dot-org/js-interpreter-tyrant/bin/run.js --threads 1 --run --diff --verbose
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar note here, but since node_modules/.bin isn't in scope you'd use

`npm bin`/run.js --threads 1 --run --diff --verbose

If we're dropping npm support, I suppose `yarn bin` is preferable - it works the same way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same issue with yarn 0.16.1 as stated above.

task :interpreter do
run_tests_if_changed('interpreter', ['apps/src/lib/tools/jsinterpreter/patchInterpreter.js']) do
TestRunUtils.run_interpreter_tests
end
Copy link
Contributor

Choose a reason for hiding this comment

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

So... how long does this take, on one container on Circle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a couple hours I think? Haven't gotten it to run yet so will find out soon!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I guess it takes more than 2 hours because circle is timing out. I don't think there is a particularly quick fix for that.

@@ -0,0 +1,99 @@
const Interpreter = require('@code-dot-org/js-interpreter');

module.exports = function patchInterpreter() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is all just extracted from JSInterpreter.js. We have to use node.js style exports because this needs to run inside node and the browser.

@@ -19,7 +19,7 @@ def filter_rubocop(modified_files)
RUBY_EXTENSIONS.any? {|ext| f.end_with? ext }
end
modified_ruby_scripts = modified_files.select do |f|
first_line = File.exist?(f) ? File.open(f).first : nil
first_line = File.file?(f) ? File.open(f).first : nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

needed to change this so it wouldn't get screwed up with git submodules which show up in git's list of "modified files" but is actually a directory.

@@ -14,6 +14,7 @@
"test:unit": "grunt unitTest",
"test:integration": "grunt integrationTest",
"test:entry": "grunt karma:entry",
"test:interpreter": "./node_modules/@code-dot-org/js-interpreter-tyrant/bin/run.js --run --diff --root ./test/interpreter --interpreter ./test/interpreter/patched-interpreter.js --progress",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue here is yarn 0.16.1. It doesn't actually put the js-interpreter-tyrant script in node_modules/.bin because js-interpreter-tyrant is under the @code-dot-org scope :(. So it ends up in node_modules/@code-dot-org/.bin which doesn't make any sense and isn't in the path. This has been fixed in newer versions of yarn. So we really need to upgrade.

@@ -34,10 +35,15 @@
"browser": {
"blockly": "./build/package/js/blockly.js"
},
"resolutions": {
"eshost": "github:pcardune/eshost#f3fa7fa",
"test262-compiler": "github:pcardune/test262-compiler#ffa0dff"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. I think I might be able to get rid of this resolutions thing actually. It should get taken care of by what is in the yarn.lock file.

  2. eshost includes a new agent definition for js-interpreter. I have an issue out asking for a better way to add new agents without having them live in the eshost repo. Haven't heard back yet :(. test262-compiler just has a small (but important) bug fix which I likewise have a pull request out for but haven't heard back yet either.

pull requests in question:

scope = scope.parentScope;
}
this.throwException('Unknown identifier: ' + nameStr);
return this.UNDEFINED;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It throws an exception sometimes. The case where it doesn't is definitely not covered here!

Though frankly, this code is only really covered by integration tests, so I really need to go back and add unit tests.

@@ -0,0 +1,6 @@
#!/bin/bash
set -x
./node_modules/@code-dot-org/js-interpreter-tyrant/bin/run.js --threads 1 --run --diff --verbose
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same issue with yarn 0.16.1 as stated above.

task :interpreter do
run_tests_if_changed('interpreter', ['apps/src/lib/tools/jsinterpreter/patchInterpreter.js']) do
TestRunUtils.run_interpreter_tests
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a couple hours I think? Haven't gotten it to run yet so will find out soon!

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

Changes LGTM (and I'm very excited about having this fantastic coverage integrated). Looks like some pretty gnarly failures in the Circle build though. Any idea what's going on there?

@pcardune
Copy link
Contributor Author

Broken tests here are due to a bug I introduced in the most recent release of @code-dot-org/js-interpreter. Fixing that here first: code-dot-org/JS-Interpreter#5

@pcardune pcardune merged commit 20e9c33 into staging Mar 28, 2017
@pcardune pcardune deleted the pcardune-interpreter-tests branch March 28, 2017 22:49
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

2 participants