mumuki-cpp-runner 1.2.0 → 1.3.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: dc5b24afc85d7b43741270c7c2c5f7c2910f03c4
4
- data.tar.gz: 505fe18a3a1f5979ffacb3a276939a6936dbd35b
3
+ metadata.gz: 9c481b077c1b72bf64d1b1121a1227d7b07d21c0
4
+ data.tar.gz: f8c626d9ec01ead7616c1196152978da08b1d816
5
5
  SHA512:
6
- metadata.gz: 1aaca1717287a0147b97821724e120c32b57f7884bd1ea09c776033385e4d87b881255b63d924a4d8bbee9aa830f7cfbcb701bf6baef776aa57b3f54d49bb02d
7
- data.tar.gz: a635187fe6dbee7a5ef0e992b2063525cdf08e000012a673d5d98d60f3fb008f3c4ab110a8c49044a1e1471ef2864b80d73d41930b3e683236b0a2d3c0606e00
6
+ metadata.gz: b25b4fd4e73a974e48fd5c2011ba219a329bced7661433a4671d79c578f6d56a88a8b44e643ad756b6afcd7b5cc7ab1e8794c5aa12b22ac80b8654cd8509b7af
7
+ data.tar.gz: 4206a939d4f2a453258538de886da2618613eb4e1f7fecddff296ecc433192cf22d52922dd05fa1b623d467fa993bb357b383caf613d358748b39e4386fc7e8f
data/lib/cpp_runner.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'mumukit'
2
2
 
3
+ I18n.load_translations_path File.join(__dir__, 'locales', '*.yml')
4
+
3
5
  Mumukit.runner_name = 'cpp'
4
6
  Mumukit.configure do |config|
5
7
  config.docker_image = 'mumuki/mumuki-cppunit-worker'
@@ -7,4 +9,5 @@ end
7
9
 
8
10
  require_relative './test_hook'
9
11
  require_relative './version_hook'
10
- require_relative './metadata_hook'
12
+ require_relative './metadata_hook'
13
+ require_relative './feedback_hook'
@@ -0,0 +1,104 @@
1
+ class CppFeedbackHook < Mumukit::Hook
2
+ def run!(request, results)
3
+ content = request.content
4
+ test_results = results.test_results[0]
5
+
6
+ CppExplainer.new.explain(content, test_results) if test_results.is_a? String
7
+ end
8
+
9
+ class CppExplainer < Mumukit::Explainer
10
+
11
+ def near_regex()
12
+ '.*[\t \n]* *(.*)\n[ \t]+\^'
13
+ end
14
+
15
+ def error()
16
+ '[eE]rror:'
17
+ end
18
+
19
+ def explain_has_no_member_named(_, result)
20
+ (/#{error} '(.*)' has no member named '(.*)'#{near_regex}/.match result).try do |it|
21
+ {type: it[1], target: it[2], near: it[3]}
22
+ end
23
+ end
24
+
25
+ def explain_was_not_declared_in_this_scope(_, result)
26
+ (/#{error} '(.*)' was not declared in this scope#{near_regex}/.match result).try do |it|
27
+ {target: it[1], near: it[2]}
28
+ end
29
+ end
30
+
31
+ def explain_does_not_a_type(_, result)
32
+ (/#{error} '(.*)' does not name a type#{near_regex}/.match result).try do |it|
33
+ {type: it[1], near: it[2]}
34
+ end
35
+ end
36
+
37
+ def explain_has_incomplete_type_and_cannot_be_defined(_, result)
38
+ (/#{error} aggregate '(.*)' has incomplete type and cannot be defined#{near_regex}/.match result).try do |it|
39
+ {type: it[1], near: it[2]}
40
+ end
41
+ end
42
+
43
+ def explain_invalid_suffix(_, result)
44
+ (/#{error} invalid suffix "(.*)" on integer constant#{near_regex}/.match result).try do |it|
45
+ {suffix: it[1], near: it[2]}
46
+ end
47
+ end
48
+
49
+ def explain_expected_comma_before_token(_, result)
50
+ (/#{error} expected ',' or '.{3}' before '\.' token#{near_regex}/.match result).try do |it|
51
+ {near: it[1]}
52
+ end
53
+ end
54
+
55
+ def explain_expected_initializer_before_token(_, result)
56
+ (/#{error} expected initializer before '.' token#{near_regex}/.match result).try do |it|
57
+ {near: it[1]}
58
+ end
59
+ end
60
+
61
+ def explain_too_many_arguments_to_function(_, result)
62
+ (/#{error} too many arguments to function '(.*)'#{near_regex}/.match result).try do |it|
63
+ {target: it[1], near: it[2]}
64
+ end
65
+ end
66
+
67
+ def explain_too_few_arguments_to_function(_, result)
68
+ (/#{error} too few arguments to function '(.*)'#{near_regex}/.match result).try do |it|
69
+ {target: it[1], near: it[2]}
70
+ end
71
+ end
72
+
73
+ def explain_call_of_overloaded_is_ambiguous(_, result)
74
+ (/#{error} call of overloaded '(.*)' is ambiguous#{near_regex}/.match result).try do |it|
75
+ {target: it[1], near: it[2]}
76
+ end
77
+ end
78
+
79
+ def explain_invalid_conversion_from_to(_, result)
80
+ (/#{error} invalid conversion from '(.*)' to '(.*)'#{near_regex}/.match result).try do |it|
81
+ {expected: it[1], actual: it[2], near: it[3]}
82
+ end
83
+ end
84
+
85
+ def explain_expected_after_struct_definition(_, result)
86
+ (/#{error} expected ';' after struct definition#{near_regex}/.match result).try do |it|
87
+ {near: it[1]}
88
+ end
89
+ end
90
+
91
+ def explain_expected_initializer_before(_, result)
92
+ (/#{error} expected initializer before '(.*)'#{near_regex}/.match result).try do |it|
93
+ {near: it[2]}
94
+ end
95
+ end
96
+
97
+ def explain_expected_unqualified_id(_, result)
98
+ (/#{error} expected unqualified-id before '(.*)' token#{near_regex}/.match result).try do |it|
99
+ {token: it[1], near: it[2]}
100
+ end
101
+ end
102
+
103
+ end
104
+ end
@@ -0,0 +1 @@
1
+ en:
@@ -0,0 +1,15 @@
1
+ en:
2
+ has_no_member_named: 'Parece que no existe el campo, atributo o método `%{target}` en `%{type}`. Revisá en esta parte `%{near}` que exista o el nombre esté bien escrito.'
3
+ was_not_declared_in_this_scope: 'El identificador `%{target}` no existe. Revisá en esta parte `%{near}` si está bien escrito o si estás usando la variable correcta.'
4
+ does_not_a_type: 'No hay un tipo de dato con el nombre `%{type}`. Revisá en esta parte `%{near}` si está bien escrito.'
5
+ has_incomplete_type_and_cannot_be_defined: 'Parece que no definiste el tipo `%{type}`. Revisá en esta parte `%{near}` que el nombre esté bien escrito.'
6
+ invalid_suffix: 'Parece que intentaste definir un identificador `%{suffix}` no válido. Revisá en esta parte `%{near}` si lo empezaste con un número. Recordá que los nombres de los identificadores deben comenzar con una **letra**, **$** o **_** (guión bajo).'
7
+ expected_comma_before_token: 'El nombre de uno de los parámetros está mal. Revisá en esta parte `%{near}` que no tenga puntos en el nombre.'
8
+ expected_initializer_before_token: 'El nombre de una de las variables está mal. Revisá en esta parte `%{near}` que no tenga puntos en el nombre.'
9
+ too_many_arguments_to_function: 'Parece que invocaste a la función `%{target}` con más argumentos de los que lleva. Revisá en esta parte `%{near}` la llamada a la función.'
10
+ too_few_arguments_to_function: 'Parece que invocaste a la función `%{target}` con menos argumentos de los que lleva. Revisá en esta parte `%{near}` la llamada a la función.'
11
+ call_of_overloaded_is_ambiguous: 'Uno o más argumentos están mal al invocar a `%{target}`. Revisá en esta parte `%{near}` con qué argumentos la estas llamando.'
12
+ invalid_conversion_from_to: 'Se esperaba un valor de tipo `%{expected}` pero se recibió uno de `%{actual}` en esta línea `%{near}`.'
13
+ expected_after_struct_definition: 'Falta el `;` después de definir el registro.'
14
+ expected_initializer_before: 'Probablemente falte un `;` después de declarar una variable en la línea anterior a `%{near}`.'
15
+ expected_unqualified_id: 'El identificador que se encuentra entes que `%{token}` no es válido. Revisá en esta parte `%{near}`.'
data/lib/metadata_hook.rb CHANGED
@@ -2,7 +2,7 @@ class CppMetadataHook < Mumukit::Hook
2
2
  def metadata
3
3
  {language: {
4
4
  name: 'c++',
5
- icon: {type: 'devicon', name: 'c'},
5
+ icon: {type: 'devicon', name: 'cpp'},
6
6
  extension: 'cpp',
7
7
  ace_mode: 'c_cpp'
8
8
  },
data/lib/test_hook.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  class CppTestHook < Mumukit::Templates::FileHook
2
2
  mashup
3
3
  isolated true
4
+ structured true
4
5
 
5
6
  def tempfile_extension
6
7
  '.cpp'
@@ -13,10 +14,16 @@ class CppTestHook < Mumukit::Templates::FileHook
13
14
  def post_process_file(file, result, status)
14
15
  if result.include? '!!TEST FINISHED WITH COMPILATION ERROR!!'
15
16
  [result, :errored]
16
- elsif result.include? '!!!FAILURES!!!'
17
- [result, :failed]
18
17
  else
19
- [result, :passed]
18
+ super
19
+ end
20
+ end
21
+
22
+ def to_structured_result(result)
23
+ if result.include? '!!!FAILURES!!!'
24
+ transform(result)
25
+ else
26
+ [['All tests passed', :passed]]
20
27
  end
21
28
  end
22
29
 
@@ -35,4 +42,19 @@ int main( int argc, char **argv)
35
42
  }
36
43
  EOF
37
44
  end
45
+
46
+ private
47
+
48
+ def transform(result)
49
+ result
50
+ .split(/\d{0,9}\) test: MumukiTest::/)
51
+ .drop(1)
52
+ .map do |it|
53
+ captures = it.split("\n")
54
+ title = captures.first.split(' (F)').first
55
+ result = [captures[1], captures[2], captures[3], captures[4], captures[5]].compact.join(' ').strip
56
+ [title, :failed, result]
57
+ end
58
+ end
59
+
38
60
  end
data/lib/version_hook.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CppVersionHook
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-cpp-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.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-15 00:00:00.000000000 Z
11
+ date: 2017-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit
@@ -102,6 +102,9 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - lib/cpp_runner.rb
105
+ - lib/feedback_hook.rb
106
+ - lib/locales/en.yml
107
+ - lib/locales/es.yml
105
108
  - lib/metadata_hook.rb
106
109
  - lib/test_hook.rb
107
110
  - lib/version_hook.rb
@@ -125,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
128
  version: '0'
126
129
  requirements: []
127
130
  rubyforge_project:
128
- rubygems_version: 2.4.8
131
+ rubygems_version: 2.6.11
129
132
  signing_key:
130
133
  specification_version: 4
131
134
  summary: Cpp Runner for Mumuki