mumukit 2.16.1 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/mumukit/isolated_environment.rb +24 -12
- data/lib/mumukit/server.rb +1 -0
- data/lib/mumukit/server/test_pipeline.rb +30 -0
- data/lib/mumukit/server/test_server.rb +18 -29
- data/lib/mumukit/templates/mulang_expectations_hook.rb +20 -44
- data/lib/mumukit/templates/try_hook.rb +6 -2
- data/lib/mumukit/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b678748b9bbd865a42951a22eb71244968362faf551452fdfe4d0a9f14889fda
|
4
|
+
data.tar.gz: 42ea663c41b564d65222f11d7baa5b7447a2e49b053eb8579b4ec2d8ad814268
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbb8f3d2905dc3b02b600efb96609bbfb888410228822d40ad55977e59aee51683d1842afb8faa5816b3c76a846639bd4de364f707bc0600d4817c8184b6f785
|
7
|
+
data.tar.gz: 0cfadb4c1dc8c55e3ed8b903c0d3d05c2217f56d39845bca17fcc97ac6888b8d5bfa7ca2c48f87f714849ed52a86302eb2893d3168b64c553d915bb975331ba5
|
@@ -16,21 +16,22 @@ module Mumukit
|
|
16
16
|
|
17
17
|
command = yield(*filenames).split
|
18
18
|
|
19
|
+
configure_container! command, binds, volumes
|
20
|
+
end
|
21
|
+
|
22
|
+
def configure_container!(command, binds, volumes)
|
19
23
|
self.container = Docker::Container.create(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
'Image' => Mumukit.config.docker_image,
|
25
|
+
'Cmd' => command,
|
26
|
+
'NetworkDisabled' => true,
|
27
|
+
'HostConfig' => {
|
28
|
+
'Binds' => binds},
|
29
|
+
'Volumes' => volumes)
|
26
30
|
end
|
27
31
|
|
28
32
|
def run!
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
exit = container.json['State']['ExitCode']
|
33
|
-
out = container.streaming_logs(stdout: true, stderr: true)
|
33
|
+
run_container!
|
34
|
+
exit, out = fetch_container_state!
|
34
35
|
|
35
36
|
if exit == 0
|
36
37
|
[out, :passed]
|
@@ -41,6 +42,17 @@ module Mumukit
|
|
41
42
|
[I18n.t('mumukit.time_exceeded', limit: Mumukit.config.command_time_limit), :aborted]
|
42
43
|
end
|
43
44
|
|
45
|
+
def run_container!
|
46
|
+
container.start
|
47
|
+
container.wait(Mumukit.config.command_time_limit)
|
48
|
+
end
|
49
|
+
|
50
|
+
def fetch_container_state!
|
51
|
+
exit = container.json['State']['ExitCode']
|
52
|
+
out = container.streaming_logs(stdout: true, stderr: true)
|
53
|
+
[exit, out]
|
54
|
+
end
|
55
|
+
|
44
56
|
def destroy!
|
45
57
|
if container
|
46
58
|
container.stop
|
@@ -48,4 +60,4 @@ module Mumukit
|
|
48
60
|
end
|
49
61
|
end
|
50
62
|
end
|
51
|
-
end
|
63
|
+
end
|
data/lib/mumukit/server.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
class Mumukit::Server::TestPipeline
|
2
|
+
def initialize(server, request)
|
3
|
+
@server = server
|
4
|
+
@request = request
|
5
|
+
end
|
6
|
+
|
7
|
+
def evaluate!
|
8
|
+
@test_results = @server.run_tests! @request
|
9
|
+
@expectation_results = @server.run_expectations!(@request).try do |raw|
|
10
|
+
static_errors?(raw) ? [] : raw
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_feedback!
|
15
|
+
@feedback = @server.run_feedback! @request,
|
16
|
+
struct(test_results: @test_results, expectation_results: @expectation_results)
|
17
|
+
end
|
18
|
+
|
19
|
+
def response
|
20
|
+
builder = Mumukit::Server::ResponseBuilder.new
|
21
|
+
builder.add_test_results @test_results
|
22
|
+
builder.add_expectation_results @expectation_results
|
23
|
+
builder.add_feedback @feedback
|
24
|
+
builder.build
|
25
|
+
end
|
26
|
+
|
27
|
+
def static_errors?(raw)
|
28
|
+
raw.size == 2 && raw[1] == :errored
|
29
|
+
end
|
30
|
+
end
|
@@ -32,19 +32,10 @@ class Mumukit::Server::TestServer
|
|
32
32
|
|
33
33
|
def test!(request)
|
34
34
|
respond_to(request) do |r|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
expectation_results: expectation_results)
|
40
|
-
|
41
|
-
feedback = run_feedback! r, results
|
42
|
-
|
43
|
-
Mumukit::Server::ResponseBuilder.build do
|
44
|
-
add_test_results(test_results)
|
45
|
-
add_expectation_results(expectation_results)
|
46
|
-
add_feedback(feedback)
|
47
|
-
end
|
35
|
+
pipeline = Mumukit::Server::TestPipeline.new self, r
|
36
|
+
pipeline.evaluate!
|
37
|
+
pipeline.generate_feedback!
|
38
|
+
pipeline.response
|
48
39
|
end
|
49
40
|
end
|
50
41
|
|
@@ -66,14 +57,6 @@ class Mumukit::Server::TestServer
|
|
66
57
|
end
|
67
58
|
end
|
68
59
|
|
69
|
-
def run_query!(request)
|
70
|
-
compile_and_run runtime.query_hook, request
|
71
|
-
end
|
72
|
-
|
73
|
-
def run_try!(request)
|
74
|
-
compile_and_run runtime.try_hook, request
|
75
|
-
end
|
76
|
-
|
77
60
|
def run_tests!(request)
|
78
61
|
return ['', :passed] if request.test.blank?
|
79
62
|
|
@@ -81,11 +64,9 @@ class Mumukit::Server::TestServer
|
|
81
64
|
end
|
82
65
|
|
83
66
|
def run_expectations!(request)
|
84
|
-
if request.expectations
|
85
|
-
|
86
|
-
|
87
|
-
[]
|
88
|
-
end
|
67
|
+
return [] if request.expectations.nil? || request.content.nil?
|
68
|
+
|
69
|
+
compile_and_run runtime.expectations_hook, request
|
89
70
|
end
|
90
71
|
|
91
72
|
def run_feedback!(request, results)
|
@@ -94,11 +75,19 @@ class Mumukit::Server::TestServer
|
|
94
75
|
|
95
76
|
private
|
96
77
|
|
78
|
+
def run_query!(request)
|
79
|
+
compile_and_run runtime.query_hook, request
|
80
|
+
end
|
81
|
+
|
82
|
+
def run_try!(request)
|
83
|
+
compile_and_run runtime.try_hook, request
|
84
|
+
end
|
85
|
+
|
97
86
|
def compile_and_run(hook, request)
|
98
|
-
compilation = hook.compile(
|
87
|
+
compilation = hook.compile(request)
|
99
88
|
hook.run!(compilation)
|
100
89
|
rescue Mumukit::CompilationError => e
|
101
|
-
|
90
|
+
[e.message, :errored]
|
102
91
|
end
|
103
92
|
|
104
93
|
def preprocess(request)
|
@@ -110,7 +99,7 @@ class Mumukit::Server::TestServer
|
|
110
99
|
end
|
111
100
|
|
112
101
|
def respond_to(request)
|
113
|
-
yield request.tap { |r| validate_request! r }
|
102
|
+
yield preprocess request.tap { |r| validate_request! r }
|
114
103
|
rescue Mumukit::RequestValidationError => e
|
115
104
|
{exit: :aborted, out: e.message}
|
116
105
|
rescue Exception => e
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'mumukit/inspection'
|
2
|
+
require 'mulang'
|
2
3
|
|
3
4
|
module Mumukit
|
4
|
-
class Templates::MulangExpectationsHook < Mumukit::
|
5
|
+
class Templates::MulangExpectationsHook < Mumukit::Hook
|
5
6
|
LOGIC_SMELLS = %w(UsesCut UsesFail UsesUnificationOperator HasRedundantReduction)
|
6
7
|
FUNCTIONAL_SMELLS = %w(HasRedundantParameter HasRedundantGuards)
|
7
8
|
OBJECT_ORIENTED_SMELLS = %w(DoesNullTest ReturnsNull)
|
@@ -9,42 +10,25 @@ module Mumukit
|
|
9
10
|
EXPRESSIVENESS_SMELLS = %w(HasTooShortBindings HasWrongCaseBindings HasMisspelledBindings)
|
10
11
|
GENERIC_SMELLS = %w(IsLongCode HasCodeDuplication HasRedundantLambda HasRedundantIf DoesTypeTest HasRedundantBooleanComparison)
|
11
12
|
|
12
|
-
isolated false
|
13
13
|
required :language, 'You have to provide a Mulang-compatible language in order to use this hook'
|
14
14
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
def compile(request)
|
16
|
+
expectations, exceptions = compile_expectations_and_exceptions request
|
17
|
+
mulang_code(request).analysis(
|
18
|
+
expectations: expectations,
|
19
|
+
smellsSet: {
|
20
|
+
tag: 'AllSmells',
|
21
|
+
exclude: (exceptions + default_smell_exceptions)
|
22
|
+
},
|
23
|
+
domainLanguage: domain_language)
|
22
24
|
end
|
23
25
|
|
24
|
-
def
|
25
|
-
parse_response
|
26
|
+
def run!(analysis)
|
27
|
+
parse_response Mulang.analyse(analysis)
|
26
28
|
rescue JSON::ParserError
|
27
|
-
raise Mumukit::CompilationError, "Can not handle mulang results #{
|
29
|
+
raise Mumukit::CompilationError, "Can not handle mulang results for analysis #{analysis}"
|
28
30
|
end
|
29
31
|
|
30
|
-
def compile_file_content(request)
|
31
|
-
compile_json_file_content(request).to_json
|
32
|
-
end
|
33
|
-
|
34
|
-
def compile_json_file_content(request)
|
35
|
-
expectations, exceptions = compile_expectations_and_exceptions request
|
36
|
-
{
|
37
|
-
sample: compile_sample(request),
|
38
|
-
spec: {
|
39
|
-
expectations: expectations,
|
40
|
-
smellsSet: {
|
41
|
-
tag: 'AllSmells',
|
42
|
-
exclude: (exceptions + default_smell_exceptions)
|
43
|
-
},
|
44
|
-
domainLanguage: domain_language
|
45
|
-
}
|
46
|
-
}
|
47
|
-
end
|
48
32
|
|
49
33
|
def domain_language
|
50
34
|
{
|
@@ -58,20 +42,12 @@ module Mumukit
|
|
58
42
|
[]
|
59
43
|
end
|
60
44
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
68
|
-
else
|
69
|
-
{
|
70
|
-
tag: 'CodeSample',
|
71
|
-
language: language,
|
72
|
-
content: compiled_content
|
73
|
-
}
|
74
|
-
end
|
45
|
+
def mulang_code(request)
|
46
|
+
Mulang::Code.new(mulang_language, compile_content(request[:content]))
|
47
|
+
end
|
48
|
+
|
49
|
+
def mulang_language
|
50
|
+
language == 'Mulang' ? Mulang::Language::External.new : Mulang::Language::Native.new(language)
|
75
51
|
end
|
76
52
|
|
77
53
|
def compile_expectations_and_exceptions(request)
|
@@ -6,8 +6,12 @@ module Mumukit
|
|
6
6
|
super request
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
9
|
+
def post_process_file(file, result, status)
|
10
|
+
structured_results = to_structured_results(file, result, status)
|
11
|
+
check_results = @checker.check structured_results, @goal
|
12
|
+
[check_results[2], check_results[1], structured_results[:query]]
|
11
13
|
end
|
14
|
+
|
15
|
+
required :to_structured_results
|
12
16
|
end
|
13
17
|
end
|
data/lib/mumukit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumukit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.17.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: 2017-
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0.46'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: mulang
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '3.3'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '3.3'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: mumukit-inspection
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,6 +288,7 @@ files:
|
|
274
288
|
- lib/mumukit/server.rb
|
275
289
|
- lib/mumukit/server/app.rb
|
276
290
|
- lib/mumukit/server/response_builder.rb
|
291
|
+
- lib/mumukit/server/test_pipeline.rb
|
277
292
|
- lib/mumukit/server/test_server.rb
|
278
293
|
- lib/mumukit/templates.rb
|
279
294
|
- lib/mumukit/templates/file_hook.rb
|
@@ -313,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
313
328
|
version: '0'
|
314
329
|
requirements: []
|
315
330
|
rubyforge_project:
|
316
|
-
rubygems_version: 2.
|
331
|
+
rubygems_version: 2.7.2
|
317
332
|
signing_key:
|
318
333
|
specification_version: 4
|
319
334
|
summary: Mumuki Test Server Development Kit
|