mumukit 2.34.1 → 2.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mumukit/metatest.rb +2 -1
- data/lib/mumukit/metatest/checker.rb +49 -11
- data/lib/mumukit/metatest/errors.rb +11 -4
- data/lib/mumukit/metatest/test_result_builder.rb +20 -0
- data/lib/mumukit/server/response_builder.rb +10 -4
- data/lib/mumukit/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c93b40ab8d9ea10cfe1e73457763ef6146c396fbfe6feeab318e0e4938553fff
|
|
4
|
+
data.tar.gz: e7b34dad3b8a67f5be0468e720bfae08a985eae4f7b299886919a03a765367e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40a8ad3cbe13a399ae7d012819eff925497920cd1233e6b4f16db14aa5f60fe0b6b521c491532c77d36f7b1c5e998b3aa132275006fd55bab3b944c258f429ef
|
|
7
|
+
data.tar.gz: 5135710e6ebbb026321d6f36fdcb0139203612d75ec5255805158438ef7008cf469813ae778395c42aa1f16b3ccd8e47366a94f5ec8adcc75b624cff8ef75aa1
|
data/lib/mumukit/metatest.rb
CHANGED
|
@@ -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
|
-
|
|
30
|
+
build_passed_test_result builder, example, input
|
|
29
31
|
rescue => e
|
|
30
|
-
|
|
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
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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, input, _example, 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,
|
|
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
|
|
62
|
-
|
|
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
|
|
66
|
-
|
|
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
|
|
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 <
|
|
12
|
+
class Errored < BaseError
|
|
6
13
|
end
|
|
7
14
|
|
|
8
|
-
class Failed <
|
|
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
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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)
|
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.35.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: 2020-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -323,6 +323,7 @@ files:
|
|
|
323
323
|
- lib/mumukit/metatest/framework.rb
|
|
324
324
|
- lib/mumukit/metatest/identity_runner.rb
|
|
325
325
|
- lib/mumukit/metatest/interactive_checker.rb
|
|
326
|
+
- lib/mumukit/metatest/test_result_builder.rb
|
|
326
327
|
- lib/mumukit/request_validation_error.rb
|
|
327
328
|
- lib/mumukit/runner.rb
|
|
328
329
|
- lib/mumukit/runtime.rb
|