ciat 0.4.9 → 0.4.10
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.
- data/lib/ciat.rb +1 -2
- data/lib/ciat/{test_file.rb → ciat_file.rb} +21 -9
- data/lib/ciat/erb_helpers.rb +6 -1
- data/lib/ciat/feedback/feedback_counter.rb +11 -19
- data/lib/ciat/feedback/return_status.rb +6 -2
- data/lib/ciat/feedback/standard_output.rb +7 -2
- data/lib/ciat/processors/compilation_interpreter.rb +20 -7
- data/lib/ciat/processors/compiler.rb +38 -15
- data/lib/ciat/processors/interpreter.rb +28 -7
- data/lib/ciat/processors/java.rb +2 -8
- data/lib/ciat/processors/parrot.rb +0 -3
- data/lib/ciat/subresult.rb +14 -4
- data/lib/ciat/subtest.rb +83 -0
- data/lib/ciat/suite.rb +9 -9
- data/lib/ciat/suite_builder.rb +5 -5
- data/lib/ciat/test.rb +36 -28
- data/lib/ciat/test_result.rb +2 -2
- data/lib/ciat/traffic_light.rb +5 -14
- data/lib/data/ciat.css +14 -2
- data/lib/data/elements.yml +8 -2
- data/lib/templates/detail_row.html.erb +10 -4
- data/lib/templates/report.html.erb +5 -5
- data/lib/templates/summary_row.html.erb +5 -3
- data/spec/ciat/{test_file_spec.rb → ciat_file_spec.rb} +51 -19
- data/spec/ciat/erb_helpers_spec.rb +8 -13
- data/spec/ciat/feedback/feedback_counter_spec.rb +37 -57
- data/spec/ciat/feedback/return_status_spec.rb +67 -61
- data/spec/ciat/feedback/standard_output_spec.rb +21 -15
- data/spec/ciat/processors/compilation_interpreter_spec.rb +12 -0
- data/spec/ciat/processors/compiler_spec.rb +12 -0
- data/spec/ciat/processors/interpreter_spec.rb +12 -0
- data/spec/ciat/processors/java_spec.rb +0 -10
- data/spec/ciat/processors/parrot_spec.rb +0 -10
- data/spec/ciat/processors/shared_examples_for_element_names.rb +27 -0
- data/spec/ciat/rake_task_spec.rb +65 -0
- data/spec/ciat/subresult_spec.rb +13 -12
- data/spec/ciat/subtest_spec.rb +199 -0
- data/spec/ciat/suite_builder_spec.rb +17 -17
- data/spec/ciat/suite_spec.rb +13 -13
- data/spec/ciat/test_result_spec.rb +36 -0
- data/spec/ciat/test_spec.rb +73 -83
- data/spec/ciat/traffic_light_spec.rb +21 -31
- data/spec/spec_helper.rb +16 -53
- data/spec/templates/detail_row/elements_html_erb_spec.rb +3 -4
- data/spec/templates/detail_row_html_erb_spec.rb +84 -23
- data/spec/templates/elements/diff_html_erb_spec.rb +5 -3
- data/spec/templates/summary_row_html_erb_spec.rb +21 -14
- metadata +13 -7
- data/lib/ciat/processors/basic_processing.rb +0 -55
- data/spec/ciat/processors/basic_processing_spec.rb +0 -146
@@ -5,6 +5,7 @@ require 'hpricot'
|
|
5
5
|
describe "checked-files output in detail row" do
|
6
6
|
include ERBHelpers
|
7
7
|
include CustomDetailRowMatchers
|
8
|
+
include Webrat::Matchers
|
8
9
|
|
9
10
|
attr_reader :erb
|
10
11
|
attr_reader :element
|
@@ -21,8 +22,9 @@ describe "checked-files output in detail row" do
|
|
21
22
|
@element.should_receive(:describe).at_least(:once).and_return("the description")
|
22
23
|
@element.should_receive(:content).and_return("the diff")
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
process_erb.should have_selector("body") do |body|
|
26
|
+
body.should have_selector("h4", :content => "the description")
|
27
|
+
body.should have_diff_table("the diff")
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
3
|
require 'hpricot'
|
4
|
+
require 'webrat'
|
4
5
|
|
5
6
|
describe "summary row of test report" do
|
6
7
|
include ERBHelpers
|
7
8
|
include CustomDetailRowMatchers
|
9
|
+
include Webrat::Matchers
|
8
10
|
|
9
11
|
attr_reader :erb
|
10
12
|
attr_reader :recursion
|
@@ -20,9 +22,10 @@ describe "summary row of test report" do
|
|
20
22
|
expect_description("the description")
|
21
23
|
@result.should_receive(:subresults).at_least(:once).and_return([])
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
process_erb.should have_selector("body") do |body|
|
26
|
+
body.should have_selector("a", :content => "the description")
|
27
|
+
body.should have_selector("td", :count => 1)
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
it "should work with one processor" do
|
@@ -35,9 +38,11 @@ describe "summary row of test report" do
|
|
35
38
|
expect_light(subresult, :light_setting, "the light")
|
36
39
|
|
37
40
|
doc = process_erb
|
38
|
-
doc.should
|
39
|
-
|
40
|
-
|
41
|
+
doc.should have_selector("body") do |body|
|
42
|
+
body.should have_selector("a", :content => "one proc description")
|
43
|
+
body.should have_selector(".light_setting", :content => "the light")
|
44
|
+
body.should have_selector("td", :count => 2)
|
45
|
+
end
|
41
46
|
end
|
42
47
|
|
43
48
|
it "should work with many processors" do
|
@@ -50,24 +55,26 @@ describe "summary row of test report" do
|
|
50
55
|
expect_light(subresults[1], :light1, "word 1")
|
51
56
|
expect_light(subresults[2], :light2, "word 2")
|
52
57
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
process_erb.should have_selector("body") do |body|
|
59
|
+
body.should have_selector("a", :content => "description three")
|
60
|
+
body.should have_light(:light0, "word 0")
|
61
|
+
body.should have_light(:light1, "word 1")
|
62
|
+
body.should have_light(:light2, "word 2")
|
63
|
+
body.should have_selector("td", :count => 4)
|
64
|
+
end
|
59
65
|
end
|
60
66
|
|
61
67
|
def expect_light(subresult, setting, word)
|
62
68
|
light = mock("mock #{setting}")
|
63
69
|
subresult.should_receive(:light).at_least(:once).and_return(light)
|
64
|
-
light.should_receive(:
|
70
|
+
light.should_receive(:color).and_return(setting)
|
65
71
|
light.should_receive(:text).and_return(word)
|
66
72
|
end
|
67
73
|
|
68
74
|
def expect_description(text)
|
69
75
|
description = mock("description")
|
70
|
-
@result.should_receive(:element).
|
76
|
+
@result.should_receive(:element).
|
77
|
+
with(:description).and_return(description)
|
71
78
|
description.should_receive(:content).and_return(text)
|
72
79
|
end
|
73
80
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ciat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy D. Frens
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-11-21 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -24,6 +24,7 @@ extra_rdoc_files:
|
|
24
24
|
- README.rdoc
|
25
25
|
files:
|
26
26
|
- lib/ciat.rb
|
27
|
+
- lib/ciat/ciat_file.rb
|
27
28
|
- lib/ciat/differs/html_differ.rb
|
28
29
|
- lib/ciat/erb_helpers.rb
|
29
30
|
- lib/ciat/feedback/composite.rb
|
@@ -33,7 +34,6 @@ files:
|
|
33
34
|
- lib/ciat/feedback/return_status.rb
|
34
35
|
- lib/ciat/feedback/standard_output.rb
|
35
36
|
- lib/ciat/io.rb
|
36
|
-
- lib/ciat/processors/basic_processing.rb
|
37
37
|
- lib/ciat/processors/compilation_interpreter.rb
|
38
38
|
- lib/ciat/processors/compiler.rb
|
39
39
|
- lib/ciat/processors/interpreter.rb
|
@@ -41,11 +41,11 @@ files:
|
|
41
41
|
- lib/ciat/processors/parrot.rb
|
42
42
|
- lib/ciat/rake_task.rb
|
43
43
|
- lib/ciat/subresult.rb
|
44
|
+
- lib/ciat/subtest.rb
|
44
45
|
- lib/ciat/suite.rb
|
45
46
|
- lib/ciat/suite_builder.rb
|
46
47
|
- lib/ciat/test.rb
|
47
48
|
- lib/ciat/test_element.rb
|
48
|
-
- lib/ciat/test_file.rb
|
49
49
|
- lib/ciat/test_result.rb
|
50
50
|
- lib/ciat/traffic_light.rb
|
51
51
|
- lib/data/ciat.css
|
@@ -70,7 +70,7 @@ rdoc_options:
|
|
70
70
|
- --title
|
71
71
|
- CIAT -- Compiler and Interpreter Acceptance Tester
|
72
72
|
- --main
|
73
|
-
- README.
|
73
|
+
- README.rdoc
|
74
74
|
- --line-numbers
|
75
75
|
require_paths:
|
76
76
|
- lib
|
@@ -94,20 +94,26 @@ signing_key:
|
|
94
94
|
specification_version: 3
|
95
95
|
summary: Acceptance tester for compilers and interpreters
|
96
96
|
test_files:
|
97
|
+
- spec/ciat/ciat_file_spec.rb
|
97
98
|
- spec/ciat/erb_helpers_spec.rb
|
98
99
|
- spec/ciat/feedback/composite_spec.rb
|
99
100
|
- spec/ciat/feedback/feedback_counter_spec.rb
|
100
101
|
- spec/ciat/feedback/html_feedback_spec.rb
|
101
102
|
- spec/ciat/feedback/return_status_spec.rb
|
102
103
|
- spec/ciat/feedback/standard_output_spec.rb
|
103
|
-
- spec/ciat/processors/
|
104
|
+
- spec/ciat/processors/compilation_interpreter_spec.rb
|
105
|
+
- spec/ciat/processors/compiler_spec.rb
|
106
|
+
- spec/ciat/processors/interpreter_spec.rb
|
104
107
|
- spec/ciat/processors/java_spec.rb
|
105
108
|
- spec/ciat/processors/parrot_spec.rb
|
109
|
+
- spec/ciat/processors/shared_examples_for_element_names.rb
|
110
|
+
- spec/ciat/rake_task_spec.rb
|
106
111
|
- spec/ciat/subresult_spec.rb
|
112
|
+
- spec/ciat/subtest_spec.rb
|
107
113
|
- spec/ciat/suite_builder_spec.rb
|
108
114
|
- spec/ciat/suite_spec.rb
|
109
115
|
- spec/ciat/test_element_spec.rb
|
110
|
-
- spec/ciat/
|
116
|
+
- spec/ciat/test_result_spec.rb
|
111
117
|
- spec/ciat/test_spec.rb
|
112
118
|
- spec/ciat/traffic_light_spec.rb
|
113
119
|
- spec/ciat_spec.rb
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'ciat/differs/html_differ'
|
3
|
-
|
4
|
-
module CIAT::Processors
|
5
|
-
module BasicProcessing
|
6
|
-
include CIAT::Differs::HtmlDiffer
|
7
|
-
|
8
|
-
# Executes the program, and diffs the output.
|
9
|
-
def process(test)
|
10
|
-
# TODO: verify required elements
|
11
|
-
# TODO: handle optional element
|
12
|
-
if execute(test)
|
13
|
-
if diff(test)
|
14
|
-
CIAT::TrafficLight::GREEN
|
15
|
-
else
|
16
|
-
CIAT::TrafficLight::RED
|
17
|
-
end
|
18
|
-
else
|
19
|
-
CIAT::TrafficLight::YELLOW
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def execute(test)
|
24
|
-
RakeFileUtils.verbose(false) do
|
25
|
-
sh "#{executable} '#{input_file(test)}' #{command_line_args(test)} > '#{output_file(test)}' 2> '#{error_file(test)}'" do |ok, result|
|
26
|
-
return ok
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def command_line_args(test) #:nodoc:
|
32
|
-
test.element?(:command_line) ? test.element(:command_line).content.strip : ''
|
33
|
-
end
|
34
|
-
|
35
|
-
# Compares the expected and generated executions.
|
36
|
-
def diff(test)
|
37
|
-
html_diff(
|
38
|
-
test.element(kind.output_name).as_file,
|
39
|
-
test.element(kind.output_name, :generated).as_file,
|
40
|
-
test.element(kind.output_name, :diff).as_file)
|
41
|
-
end
|
42
|
-
|
43
|
-
def input_file(test)
|
44
|
-
test.element(kind.input_name).as_file
|
45
|
-
end
|
46
|
-
|
47
|
-
def output_file(test)
|
48
|
-
test.element(kind.output_name, :generated).as_file
|
49
|
-
end
|
50
|
-
|
51
|
-
def error_file(test)
|
52
|
-
test.element(kind.output_name, :error).as_file
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,146 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
-
|
3
|
-
describe CIAT::Processors::BasicProcessing do
|
4
|
-
class Processor
|
5
|
-
include CIAT::Processors::BasicProcessing
|
6
|
-
end
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
@processor = Processor.new
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "processing" do
|
13
|
-
before(:each) do
|
14
|
-
@test = mock("test")
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should execute and diff normally" do
|
18
|
-
@processor.should_receive(:execute).with(@test).and_return(true)
|
19
|
-
@processor.should_receive(:diff).with(@test).and_return(true)
|
20
|
-
|
21
|
-
@processor.process(@test).should == CIAT::TrafficLight::GREEN
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should execute with an error" do
|
25
|
-
@processor.should_receive(:execute).with(@test).and_return(false)
|
26
|
-
|
27
|
-
@processor.process(@test).should == CIAT::TrafficLight::YELLOW
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should execute normally and diff with a failure" do
|
31
|
-
@processor.should_receive(:execute).with(@test).and_return(true)
|
32
|
-
@processor.should_receive(:diff).with(@test).and_return(false)
|
33
|
-
|
34
|
-
@processor.process(@test).should == CIAT::TrafficLight::RED
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "executing a processor for a test" do
|
39
|
-
it "should put together and execute a shell command" do
|
40
|
-
test, ok, result = mock("test"), mock("ok"), mock("result")
|
41
|
-
|
42
|
-
@processor.should_receive(:executable).and_return("[executable]")
|
43
|
-
@processor.should_receive(:input_file).with(test).
|
44
|
-
and_return("[input]")
|
45
|
-
@processor.should_receive(:command_line_args).with(test).
|
46
|
-
and_return("[args]")
|
47
|
-
@processor.should_receive(:output_file).with(test).
|
48
|
-
and_return("[output]")
|
49
|
-
@processor.should_receive(:error_file).with(test).
|
50
|
-
and_return("[error]")
|
51
|
-
@processor.should_receive(:sh).
|
52
|
-
with("[executable] '[input]' [args] > '[output]' 2> '[error]'").
|
53
|
-
and_yield(ok, result)
|
54
|
-
|
55
|
-
@processor.execute(test).should == ok
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "handling command-line arguments" do
|
60
|
-
it "should strip command-line arguments" do
|
61
|
-
test = mock("test")
|
62
|
-
command_line = mock("command_line")
|
63
|
-
|
64
|
-
test.should_receive(:element?).with(:command_line).and_return(true)
|
65
|
-
test.should_receive(:element).with(:command_line).
|
66
|
-
and_return(command_line)
|
67
|
-
command_line.should_receive(:content).
|
68
|
-
and_return(" argument1 \t argument2 \n\n")
|
69
|
-
|
70
|
-
@processor.command_line_args(test).should == "argument1 \t argument2"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should return empty string if none provided" do
|
74
|
-
test = mock("test")
|
75
|
-
|
76
|
-
test.should_receive(:element?).with(:command_line).and_return(false)
|
77
|
-
|
78
|
-
@processor.command_line_args(test).should == ''
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "computing a diff" do
|
83
|
-
it "should compute a diff in HTML" do
|
84
|
-
test, kind, result =
|
85
|
-
mock("test"), mock("processor kind"), mock("result")
|
86
|
-
output_name = mock("output name")
|
87
|
-
|
88
|
-
@processor.should_receive(:kind).any_number_of_times.and_return(kind)
|
89
|
-
kind.should_receive(:output_name).any_number_of_times.
|
90
|
-
and_return(output_name)
|
91
|
-
original_file = expect_element_as_file(test, output_name)
|
92
|
-
generated_file = expect_element_as_file(test, output_name, :generated)
|
93
|
-
diff_file = expect_element_as_file(test, output_name, :diff)
|
94
|
-
@processor.should_receive(:html_diff).
|
95
|
-
with(original_file, generated_file, diff_file).and_return(result)
|
96
|
-
|
97
|
-
@processor.diff(test).should eql(result)
|
98
|
-
end
|
99
|
-
|
100
|
-
def expect_element_as_file(test, *names)
|
101
|
-
element, filename = mock("#{names} element"), mock("#{names} filename")
|
102
|
-
test.should_receive(:element).with(*names).and_return(element)
|
103
|
-
element.should_receive(:as_file).and_return(filename)
|
104
|
-
filename
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should get filename of input" do
|
109
|
-
test = mock("test")
|
110
|
-
kind, element, name = mock("kind"), mock("element"), mock("name")
|
111
|
-
filename = mock("filename")
|
112
|
-
|
113
|
-
@processor.should_receive(:kind).and_return(kind)
|
114
|
-
kind.should_receive(:input_name).and_return(name)
|
115
|
-
test.should_receive(:element).with(name).and_return(element)
|
116
|
-
element.should_receive(:as_file).and_return(filename)
|
117
|
-
|
118
|
-
@processor.input_file(test).should eql(filename)
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should get filename of input" do
|
122
|
-
test = mock("test")
|
123
|
-
kind, element, name = mock("kind"), mock("element"), mock("name")
|
124
|
-
filename = mock("filename")
|
125
|
-
|
126
|
-
@processor.should_receive(:kind).and_return(kind)
|
127
|
-
kind.should_receive(:output_name).and_return(name)
|
128
|
-
test.should_receive(:element).with(name, :generated).and_return(element)
|
129
|
-
element.should_receive(:as_file).and_return(filename)
|
130
|
-
|
131
|
-
@processor.output_file(test).should eql(filename)
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should get filename of input" do
|
135
|
-
test = mock("test")
|
136
|
-
kind, element, name = mock("kind"), mock("element"), mock("name")
|
137
|
-
filename = mock("filename")
|
138
|
-
|
139
|
-
@processor.should_receive(:kind).and_return(kind)
|
140
|
-
kind.should_receive(:output_name).and_return(name)
|
141
|
-
test.should_receive(:element).with(name, :error).and_return(element)
|
142
|
-
element.should_receive(:as_file).and_return(filename)
|
143
|
-
|
144
|
-
@processor.error_file(test).should eql(filename)
|
145
|
-
end
|
146
|
-
end
|