testdata 0.3.1 → 0.3.2
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/testdata.rb +32 -10
- metadata +2 -2
data/lib/testdata.rb
CHANGED
@@ -22,8 +22,13 @@ class Path
|
|
22
22
|
output_values = XPath.match(node, "records/io/summary[type='output']/*").map(&stringify)
|
23
23
|
|
24
24
|
path_no = node.text('summary/path')
|
25
|
-
actual = XPath.first(@log.root, "records/result[path_no='#{path_no}']/actual") if @log
|
26
25
|
|
26
|
+
if @log then
|
27
|
+
node_result = XPath.first(@log.root, "records/result[path_no='#{path_no}']")
|
28
|
+
actual = XPath.first(node_result, "actual")
|
29
|
+
end
|
30
|
+
|
31
|
+
puts 'path_no : ' + path_no
|
27
32
|
|
28
33
|
result = nil
|
29
34
|
@success << [nil, path_no.to_i]
|
@@ -40,17 +45,22 @@ class Path
|
|
40
45
|
if raw_result then
|
41
46
|
a = [raw_result].flatten.map(&:strip)
|
42
47
|
b = expected.map(&:strip)
|
48
|
+
|
49
|
+
# actual.text is used by the log file
|
43
50
|
actual.text = a.join("\n")[/</] ? CData.new("\n%s\n" % a.join("\n")) : a.join("\n") if @log
|
44
51
|
|
45
|
-
#
|
46
|
-
#
|
52
|
+
#puts 'a : ' + a.inspect + ' : ' + a[0].length.to_s
|
53
|
+
#puts 'b : ' + b.inspect + ' b :' + b[0].length.to_s
|
54
|
+
|
47
55
|
result = a == b
|
48
56
|
else
|
49
57
|
result = [raw_result].compact == expected
|
50
58
|
end
|
51
59
|
|
52
60
|
rescue
|
53
|
-
|
61
|
+
err_label = 'error: ' + ($!).to_s
|
62
|
+
puts err_label
|
63
|
+
XPath.first(node_result, "error").text = err_label
|
54
64
|
result = false
|
55
65
|
ensure
|
56
66
|
@success[-1][0] = result
|
@@ -107,7 +117,8 @@ class Testdata
|
|
107
117
|
|
108
118
|
def tests()
|
109
119
|
script = XPath.first(@doc.root, "summary/script/text()").to_s
|
110
|
-
|
120
|
+
file_path = File.exists?(script) ? script : @filepath + '/' + script
|
121
|
+
s = File.open(file_path,'r').read
|
111
122
|
|
112
123
|
stringify = Proc.new {|x| x.text.to_s.gsub(/[\n\s]/,'').length > 0 ? x.text : x.cdatas.join.strip}
|
113
124
|
|
@@ -138,6 +149,7 @@ class Testdata
|
|
138
149
|
body.gsub!(/#{keyword}(?!:)/, "'%s'" % value )
|
139
150
|
end
|
140
151
|
end
|
152
|
+
#puts 'xxxxx : ' + body.to_s
|
141
153
|
[path_no, content[i][0], body, output]
|
142
154
|
end
|
143
155
|
|
@@ -157,20 +169,30 @@ class Testdata
|
|
157
169
|
xml.schema 'results/result(path_no, title, test, expected, actual)'
|
158
170
|
end
|
159
171
|
xml.records do
|
160
|
-
tests.each do |path_no, title,
|
172
|
+
tests.each do |path_no, title, testx, expected|
|
173
|
+
|
161
174
|
xml.result do
|
162
175
|
xml.path_no path_no
|
163
176
|
xml.title title
|
164
177
|
|
165
|
-
|
166
|
-
|
178
|
+
if testx[/[<>]/] then
|
179
|
+
xml.testx do
|
180
|
+
xml.cdata!("\n%s\n" % testx)
|
181
|
+
end
|
182
|
+
else
|
183
|
+
xml.testx testx
|
167
184
|
end
|
168
185
|
|
169
|
-
|
170
|
-
|
186
|
+
if expected[/</] then
|
187
|
+
xml.expected do
|
188
|
+
xml.cdata!("\n%s\n" % expected)
|
189
|
+
end
|
190
|
+
else
|
191
|
+
xml.expected expected
|
171
192
|
end
|
172
193
|
|
173
194
|
xml.actual
|
195
|
+
xml.error
|
174
196
|
end
|
175
197
|
end
|
176
198
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testdata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2011-01-
|
12
|
+
date: 2011-01-27 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|