mumuki-qsim-runner 1.0.1 → 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: 079017d67d9727f4e5b9254b2a2e9650c2ea6ead
4
- data.tar.gz: 250ad7275089849027cab37208a0b55ac4170f3a
3
+ metadata.gz: e328f5107c8be0e6be6afbfc57da5155a8bf9b94
4
+ data.tar.gz: 933c6c30132d17a78166df63bb672a3306944af3
5
5
  SHA512:
6
- metadata.gz: 8dd8c9fb0278a5169b776014a559ccc0aff025afb8475177de8a74eb6438829473f896781a9ace9e47b9255ae557a1369ce9a82a0d1b727cc487057d07293831
7
- data.tar.gz: c646587d123053b75251902e21496ed8e57a8283a7559fcae1813fc5199a0f125295c13a20037e2523cedde7c5f05ef33f358e9e1d90b316230481bc507684a9
6
+ metadata.gz: e1211643581f06df53885d4cc368da7b05e18524b3ad37766cb2cd0018bbae1d8aff01db35adc2771bdbe4e50a11565eb6f9aff50c29bb981c350202a86f4682
7
+ data.tar.gz: db5bcf5ed50f23e1ecb33b100be94c97c5ec6a2efa4ad1ed115bc682e6cdbcc63358c0448bf92076e54d59597299e9e1d61a1d49ae218d6c8d36a24f1178f763
@@ -0,0 +1,10 @@
1
+ module Qsim
2
+ class MultipleExecutionsRunner
3
+ def run(output, example)
4
+ result = output.find { |it| it[:id] == example[:id] }
5
+
6
+ raise Mumukit::Metatest::Errored, result[:error] if result[:error]
7
+ result
8
+ end
9
+ end
10
+ end
@@ -13,4 +13,5 @@ end
13
13
  require_relative './test_hook'
14
14
  require_relative './metadata_hook'
15
15
  require_relative './checker'
16
+ require_relative './multiple_executions_runner'
16
17
  require_relative './html_renderer'
@@ -1,18 +1,28 @@
1
1
  class QsimTestHook < Mumukit::Templates::FileHook
2
+ include Mumukit::WithTempfile
2
3
  isolated true
3
- mashup :extra, :content
4
4
 
5
5
  def tempfile_extension
6
6
  '.qsim'
7
7
  end
8
8
 
9
9
  def command_line(filename)
10
- "runqsim #{filename} 6"
10
+ "runqsim #{filename} #{q_architecture} #{input_file_separator}"
11
11
  end
12
12
 
13
13
  def compile_file_content(request)
14
- @examples = parse_test(request)[:examples]
15
- (super request).strip
14
+ @examples = to_examples(parse_test(request)[:examples])
15
+
16
+ <<EOF
17
+ CALL main
18
+
19
+ #{request.extra}
20
+
21
+ main:
22
+ #{request.content}
23
+ #{input_file_separator}
24
+ #{initial_state_file}
25
+ EOF
16
26
  end
17
27
 
18
28
  def execute!(request)
@@ -35,16 +45,61 @@ class QsimTestHook < Mumukit::Templates::FileHook
35
45
 
36
46
  private
37
47
 
48
+ def to_examples(examples)
49
+ defaults = { preconditions: {} }
50
+ examples.each_with_index.map { |example, index| defaults.merge(example).merge(id: index) }
51
+ end
52
+
38
53
  def framework
39
54
  Mumukit::Metatest::Framework.new checker: Qsim::Checker.new,
40
- runner: Mumukit::Metatest::IdentityRunner.new
55
+ runner: Qsim::MultipleExecutionsRunner.new
41
56
  end
42
57
 
43
58
  def parse_json(json_result)
44
- JSON.parse(json_result).deep_symbolize_keys
59
+ JSON.parse(json_result).map(&:deep_symbolize_keys)
45
60
  end
46
61
 
47
62
  def parse_test(request)
48
63
  YAML.load(request.test).deep_symbolize_keys
49
64
  end
65
+
66
+ def default_initial_state
67
+ {
68
+ special_records: {
69
+ PC: '0000',
70
+ SP: 'FFEF',
71
+ IR: '0000'
72
+ },
73
+ flags: {
74
+ N: 0,
75
+ Z: 0,
76
+ V: 0,
77
+ C: 0
78
+ },
79
+ records: {
80
+ R0: '0000',
81
+ R1: '0000',
82
+ R2: '0000',
83
+ R3: '0000',
84
+ R4: '0000',
85
+ R5: '0000',
86
+ R6: '0000',
87
+ R7: '0000'
88
+ },
89
+ memory: {}
90
+ }
91
+ end
92
+
93
+ def initial_state_file
94
+ initial_states = @examples.map { |example| default_initial_state.merge(id: example[:id]).merge(example[:preconditions]) }
95
+ JSON.generate initial_states
96
+ end
97
+
98
+ def input_file_separator
99
+ '!!!BEGIN_EXAMPLES!!!'
100
+ end
101
+
102
+ def q_architecture
103
+ 6
104
+ end
50
105
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-qsim-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
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-28 00:00:00.000000000 Z
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit
@@ -106,6 +106,7 @@ files:
106
106
  - lib/locales/en.yml
107
107
  - lib/locales/es.yml
108
108
  - lib/metadata_hook.rb
109
+ - lib/multiple_executions_runner.rb
109
110
  - lib/qsim_runner.rb
110
111
  - lib/records.html.erb
111
112
  - lib/test_hook.rb