mumuki-javascript-runner 1.5.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/feedback_hook.rb +25 -0
- data/lib/javascript_runner.rb +6 -2
- data/lib/locales/en.yml +2 -0
- data/lib/locales/es.yml +2 -0
- data/lib/locales/pt.yml +2 -0
- data/lib/query_hook.rb +7 -3
- data/lib/test_hook.rb +11 -4
- data/lib/validation_hook.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 643e7004181714b9389b777b05343707d8c83af4b2aa5f409b433b7a290af5f7
|
4
|
+
data.tar.gz: 42fb43b4425a6ff90c7522ae1de68980c4f0683e80dfb083db70d89be6f8dd85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a7062a6a43c6caf6a4623c7977d3b4e052d06a830f2c8e3242c4d49706e9afb73cfb47d09a6e1674acbda7cc897c5730bd9c6351e5e4e1dad289b4a74d622a
|
7
|
+
data.tar.gz: 72ff4deb4365eef74e042ad1edfe9203e85cd379c8d7307d269348d8521e442153d9751c8ce985ae905d4b9b0627f54d1217f05dd83c7b1121b1539cad226522
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class JavascriptFeedbackHook < Mumukit::Hook
|
2
|
+
def run!(request, results)
|
3
|
+
content = request.content
|
4
|
+
test_results = test_failure_messages results
|
5
|
+
|
6
|
+
JavascriptExplainer.new.explain(content, test_results)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_failure_messages(results)
|
10
|
+
structured_test_results = results.test_results[0]
|
11
|
+
if structured_test_results.is_a? Array
|
12
|
+
structured_test_results.select { |it| it[1].failed? }.map { |it| it[2] }.join("\n")
|
13
|
+
else
|
14
|
+
''
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class JavascriptExplainer < Mumukit::Explainer
|
19
|
+
def explain_is_not_defined(_, test_results)
|
20
|
+
(/([a-zA-Z0-9_]+) is not defined/.match test_results).try do |it|
|
21
|
+
{identifier: it[1]}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/javascript_runner.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'mumukit'
|
2
2
|
|
3
|
+
I18n.load_translations_path File.join(__dir__, 'locales', '*.yml')
|
4
|
+
|
3
5
|
Mumukit.runner_name = 'javascript'
|
4
6
|
Mumukit.configure do |config|
|
5
|
-
config.docker_image = 'mumuki/mumuki-mocha-worker'
|
7
|
+
config.docker_image = 'mumuki/mumuki-mocha-worker:2.0'
|
6
8
|
config.structured = true
|
7
9
|
config.stateful = true
|
10
|
+
config.content_type = 'markdown'
|
8
11
|
end
|
9
12
|
|
10
13
|
require_relative './version'
|
@@ -12,5 +15,6 @@ require_relative './metadata_hook'
|
|
12
15
|
require_relative './validation_hook'
|
13
16
|
require_relative './test_hook'
|
14
17
|
require_relative './expectations_hook'
|
18
|
+
require_relative './feedback_hook'
|
15
19
|
require_relative './query_hook'
|
16
|
-
require_relative './try_hook'
|
20
|
+
require_relative './try_hook'
|
data/lib/locales/en.yml
ADDED
data/lib/locales/es.yml
ADDED
data/lib/locales/pt.yml
ADDED
data/lib/query_hook.rb
CHANGED
@@ -95,11 +95,15 @@ javascript
|
|
95
95
|
|
96
96
|
def error_patterns
|
97
97
|
[
|
98
|
-
Mumukit::ErrorPattern::Errored.new(
|
98
|
+
Mumukit::ErrorPattern::Errored.new(error_regexp)
|
99
99
|
]
|
100
100
|
end
|
101
101
|
|
102
|
-
def
|
103
|
-
|
102
|
+
def error_types
|
103
|
+
'(Reference|Syntax|Type)Error'
|
104
|
+
end
|
105
|
+
|
106
|
+
def error_regexp
|
107
|
+
/(?=\X*#{error_types})(solution.*\n|var __mumuki_query_result__ = )|#{error_types}.*\n\K\X*/
|
104
108
|
end
|
105
109
|
end
|
data/lib/test_hook.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
class JavascriptTestHook < Mumukit::Templates::FileHook
|
2
2
|
isolated true
|
3
3
|
structured true, separator: '!!!JAVASCRIPT-MUMUKI-OUTPUT!!!'
|
4
|
+
line_number_offset 3, include_extra: true
|
4
5
|
|
5
6
|
def compile_file_content(request)
|
6
7
|
<<javascript
|
7
8
|
'use strict';
|
8
|
-
|
9
|
-
var assert = require('assert');
|
10
|
-
|
9
|
+
let assert = require('assert');
|
11
10
|
#{request.extra}
|
12
11
|
#{request.content}
|
13
12
|
describe('', function() {
|
@@ -32,11 +31,19 @@ javascript
|
|
32
31
|
transform(super['tests'])
|
33
32
|
end
|
34
33
|
|
34
|
+
def post_process_unstructured_result(file, result, status)
|
35
|
+
if status.errored?
|
36
|
+
[content_type.code(result.gsub(/(SyntaxError: .*\n)(.|\n)*/) { $1 }), status]
|
37
|
+
else
|
38
|
+
super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
35
42
|
def transform(examples)
|
36
43
|
examples.map { |e| [e['fullTitle'], e['err'].present? ? :failed : :passed, parse_out(e['err'])] }
|
37
44
|
end
|
38
45
|
|
39
46
|
def parse_out(exception)
|
40
|
-
exception.present? ? exception['message'] : ''
|
47
|
+
exception.present? ? content_type.code(exception['message']) : ''
|
41
48
|
end
|
42
49
|
end
|
data/lib/validation_hook.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class JavascriptValidationHook < Mumukit::Hook
|
2
2
|
def validate!(request)
|
3
3
|
matches = request_matches?(request) do |it|
|
4
|
-
it =~ /(
|
4
|
+
it =~ /(^|[^_[[:alnum:]]]+)(require|process|os|fs|eval|cluster|v8|vm|tty|tls|root|global|crypto|stream|events)([^_[[:alnum:]]]+|$)/
|
5
5
|
end
|
6
6
|
raise Mumukit::RequestValidationError, "You can not use #{$2} here" if matches
|
7
7
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-javascript-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Leonardo Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mumukit
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.40'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.40'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,7 +102,11 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- lib/expectations_hook.rb
|
105
|
+
- lib/feedback_hook.rb
|
105
106
|
- lib/javascript_runner.rb
|
107
|
+
- lib/locales/en.yml
|
108
|
+
- lib/locales/es.yml
|
109
|
+
- lib/locales/pt.yml
|
106
110
|
- lib/metadata_hook.rb
|
107
111
|
- lib/query_hook.rb
|
108
112
|
- lib/test_hook.rb
|
@@ -128,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
132
|
- !ruby/object:Gem::Version
|
129
133
|
version: '0'
|
130
134
|
requirements: []
|
131
|
-
rubygems_version: 3.0.
|
135
|
+
rubygems_version: 3.0.3
|
132
136
|
signing_key:
|
133
137
|
specification_version: 4
|
134
138
|
summary: Javascript Runner for Mumuki
|