mumuki-java-runner 1.0.0 → 1.1.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: 2bf0c7e563b47d1319d58d5182df60adbb288de8
4
- data.tar.gz: 25b86a5e426eadd2773e0c9d8500b69678555951
3
+ metadata.gz: 0a541271b702736638069bec61f59aabb4c448fc
4
+ data.tar.gz: aaa46fb1556615c7c8690527c58c31f986371254
5
5
  SHA512:
6
- metadata.gz: bf17f20de127e1365e33524ee8a9be1bb9cd2680ce68e17a92b5f899af84be457ff3309ee50761a73263ef193e349f3eebf5af00c3ab092b991ffe1457460b39
7
- data.tar.gz: 01e4f8236d9938835f2e1f3a9d1351403f00516a13346e53766c1f2ecf0c676f4990d26d817ac47b6b3bc0dfc99b0b4ca91095b0a3d31236ea1d5b122ca33e38
6
+ metadata.gz: 599d52e7d4669ac2a7ac3cf470bfa6ad3fb545ecd76bea143b4ba89cae42f2c3017fa675503f50cd954d83965cdc7f9d7a92bcb48b9ae2267cf7c04e402d767a
7
+ data.tar.gz: 8f298391002b59499a250c594fd15ef65d7d06a0d3fafa6be0e49d75ecf90c5dc7b429665991a76c2f33946c3c6ff3e540ab80c604d9929b4b3d77fafa02a194
@@ -3,8 +3,8 @@ require 'mumukit'
3
3
  Mumukit.runner_name = 'java'
4
4
  Mumukit.configure do |config|
5
5
  config.docker_image = 'mumuki/mumuki-junit-worker'
6
-
7
6
  end
8
7
 
8
+ require_relative './version'
9
9
  require_relative './test_hook'
10
- require_relative './metadata_hook'
10
+ require_relative './metadata_hook'
@@ -1,5 +1,6 @@
1
1
  class JavaTestHook < Mumukit::Templates::FileHook
2
2
  isolated true
3
+ structured true
3
4
 
4
5
  def tempfile_extension
5
6
  '.java'
@@ -9,6 +10,14 @@ class JavaTestHook < Mumukit::Templates::FileHook
9
10
  "runjunit #{filename}"
10
11
  end
11
12
 
13
+ def to_structured_result(result)
14
+ transform(JSON.parse(result))
15
+ end
16
+
17
+ def transform(examples)
18
+ examples.map { |e| [e[0], e[1].to_sym, e[2]] }
19
+ end
20
+
12
21
  def post_process_file(file, result, status)
13
22
  if result.include? '!!TEST FINISHED WITH COMPILATION ERROR!!'
14
23
  [result, :errored]
@@ -22,21 +31,57 @@ class JavaTestHook < Mumukit::Templates::FileHook
22
31
  import java.util.*;
23
32
  import java.util.function.*;
24
33
  import java.util.stream.*;
34
+ import java.util.stream.Collectors.*;
25
35
  import java.time.*;
36
+ import org.junit.runner.RunWith;
26
37
  import org.junit.*;
27
-
38
+ import org.junit.runner.*;
39
+ import org.junit.runner.notification.*;
40
+ import org.junit.runners.*;
41
+ import org.junit.runners.model.InitializationError;
42
+ import org.apache.commons.text.StringEscapeUtils;
28
43
  #{request.content}
29
-
30
44
  #{request.extra}
31
45
 
32
46
  public class SubmissionTest {
33
- #{request.test}
34
-
35
- public static void main(String args[]) {
36
- org.junit.runner.JUnitCore.main("SubmissionTest");
47
+ #{request.test}
48
+ public static void main(String[] args) {
49
+ JUnitCore core = new JUnitCore();
50
+ core.addListener(new MuListener());
51
+ core.run(SubmissionTest.class);
52
+ }
37
53
  }
54
+ class MuListener extends RunListener {
55
+ private Map<String, Collection<String>> tests = new HashMap<>();
56
+ @Override
57
+ public void testStarted(Description description) throws Exception {
58
+ String methodName = description.getMethodName();
59
+ tests.put(methodName, Arrays.asList(methodName, "passed"));
60
+ }
61
+
62
+ @Override
63
+ public void testFailure(Failure failure) {
64
+ String methodName = failure.getDescription().getMethodName();
65
+ tests.put(methodName, Arrays.asList(methodName, "failed", failure.getMessage()));
66
+ }
67
+
68
+ @Override
69
+ public void testRunFinished(Result r) {
70
+ String result = prettyFormatResults(tests.values());
71
+ System.out.println(StringEscapeUtils.unescapeJson(result));
72
+ }
73
+
74
+ public String prettyFormatString(String string) {
75
+ return ("\\\""+string+"\\\"");
76
+ }
77
+ public String prettyFormatExample(Collection<String> example) {
78
+ return "["+example.stream().map(element -> prettyFormatString(element)).collect(Collectors.joining(",")) +"]";
79
+ }
80
+ public String prettyFormatResults(Collection<Collection<String>> results) {
81
+ return "["+results.stream().map(element -> prettyFormatExample(element)).collect(Collectors.joining(","))+"]";
82
+ }
38
83
  }
39
84
  EOF
40
85
  end
41
86
 
42
- end
87
+ end
@@ -0,0 +1,3 @@
1
+ module JavaVersionHook
2
+ VERSION = '1.1.0'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-java-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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: 2016-09-27 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit
@@ -104,6 +104,7 @@ files:
104
104
  - lib/java_runner.rb
105
105
  - lib/metadata_hook.rb
106
106
  - lib/test_hook.rb
107
+ - lib/version.rb
107
108
  homepage: http://github.com/mumuki/mumuki-java-server
108
109
  licenses:
109
110
  - MIT
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
125
  version: '0'
125
126
  requirements: []
126
127
  rubyforge_project:
127
- rubygems_version: 2.4.8
128
+ rubygems_version: 2.6.11
128
129
  signing_key:
129
130
  specification_version: 4
130
131
  summary: Java Runner for Mumuki