testkit123 0.2.4 → 0.2.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f614e8e95327241b534bbf266dad46525c6cd71adbedf8ca8044527cc9882a62
4
- data.tar.gz: 0777ac2e0d3c01b7d4a6238a428be34496f2cb3910f5bcb86075af1f37329325
3
+ metadata.gz: 7b69d7193e9f8255f026689f71a93794fa710adf05c2cce1992a1003d92a8886
4
+ data.tar.gz: 1386ccfd90a285cba41135fe003846d43ab1cb894e4856c2e5d481f245dc2c02
5
5
  SHA512:
6
- metadata.gz: c36ff119e0864242544c179d34a2674524873b2458a65b43384018a46bff12ea9f9ed8579fa76b31a22e1723656a38d23ecea3bb001ccf160ec70b3191e1eb54
7
- data.tar.gz: 5596f0154676cb0893ad1db11bf20a35430ec566e5abd4f77f6208cce7af4f7d3ded1cff57848e55469a3d033669a2f1a2870a2124fda5b8e3277380328b20bc
6
+ metadata.gz: 2b9aa7567633aaf7104624da65dea865d4ed10a5936c1f824c474e8dd8e5e8b596673cd75e8947ed0fada4904bb505215f65a5af8979b15b2001e561da3bb12a
7
+ data.tar.gz: f95045d7b9381c9b8fa6b96fd17e3eb511c8e1bcda6414e385c876e999b24821865e6701be264954d02caa8d630c8f4dc5ee5abe00e69c65f4470bcc9f472dfb
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -135,12 +135,14 @@ end
135
135
  ext = config[:testdata_ext][/\.?td$/] ? 'td' : 'xml'
136
136
  testdata_file = File.join(datafilepath, "testdata_#{proj}.#{ext}")
137
137
  puts 'testdata_file: ' + testdata_file.inspect if @debug
138
+ puts 'source code filepath: ' + test_rbfile.inspect if @debug
138
139
 
139
140
  s = File.read(test_rbfile).gsub(/^( )?end/,'')
140
141
  require_gems = s.scan(/^require +['"]([^'"]+)/).map(&:first)
141
142
 
142
- before_test = s[/(?<=def tests\(\)).*(?=\n test )/m].lstrip
143
-
143
+ before_test = s[/(?<=def tests\(\)).*/m].split(/ test /)[0].lstrip
144
+ puts '** before_test: ' + before_test.inspect
145
+
144
146
  a = s.split(/(?= test )/)
145
147
  a.shift
146
148
 
@@ -162,13 +164,36 @@ end
162
164
  puts 'xml: ' + xml.inspect if @debug
163
165
 
164
166
  doc = Rexle.new(xml)
165
- testnode = doc.root.xpath('records//test')[n-1]
167
+ puts 'after doc : ' if @debug
168
+ r = doc.root.xpath('records//test') || doc.root.xpath('records/test')
169
+
170
+ if @debug then
171
+ puts 'r: ' + r.inspect
172
+ puts 'r.length: ' + r.length.inspect
173
+ puts 'n: ' + n.inspect
174
+ end
175
+
176
+ testnode = r[n-1]
177
+ puts 'testnode: ' + testnode.xml.inspect if @debug
178
+
166
179
  title = testnode.text('summary/type')
167
180
  i = tests.index tests.assoc(title)
168
-
181
+
169
182
  testcode = a[i].strip.lines[1..-2].map do |line|
170
183
  line.sub(/^ {6}/,'')
171
184
  end.join
185
+
186
+ # replace the input variable names with the input variable names defined
187
+ # in the testdata file and prefix them with *test_*.
188
+
189
+ input_vars = testnode.xpath('records/input/summary/*/name()')
190
+
191
+ puts 'input_vars: ' + input_vars.inspect
192
+ puts 'tests[i][1]: ' + tests[i][1].inspect
193
+ puts 'zip: ' + tests[i][1].zip(input_vars).inspect
194
+ tests[i][1].zip(input_vars).each do |x|
195
+ testcode.gsub!(x[0], 'test_' + x[1])
196
+ end
172
197
 
173
198
  args = testnode.xpath('records/input/summary/*').map do |input|
174
199
  "test_%s =<<EOF\n%s\nEOF\n" % [input.name,
@@ -185,12 +210,15 @@ end
185
210
 
186
211
  puts 'gems: ' + require_gems.inspect if @debug
187
212
 
213
+ codex = testcode.rstrip.lines
214
+
188
215
  "# Test %d. Type: %s\n# Description: %s\n" \
189
216
  % [n, title, testnode.text('summary/type')] + \
190
217
  "# --------------------------------------------\n\n" + \
191
218
  "require '#{proj}'\n" + require_gems.map {|x| "require '%s'" \
192
219
  % x}.join("\n") + "\n\n\n" \
193
- + before_test.gsub(/^ /,'') + "\n" + args.join("\n") + testcode
220
+ + before_test.gsub(/^ /,'') + "\n" + args.join("\n") \
221
+ + codex[0..-2].join + 'puts ' + codex.last
194
222
 
195
223
  end
196
224
 
@@ -290,3 +318,4 @@ EOF
290
318
  end
291
319
 
292
320
  end
321
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testkit123
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file