mumukit 2.8.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1423fda205b081b91b0561d56e411b8939a3725
4
- data.tar.gz: c86cfd9ad3ba565a0edb82f69aaaa54c65bf70bd
3
+ metadata.gz: 21c46d72fc20503bd751e4ef3b798b006d6d2857
4
+ data.tar.gz: 7ea814106ca4d802e729eb2a0131c11051be45b9
5
5
  SHA512:
6
- metadata.gz: 957d17aa5282ab203ee13d5a988ba736db8f9cda15592fc4f3be26fde2ed69fd2584040fc0e2ce3786ff2476ffe6feb226bb5a0624be379c2c25eed7aa276799
7
- data.tar.gz: 1fd89515534bd0e4fd1a06204c03ffe8249f4816b5b779129ac8c253324e27def6a6b994bace145baf02aa20b69102c4fe28ff299f79b18dd61e040b8b9e3243
6
+ metadata.gz: cb397d1d351c9958717d5e604a1a9cf5099ad40ca55ce574cb668fde10ba4b788639a35648bbeb7a5a66ebfc39b6a7b511113780d8fc0982d5a66a31fb72a165
7
+ data.tar.gz: 86d56d7eb5d463deae54fe44268856dd149fc86437fd7464a6e79e14862beddc56309c55e3ef2dc3dca30102fc9b73da2a3696083da925a01b47a58402d70397
data/lib/locales/en.yml CHANGED
@@ -2,3 +2,4 @@ en:
2
2
  mumukit:
3
3
  memory_exceeded: Memory limit exceeded. Is your program trying to allocate to much memory?
4
4
  time_exceeded: Execution time limit of %{limit}s exceeded. Is your program performing an infinite loop or recursion?
5
+ masked_tempfile_basename: solution
data/lib/locales/es.yml CHANGED
@@ -2,3 +2,4 @@ es:
2
2
  mumukit:
3
3
  memory_exceeded: Limite de memoria excedido. ¿Tu programa está alocando demasiada memoria?
4
4
  time_exceeded: Limite de tiempo de ejecución de %{limit}s excedido. ¿Tu programa tiene recursión o bucle infinito?
5
+ masked_tempfile_basename: solucion
data/lib/mumukit.rb CHANGED
@@ -57,6 +57,7 @@ require_relative 'mumukit/runtime'
57
57
  require_relative 'mumukit/isolated_environment'
58
58
  require_relative 'mumukit/templates'
59
59
  require_relative 'mumukit/request_validation_error'
60
+ require_relative 'mumukit/compilation_error'
60
61
  require_relative 'mumukit/defaults'
61
62
  require_relative 'mumukit/metatest'
62
63
  require_relative 'mumukit/explainer'
@@ -0,0 +1,4 @@
1
+ module Mumukit
2
+ class CompilationError < StandardError
3
+ end
4
+ end
@@ -84,6 +84,8 @@ class Mumukit::Server::TestServer
84
84
  def compile_and_run(hook, request)
85
85
  compilation = hook.compile(preprocess request)
86
86
  hook.run!(compilation)
87
+ rescue Mumukit::CompilationError => e
88
+ [e.message, :errored]
87
89
  end
88
90
 
89
91
  def preprocess(request)
@@ -10,6 +10,7 @@ require_relative './templates/with_metatest_results'
10
10
  require_relative './templates/with_mashup_file_content'
11
11
  require_relative './templates/with_embedded_environment'
12
12
  require_relative './templates/with_isolated_environment'
13
+ require_relative './templates/with_line_number_offset'
13
14
  require_relative './templates/mulang_expectations_hook'
14
15
  require_relative './templates/with_code_smells'
15
16
  require_relative './templates/with_cookie'
@@ -2,17 +2,24 @@ module Mumukit
2
2
  class Templates::FileHook < Mumukit::Hook
3
3
  include Mumukit::WithTempfile
4
4
 
5
+ attr_accessor :request
6
+
5
7
  def compile(request)
8
+ self.request = request
6
9
  write_tempfile! compile_file_content(request)
7
10
  end
8
11
 
9
12
  def run!(file)
10
13
  result, status = run_file!(file)
11
- post_process_file(file, result.force_encoding('UTF-8'), status)
14
+ post_process_file(file, cleanup_raw_result(result), status)
12
15
  ensure
13
16
  file.unlink
14
17
  end
15
18
 
19
+ def cleanup_raw_result(result)
20
+ mask_tempfile_references(result.force_encoding('UTF-8'), masked_tempfile_path)
21
+ end
22
+
16
23
  def post_process_file(file, result, status)
17
24
  [result, status]
18
25
  end
@@ -22,6 +29,19 @@ module Mumukit
22
29
 
23
30
  required :run_file!, 'Wrong configuration. You must include an environment mixin'
24
31
 
32
+ def masked_tempfile_path
33
+ @masked_tempfile_path ||= "#{t 'mumukit.masked_tempfile_basename'}#{tempfile_extension}"
34
+ end
35
+
36
+ def self.line_number_offset(offset, options={})
37
+ include Mumukit::Templates::WithLineNumberOffset
38
+
39
+ define_method(:line_number_offset) do
40
+ extra_offset = options[:include_extra] && request.extra ? request.extra.lines.length : 0
41
+ offset + extra_offset
42
+ end
43
+ end
44
+
25
45
  def self.metatested(value=true)
26
46
  if value
27
47
  include Mumukit::Templates::WithMetatest
@@ -0,0 +1,19 @@
1
+ module Mumukit::Templates::WithLineNumberOffset
2
+ def cleanup_raw_result(result)
3
+ super(result).gsub(line_number_reference_regexp) do
4
+ rebuild_line_number_reference correct_line_number($1.to_i)
5
+ end
6
+ end
7
+
8
+ def line_number_reference_regexp
9
+ /#{masked_tempfile_path}\:(\d+)/m
10
+ end
11
+
12
+ def rebuild_line_number_reference(new_line_number)
13
+ "#{masked_tempfile_path}:#{new_line_number}"
14
+ end
15
+
16
+ def correct_line_number(number)
17
+ number - line_number_offset
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Mumukit
2
- VERSION = '2.8.0'
2
+ VERSION = '2.9.0'
3
3
  end
@@ -23,5 +23,8 @@ module Mumukit
23
23
  file
24
24
  end
25
25
 
26
+ def mask_tempfile_references(string, masked_tempfile_path)
27
+ string.gsub(/\/tmp\/mumuki\.compile(.+?)#{tempfile_extension}/, masked_tempfile_path)
28
+ end
26
29
  end
27
30
  end
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.8.0
4
+ version: 2.9.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-05-12 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -217,6 +217,7 @@ files:
217
217
  - lib/locales/en.yml
218
218
  - lib/locales/es.yml
219
219
  - lib/mumukit.rb
220
+ - lib/mumukit/compilation_error.rb
220
221
  - lib/mumukit/cookie.rb
221
222
  - lib/mumukit/defaults.rb
222
223
  - lib/mumukit/defaults/default_expectations_hook.rb
@@ -253,6 +254,7 @@ files:
253
254
  - lib/mumukit/templates/with_cookie.rb
254
255
  - lib/mumukit/templates/with_embedded_environment.rb
255
256
  - lib/mumukit/templates/with_isolated_environment.rb
257
+ - lib/mumukit/templates/with_line_number_offset.rb
256
258
  - lib/mumukit/templates/with_mashup_file_content.rb
257
259
  - lib/mumukit/templates/with_metatest.rb
258
260
  - lib/mumukit/templates/with_metatest_results.rb
@@ -282,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
284
  version: '0'
283
285
  requirements: []
284
286
  rubyforge_project:
285
- rubygems_version: 2.4.8
287
+ rubygems_version: 2.6.12
286
288
  signing_key:
287
289
  specification_version: 4
288
290
  summary: Mumuki Test Server Development Kit