mumukit 2.28.1 → 2.29.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mumukit.rb +1 -0
- data/lib/mumukit/isolated_environment.rb +2 -3
- data/lib/mumukit/server/test_server.rb +13 -3
- data/lib/mumukit/string.rb +5 -0
- data/lib/mumukit/templates.rb +1 -0
- data/lib/mumukit/templates/mulang_expectations_hook.rb +1 -1
- data/lib/mumukit/templates/multi_file_hook.rb +25 -0
- data/lib/mumukit/templates/with_embedded_environment.rb +4 -2
- data/lib/mumukit/templates/with_isolated_environment.rb +4 -2
- data/lib/mumukit/templates/with_multiple_files.rb +5 -1
- data/lib/mumukit/version.rb +1 -1
- data/lib/mumukit/with_tempfile.rb +8 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a827027f338d223865479f6fbd0bbc8ca7f36f52caf20f3402e08c749e0b3f7
|
4
|
+
data.tar.gz: 5208a95b1fe08adc9864cd0ec0b1dcdd12e6e91fcaf701664a1b9a5a52e1c08c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fdd7cead0cf6d3d21f1dd89a65a85097c7c0576151e97db14b8d82346559fe0e0c0d257d26811bece79fe3b6cc70aa8117b453cb30b65b74d712f42d56745b9
|
7
|
+
data.tar.gz: 7d34da4a77324f5aaeedc0e3162b8e54902b423e14e7c0d830fbf51d76d956e73da28a3f650d260209f6462d0bc2e7a418e06bcd7bf5c371af1727cc03e91b14
|
data/lib/mumukit.rb
CHANGED
@@ -7,12 +7,11 @@ module Mumukit
|
|
7
7
|
attr_accessor :container
|
8
8
|
|
9
9
|
def configure!(*files)
|
10
|
-
|
11
10
|
filenames = files.map { |it| File.absolute_path(it.path) }
|
12
|
-
dirnames = filenames.map { |it| Pathname.new(it).dirname }
|
11
|
+
dirnames = filenames.map { |it| Pathname.new(it).dirname }.uniq
|
13
12
|
|
14
13
|
binds = dirnames.map { |it| "#{it}:#{it}" }
|
15
|
-
volumes = Hash[
|
14
|
+
volumes = Hash[dirnames.map { |it| [[it, {}]] }]
|
16
15
|
|
17
16
|
command = yield(*filenames).split
|
18
17
|
|
@@ -28,9 +28,13 @@ class Mumukit::Server::TestServer
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def parse_request_body(sinatra_request)
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
begin
|
32
|
+
parse_body(sinatra_request).tap do |it|
|
33
|
+
I18n.locale = it['locale'] || :en
|
34
|
+
end
|
35
|
+
rescue StandardError => e
|
36
|
+
raise StandardError.new("Error parsing request body. Cause: #{e}")
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
def test!(request)
|
@@ -120,4 +124,10 @@ class Mumukit::Server::TestServer
|
|
120
124
|
def default_repo_url
|
121
125
|
"https://github.com/mumuki/mumuki-#{Mumukit.runner_name}-runner"
|
122
126
|
end
|
127
|
+
|
128
|
+
def parse_body(sinatra_request)
|
129
|
+
json = sinatra_request.body.read
|
130
|
+
return {} if json.empty?
|
131
|
+
JSON.parse json
|
132
|
+
end
|
123
133
|
end
|
data/lib/mumukit/templates.rb
CHANGED
@@ -15,6 +15,7 @@ require_relative './templates/with_code_smells'
|
|
15
15
|
require_relative './templates/with_cookie'
|
16
16
|
|
17
17
|
require_relative './templates/file_hook'
|
18
|
+
require_relative './templates/multi_file_hook'
|
18
19
|
require_relative './templates/try_hook'
|
19
20
|
require_relative './templates/expectations_hook'
|
20
21
|
require_relative './templates/mulang_expectations_hook'
|
@@ -6,7 +6,7 @@ module Mumukit
|
|
6
6
|
FUNCTIONAL_SMELLS = %w(HasRedundantParameter HasRedundantGuards)
|
7
7
|
OBJECT_ORIENTED_SMELLS = %w(DoesNullTest ReturnsNull)
|
8
8
|
IMPERATIVE_SMELLS = %w(HasRedundantLocalVariableReturn HasAssignmentReturn)
|
9
|
-
EXPRESSIVENESS_SMELLS = %w(
|
9
|
+
EXPRESSIVENESS_SMELLS = %w(HasTooShortIdentifiers HasWrongCaseIdentifiers HasMisspelledIdentifiers)
|
10
10
|
GENERIC_SMELLS = %w(IsLongCode HasCodeDuplication HasRedundantLambda HasRedundantIf DoesTypeTest HasRedundantBooleanComparison HasEmptyIfBranches)
|
11
11
|
|
12
12
|
required :language, 'You have to provide a Mulang-compatible language in order to use this hook'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Mumukit
|
4
|
+
class Templates::MultiFileHook < Templates::FileHook
|
5
|
+
include Mumukit::Templates::WithMultipleFiles
|
6
|
+
|
7
|
+
def compile(request)
|
8
|
+
return super unless has_files?(request)
|
9
|
+
|
10
|
+
self.request = request
|
11
|
+
write_tempdir! compile_file_content(request)
|
12
|
+
end
|
13
|
+
|
14
|
+
def run!(tempdir)
|
15
|
+
return super unless has_files?(request)
|
16
|
+
|
17
|
+
begin
|
18
|
+
result, status = run_files!(*tempdir.files)
|
19
|
+
post_process_file(tempdir.files, cleanup_raw_result(result), status)
|
20
|
+
ensure
|
21
|
+
FileUtils.rm_rf tempdir.dir
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -5,8 +5,10 @@ module Mumukit
|
|
5
5
|
include Mumukit::WithCommandLine
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
run_command command_line(
|
8
|
+
def run_files!(*files)
|
9
|
+
run_command command_line(*files.map {|f| f.path})
|
10
10
|
end
|
11
|
+
|
12
|
+
alias_method 'run_file!', 'run_files!'
|
11
13
|
end
|
12
14
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module Mumukit
|
2
2
|
module Templates::WithIsolatedEnvironment
|
3
|
-
def
|
3
|
+
def run_files!(*files)
|
4
4
|
env = Mumukit::IsolatedEnvironment.new
|
5
|
-
env.configure!(
|
5
|
+
env.configure!(*files) { |*filenames| command_line(*filenames) }
|
6
6
|
env.run!
|
7
7
|
ensure
|
8
8
|
env.destroy!
|
9
9
|
end
|
10
|
+
|
11
|
+
alias_method 'run_file!', 'run_files!'
|
10
12
|
end
|
11
13
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Mumukit::Templates::WithMultipleFiles
|
2
2
|
def files_of(request)
|
3
3
|
raise 'You need to enable Mumukit.config.multifile first!' unless Mumukit.config.multifile
|
4
|
-
|
4
|
+
has_files?(request) ? request.content : {}
|
5
|
+
end
|
6
|
+
|
7
|
+
def has_files?(request)
|
8
|
+
request.content.is_a?(Hash)
|
5
9
|
end
|
6
10
|
end
|
data/lib/mumukit/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'tempfile'
|
2
|
+
require 'tmpdir'
|
2
3
|
|
3
4
|
module Mumukit
|
4
5
|
module WithTempfile
|
@@ -16,6 +17,13 @@ module Mumukit
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
20
|
+
def write_tempdir!(files)
|
21
|
+
dir = Dir.mktmpdir
|
22
|
+
files.map do |filename, content|
|
23
|
+
File.open("#{dir}/#{filename.sanitize_as_filename}", 'w') { |file| file.write content; file }
|
24
|
+
end.try { |it| struct dir: dir, files: it }
|
25
|
+
end
|
26
|
+
|
19
27
|
def with_tempfile
|
20
28
|
file = create_tempfile
|
21
29
|
yield file
|
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.29.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: 2019-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -300,10 +300,12 @@ files:
|
|
300
300
|
- lib/mumukit/server/response_builder.rb
|
301
301
|
- lib/mumukit/server/test_pipeline.rb
|
302
302
|
- lib/mumukit/server/test_server.rb
|
303
|
+
- lib/mumukit/string.rb
|
303
304
|
- lib/mumukit/templates.rb
|
304
305
|
- lib/mumukit/templates/expectations_hook.rb
|
305
306
|
- lib/mumukit/templates/file_hook.rb
|
306
307
|
- lib/mumukit/templates/mulang_expectations_hook.rb
|
308
|
+
- lib/mumukit/templates/multi_file_hook.rb
|
307
309
|
- lib/mumukit/templates/multi_file_precompile_hook.rb
|
308
310
|
- lib/mumukit/templates/try_hook.rb
|
309
311
|
- lib/mumukit/templates/with_code_smells.rb
|
@@ -340,8 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
340
342
|
- !ruby/object:Gem::Version
|
341
343
|
version: '0'
|
342
344
|
requirements: []
|
343
|
-
|
344
|
-
rubygems_version: 2.7.8
|
345
|
+
rubygems_version: 3.0.2
|
345
346
|
signing_key:
|
346
347
|
specification_version: 4
|
347
348
|
summary: Mumuki Test Server Development Kit
|