-
-
Notifications
You must be signed in to change notification settings - Fork 231
Add javascript code snippet validation #662
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
Conversation
Fixes common-workflow-language#594. To do this, it is needed to add jshint and refractor js_sandbox to so that it can be useful for this.
|
cwltool/validate_js.py
Outdated
}) | ||
) | ||
|
||
def dump_jshint_error(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs type information
cwltool/validate_js.py
Outdated
return [] | ||
|
||
return list(itertools.chain(* | ||
map(lambda x: get_expressions(x[1], schema.items, SourceLine(tool, x[0])), enumerate(tool)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cwltool/validate_js.py:47: error: "Schema" has no attribute "items"
from https://travis-ci.org/common-workflow-language/cwltool/jobs/348306873#L618
cwltool/load_tool.py
Outdated
@@ -187,7 +188,9 @@ def validate_document(document_loader, # type: Loader | |||
fetcher_constructor=None, # type: FetcherConstructorType | |||
skip_schemas=None, # type: bool | |||
overrides=None, # type: List[Dict] | |||
metadata=None, # type: Optional[Dict] | |||
metadata=None, # type: Optional[Dict], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra comma at the end of the type hint needs to be removed
Jenkins, test this please |
cwltool/validate_js.py
Outdated
linter_folder = resource_filename(__name__, "jshint") | ||
|
||
returncode, stdout, stderr = exec_js_process( | ||
path.join(linter_folder, "jshint_wrapper.js"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you should use get_data from https://github.com/common-workflow-language/cwltool/blob/master/tests/util.py (maybe that should be moved to the cwltool package?)
This is why the conformance tests are failing 🙂
@ThomasHickman You are getting closer! :-) |
@mr-c any idea what I'm still doing wrong? :) |
@ThomasHickman I haven't had a chance to try myself yet, but the next stage is to create a new virtualenv, https://github.com/common-workflow-language/common-workflow-language/blob/master/CONFORMANCE_TESTS.md#usage with |
Much closer!
|
Thanks again @ThomasHickman ; this is working everywhere but Windows. Ping me once that is fixed I'll do a final review and we can get this merged! |
@mr-c I've fixed the windows issue. Do you want to do a final review now? Note from above: I've removed the get_data to get_test_data change as I don't need |
The reason for using |
Yep, we know. But then it won't work if someone executes `cwltool.py`,
which is a shortcut for running cwltool without installing it first.
On Mar 12, 2018 15:22, "Peter Amstutz" <[email protected]> wrote:
The reason for using resource_stream is to support delivery as a Python
egg. Assuming files are on disk doesn't work when the module is stored in a
zip archive (I don't know if wheels have similar behavior.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#662 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABROCJ_lP5ws8RvHHK8jN6qPr8dN8cefks5tdoS-gaJpZM4SHXiy>
.
|
So if we want to be clever about it, the wrapper method should try resource_stream() first and then fall back to searching for the file? |
Sure, the decision that needs to be made can be moved to a separate issue
for discussion and (hopefully) quick implementation. @tetron, did you have
any other feedback on this PR?
|
A few comments -
However I don't want to hold up merging a useful feature on these, if @mr-c has tested it and it seems to be working well, I'm okay with merging now and doing a followup cleanup PR. |
@tetron Those seem fair enough comments. I also noticed while having a look at (1) that command line parameters were not getting propagated to validate_js in |
As before, as long as follow up issues are filed so we don't completely forget them I'm fine merging this now 😁 |
Codecov Report
@@ Coverage Diff @@
## master #662 +/- ##
==========================================
+ Coverage 62.4% 62.57% +0.17%
==========================================
Files 26 27 +1
Lines 4274 4414 +140
Branches 1147 1180 +33
==========================================
+ Hits 2667 2762 +95
- Misses 1324 1358 +34
- Partials 283 294 +11
Continue to review full report at Codecov.
|
@ThomasHickman @tetron Please file follow up issues as requested |
This fixes #594. Note: I refractored most of
exec_js
(in sandbox_js) intoexec_js_process
, so that I could use a function that runs a javascript process, inputs the results to stdin and captures them on stdout, while having a timeout.