mumukit 2.34.1 → 2.38.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
  SHA256:
3
- metadata.gz: ecf5dad926913985cd2067a888f7e14233c66a70a887ee287d60093fd3d33faf
4
- data.tar.gz: 8e36f9461737a850f6c8a691b0e6524bbe58dbd7276e92b5c5e40f6ad4c407d4
3
+ metadata.gz: b3876e1a398e3f2e0cf33f7aa1a4df85979cca7ffef37b4070d5344c2072e952
4
+ data.tar.gz: 9dcde120df168b2898461e08cb08ca26c219fdaf0791bc38a133891a7dba51ad
5
5
  SHA512:
6
- metadata.gz: 6fbd065df141368fee19ddfbc7c9eb03df473ff1a0cf92cc2b4ab407dc35688ce7ac119cd778e63ad6a87a880f41fbe7c027645e652b959e13eb2355070618f6
7
- data.tar.gz: 7ea9f24a7635aec967c1c3ceb3df3458a533aacdd644596beb58bbb91fffa15ef62bbe785d9d5a984bafc80faa48bc75adb279da4765e2559381226227f829df
6
+ metadata.gz: 6863a908811d9df5f390827c8c3fdea11d0c3de67b07435658d037d8b5ba9ae9d9c13cb92236bbab0e29bf942d7d668468112295ca1ce9f6cda2312cc1e0c328
7
+ data.tar.gz: 2ab1f2822e74a9b7c0a628f4661749a6e1d87e2c69c833844a34cc434ba626e61026a7f61e554a8dfccd9dc60e414b1836ad143fbfeafcbc2199e3b01801e63c
@@ -0,0 +1,17 @@
1
+ es-CL:
2
+ mumukit:
3
+ memory_exceeded: Limite de memoria excedido. ¿Tu programa está alocando demasiada memoria?
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
6
+ interactive:
7
+ check_last_query_equals: "La consulta debería ser '%{expected}' pero fue '%{actual}'"
8
+ check_last_query_fails: "La consulta debería fallar pero pasó"
9
+ check_last_query_matches: "La consulta no cumple con la expresión regular %{regex}"
10
+ check_last_query_outputs: "La consulta debería devolver '%{expected}' pero devolvió '%{actual}'"
11
+ check_last_query_includes: "La consulta debería incluir '%{expected}' pero devolvió '%{actual}'"
12
+ check_last_query_like: "La consulta debería ser como '%{expected}' pero devolvió '%{actual}'"
13
+ check_last_query_passes: "La consulta debería pasar pero falló"
14
+ check_query_fails: "La consulta '%{query}' debería fallar pero pasó"
15
+ check_query_outputs: "La consulta '%{query}' debería devolver '%{expected}' pero devolvió '%{actual}'"
16
+ check_query_passes: "La consulta '%{query}' debería pasar pero falló"
17
+ goal_passed: "El objetivo se cumplió exitosamente"
@@ -1,7 +1,7 @@
1
1
  es:
2
2
  mumukit:
3
3
  memory_exceeded: Limite de memoria excedido. ¿Tu programa está alocando demasiada memoria?
4
- time_exceeded: Limite de tiempo de ejecución de %{limit}s excedido. ¿Tu programa tiene recursión o bucle infinito?
4
+ time_exceeded: Limite de tiempo de ejecución de %{limit}s excedido. ¿Tu programa tiene recursión o bucle infinito?
5
5
  masked_tempfile_basename: solucion
6
6
  interactive:
7
7
  check_last_query_equals: "La consulta debería ser '%{expected}' pero fue '%{actual}'"
@@ -14,4 +14,4 @@ es:
14
14
  check_query_fails: "La consulta '%{query}' debería fallar pero pasó"
15
15
  check_query_outputs: "La consulta '%{query}' debería devolver '%{expected}' pero devolvió '%{actual}'"
16
16
  check_query_passes: "La consulta '%{query}' debería pasar pero falló"
17
- goal_passed: "El objetivo se cumplió exitosamente"
17
+ goal_passed: "El objetivo se cumplió exitosamente"
@@ -1,11 +1,17 @@
1
1
  class Mumukit::Explainer
2
+ include Mumukit::WithContentType
3
+
2
4
  def explain(content, test_results)
5
+ content_type.enumerate(explanations(content, test_results))
6
+ end
7
+
8
+ private
9
+
10
+ def explanations(content, test_results)
3
11
  explain_methods
4
12
  .map { |selector, key| eval_explain(selector, key, content, test_results) }
5
13
  .compact
6
14
  .map { |explain| I18n.t(explain[:key], explain[:binding]) }
7
- .map { |it| "* #{it}" }
8
- .join("\n")
9
15
  end
10
16
 
11
17
  def eval_explain(selector, key, content, test_results)
@@ -3,6 +3,7 @@ end
3
3
 
4
4
  require_relative './metatest/errors'
5
5
  require_relative './metatest/checker'
6
+ require_relative './metatest/test_result_builder'
6
7
  require_relative './metatest/interactive_checker'
7
8
  require_relative './metatest/framework'
8
- require_relative './metatest/identity_runner'
9
+ require_relative './metatest/identity_runner'
@@ -24,10 +24,12 @@ module Mumukit::Metatest
24
24
  ## }
25
25
  ##
26
26
  def check(input, example)
27
+ builder = Mumukit::Metatest::TestResultBuilder.new
28
+
27
29
  check_assertions input, postconditions_for(example), example
28
- [example[:name], :passed, render_success_output(input)]
30
+ build_passed_test_result builder, example, input
29
31
  rescue => e
30
- [example[:name], :failed, render_error_output(input, e.message)]
32
+ build_failed_test_result builder, example, input, e
31
33
  end
32
34
 
33
35
  ## If no postconditions are included in the example,
@@ -36,12 +38,34 @@ module Mumukit::Metatest
36
38
  example[:postconditions] || example.except(:name)
37
39
  end
38
40
 
39
- def render_success_output(value)
41
+ # Implementors may override this method instead of `build_success_output`
42
+ # if they don't want to handle error details.
43
+ #
44
+ # This method is only for backward compatibility. New code
45
+ # should use `build_success_output`.
46
+ def render_success_output(_input)
40
47
  nil
41
48
  end
42
49
 
43
- def render_error_output(value, error)
44
- error
50
+ # Implementors may override this method instead of `build_error_output`
51
+ # if they don't want to handle error details.
52
+ #
53
+ # This method is only for backward compatibility. New code
54
+ # should use `build_error_output`.
55
+ def render_error_output(_input, error_message)
56
+ error_message
57
+ end
58
+
59
+ # Implementors should override this method if they want access to
60
+ # the error details and produce more complex test results
61
+ def build_success_output(builder, _example, input)
62
+ builder.result = render_success_output input
63
+ end
64
+
65
+ # Implementors should override this method if they want access to
66
+ # the error details and produce more complex test results
67
+ def build_error_output(builder, _example, input, error)
68
+ builder.result = render_error_output input, error.message
45
69
  end
46
70
 
47
71
  def check_assertions(input, assertions_hash, example)
@@ -54,16 +78,30 @@ module Mumukit::Metatest
54
78
  send "check_#{assertion_name}", input, assertion_config
55
79
  end
56
80
 
57
- def fail(message)
58
- raise Mumukit::Metatest::Failed, message
81
+ def fail(message, details: nil)
82
+ raise Mumukit::Metatest::Failed.new(message, details)
83
+ end
84
+
85
+ def abort(message, details: nil)
86
+ raise Mumukit::Metatest::Aborted.new(message, details)
87
+ end
88
+
89
+ def error(message, details: nil)
90
+ raise Mumukit::Metatest::Errored.new(message, details)
59
91
  end
60
92
 
61
- def abort(message)
62
- raise Mumukit::Metatest::Aborted, message
93
+ def build_passed_test_result(builder, example, input)
94
+ builder.title = example[:name]
95
+ builder.status = :passed
96
+ build_success_output builder, example, input
97
+ builder.build
63
98
  end
64
99
 
65
- def error(message)
66
- raise Mumukit::Metatest::Errored, message
100
+ def build_failed_test_result(builder, example, input, e)
101
+ builder.title = example[:name]
102
+ builder.status = :failed
103
+ build_error_output builder, example, input, e
104
+ builder.build
67
105
  end
68
106
  end
69
107
  end
@@ -1,10 +1,17 @@
1
1
  module Mumukit::Metatest
2
- class Aborted < StandardError
2
+ class BaseError < StandardError
3
+ attr_reader :details
4
+ def initialize(message = "", details = nil)
5
+ super(message)
6
+ @details = details
7
+ end
8
+ end
9
+ class Aborted < BaseError
3
10
  end
4
11
 
5
- class Errored < StandardError
12
+ class Errored < BaseError
6
13
  end
7
14
 
8
- class Failed < StandardError
15
+ class Failed < BaseError
9
16
  end
10
- end
17
+ end
@@ -0,0 +1,20 @@
1
+ module Mumukit::Metatest
2
+ class TestResultBuilder
3
+ attr_accessor :title, :status, :result, :summary_type, :summary_message
4
+
5
+ def summary
6
+ {type: summary_type.presence, message: summary_message.presence}.compact
7
+ end
8
+
9
+ def build
10
+ raise 'missing status' unless status
11
+ raise "invalid #{status}" unless status.passed? || status.failed?
12
+
13
+ if summary_message.present? || summary_type.present?
14
+ [title, status, result, summary]
15
+ else
16
+ [title, status, result]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -58,10 +58,16 @@ class Mumukit::Server::ResponseBuilder
58
58
  end
59
59
 
60
60
  def structured_base_response(test_results)
61
- {testResults: test_results[0].map { |title, status, result|
62
- {title: title,
63
- status: status,
64
- result: result} }}
61
+ {
62
+ testResults: test_results[0].map do |title, status, result, summary|
63
+ { summary: summary&.compact.presence }
64
+ .compact
65
+ .merge(
66
+ title: title,
67
+ status: status,
68
+ result: result)
69
+ end
70
+ }
65
71
  end
66
72
 
67
73
  def unstructured_base_response(test_results)
@@ -2,12 +2,12 @@ require 'mulang'
2
2
 
3
3
  module Mumukit
4
4
  class Templates::MulangExpectationsHook < Mumukit::Templates::ExpectationsHook
5
- LOGIC_SMELLS = %w(UsesCut UsesFail UsesUnificationOperator HasRedundantReduction)
6
- FUNCTIONAL_SMELLS = %w(HasRedundantParameter HasRedundantGuards)
7
- OBJECT_ORIENTED_SMELLS = %w(DoesNullTest ReturnsNull)
8
- IMPERATIVE_SMELLS = %w(HasRedundantLocalVariableReturn HasAssignmentReturn)
9
- EXPRESSIVENESS_SMELLS = %w(HasTooShortIdentifiers HasWrongCaseIdentifiers HasMisspelledIdentifiers)
10
- GENERIC_SMELLS = %w(IsLongCode HasCodeDuplication HasRedundantLambda HasRedundantIf DoesTypeTest HasRedundantBooleanComparison HasEmptyIfBranches)
5
+ LOGIC_SMELLS = Mulang::Expectation::LOGIC_SMELLS
6
+ FUNCTIONAL_SMELLS = Mulang::Expectation::FUNCTIONAL_SMELLS
7
+ OBJECT_ORIENTED_SMELLS = Mulang::Expectation::OBJECT_ORIENTED_SMELLS
8
+ IMPERATIVE_SMELLS = Mulang::Expectation::IMPERATIVE_SMELLS
9
+ EXPRESSIVENESS_SMELLS = Mulang::Expectation::EXPRESSIVENESS_SMELLS
10
+ GENERIC_SMELLS = Mulang::Expectation::GENERIC_SMELLS
11
11
 
12
12
  required :language, 'You have to provide a Mulang-compatible language in order to use this hook'
13
13
 
@@ -16,14 +16,15 @@ module Mumukit
16
16
  end
17
17
 
18
18
  def compile_mulang_analysis(request, expectations)
19
- mulang_code(request).analysis(
19
+ mulang_code(request).analysis({
20
20
  expectations: expectations[:ast],
21
21
  customExpectations: expectations[:custom],
22
22
  smellsSet: {
23
23
  tag: 'AllSmells',
24
24
  exclude: (expectations[:exceptions] + default_smell_exceptions)
25
25
  },
26
- domainLanguage: domain_language)
26
+ domainLanguage: domain_language
27
+ }.merge({normalizationOptions: normalization_options(request).presence}.compact))
27
28
  end
28
29
 
29
30
  def run_mulang_analysis(analysis)
@@ -41,6 +42,10 @@ module Mumukit
41
42
  }
42
43
  end
43
44
 
45
+ def normalization_options(request)
46
+ request.dig(:settings, :normalization_options) || {}
47
+ end
48
+
44
49
  def default_smell_exceptions
45
50
  []
46
51
  end
@@ -1,3 +1,3 @@
1
1
  module Mumukit
2
- VERSION = '2.34.1'
2
+ VERSION = '2.38.0'
3
3
  end
metadata CHANGED
@@ -1,63 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.34.1
4
+ version: 2.38.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: 2019-10-08 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.7'
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '3'
19
+ version: '2.0'
23
20
  type: :development
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '1.7'
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '3'
26
+ version: '2.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rake
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: '10.0'
33
+ version: '12.3'
40
34
  type: :development
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: '10.0'
40
+ version: '12.3'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: rspec
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '2'
47
+ version: '3.0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '2'
54
+ version: '3.0'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: codeclimate-test-reporter
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -176,14 +170,14 @@ dependencies:
176
170
  requirements:
177
171
  - - "~>"
178
172
  - !ruby/object:Gem::Version
179
- version: '0.46'
173
+ version: '0.71'
180
174
  type: :runtime
181
175
  prerelease: false
182
176
  version_requirements: !ruby/object:Gem::Requirement
183
177
  requirements:
184
178
  - - "~>"
185
179
  - !ruby/object:Gem::Version
186
- version: '0.46'
180
+ version: '0.71'
187
181
  - !ruby/object:Gem::Dependency
188
182
  name: sinatra-cross_origin
189
183
  requirement: !ruby/object:Gem::Requirement
@@ -218,28 +212,28 @@ dependencies:
218
212
  requirements:
219
213
  - - "~>"
220
214
  - !ruby/object:Gem::Version
221
- version: '5.1'
215
+ version: '6.0'
222
216
  type: :runtime
223
217
  prerelease: false
224
218
  version_requirements: !ruby/object:Gem::Requirement
225
219
  requirements:
226
220
  - - "~>"
227
221
  - !ruby/object:Gem::Version
228
- version: '5.1'
222
+ version: '6.0'
229
223
  - !ruby/object:Gem::Dependency
230
224
  name: mumukit-inspection
231
225
  requirement: !ruby/object:Gem::Requirement
232
226
  requirements:
233
227
  - - "~>"
234
228
  - !ruby/object:Gem::Version
235
- version: '5.0'
229
+ version: '6.0'
236
230
  type: :runtime
237
231
  prerelease: false
238
232
  version_requirements: !ruby/object:Gem::Requirement
239
233
  requirements:
240
234
  - - "~>"
241
235
  - !ruby/object:Gem::Version
242
- version: '5.0'
236
+ version: '6.0'
243
237
  - !ruby/object:Gem::Dependency
244
238
  name: mumukit-core
245
239
  requirement: !ruby/object:Gem::Requirement
@@ -272,22 +266,16 @@ dependencies:
272
266
  name: mumukit-content-type
273
267
  requirement: !ruby/object:Gem::Requirement
274
268
  requirements:
275
- - - ">="
276
- - !ruby/object:Gem::Version
277
- version: '0.2'
278
- - - "<"
269
+ - - "~>"
279
270
  - !ruby/object:Gem::Version
280
- version: '2'
271
+ version: '1.10'
281
272
  type: :runtime
282
273
  prerelease: false
283
274
  version_requirements: !ruby/object:Gem::Requirement
284
275
  requirements:
285
- - - ">="
286
- - !ruby/object:Gem::Version
287
- version: '0.2'
288
- - - "<"
276
+ - - "~>"
289
277
  - !ruby/object:Gem::Version
290
- version: '2'
278
+ version: '1.10'
291
279
  description: Helpers for building a Mumuki Test Server
292
280
  email:
293
281
  - flbulgarelli@yahoo.com.ar
@@ -297,6 +285,7 @@ extra_rdoc_files: []
297
285
  files:
298
286
  - bin/limit
299
287
  - lib/locales/en.yml
288
+ - lib/locales/es-CL.yml
300
289
  - lib/locales/es.yml
301
290
  - lib/locales/pt.yml
302
291
  - lib/mumukit.rb
@@ -323,6 +312,7 @@ files:
323
312
  - lib/mumukit/metatest/framework.rb
324
313
  - lib/mumukit/metatest/identity_runner.rb
325
314
  - lib/mumukit/metatest/interactive_checker.rb
315
+ - lib/mumukit/metatest/test_result_builder.rb
326
316
  - lib/mumukit/request_validation_error.rb
327
317
  - lib/mumukit/runner.rb
328
318
  - lib/mumukit/runtime.rb
@@ -379,8 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
379
369
  - !ruby/object:Gem::Version
380
370
  version: '0'
381
371
  requirements: []
382
- rubyforge_project:
383
- rubygems_version: 2.7.7
372
+ rubygems_version: 3.0.3
384
373
  signing_key:
385
374
  specification_version: 4
386
375
  summary: Mumuki Test Server Development Kit