testdata 1.1.10 → 1.1.13

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
  SHA256:
3
- metadata.gz: 538ee4e9da6112785d2a5adb42574122aac61b61132b737b8a514acaad5978e9
4
- data.tar.gz: 335a22cee75aa3760bd10dbf3bb3d814aafbe320f0bd4f7f1b721136743b26d6
3
+ metadata.gz: 5a3d6471fcd0124a4c7dccd09604348ed9b0f95097e5c445b3fcdec6e168d9e6
4
+ data.tar.gz: c76b3fe53e3d0324c4adec135d6a7b25861a1f0af3ebbcb9818696610d1eabe7
5
5
  SHA512:
6
- metadata.gz: 5b4ead3de090642fc503b1d1a076e2632678962adf4f3a0f0e972c7b33c10965f4de040c1d9c65cf3ae54a0e194c7f557cd9a27dada6d069744f1ea6956469d4
7
- data.tar.gz: e6784581fdfcfe104897f800d1866ed10375cc9425408a20d7eed146ea1775a301a558a803b229b267c5fc689367dc3ad9fe6c198a04fd5f90fa462bf462727f
6
+ metadata.gz: 98c83b30dee58b34f7a9886e66f54e7c7afaa41e3addeb1ad87fa6665d3c7cbc6ad038d04aa7cd1957e21b90f7b05e515b4c8b4cfdfcd75156d6da6d275bd1af
7
+ data.tar.gz: 9014b80ef725ac1984bd6f2678717d5ea3c74b2f8de5d914ae4e3bd6d4c79206cdc71572e363ffe7f601dd3488184f0626e3d523e85282440106369c031ccd28
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/testdata.rb CHANGED
@@ -7,14 +7,16 @@ require 'testdata_text'
7
7
  require 'diffyc32'
8
8
  require 'polyrex'
9
9
  require 'yaml'
10
+ require 'rxfreader'
10
11
 
11
12
 
12
13
  class TestdataException < Exception
13
14
  end
14
15
 
15
16
  module Testdata
16
-
17
+
17
18
  class Base
19
+ include RXFRead
18
20
  using ColouredText
19
21
 
20
22
  include AppRoutes
@@ -22,7 +24,7 @@ module Testdata
22
24
  attr_accessor :debug
23
25
 
24
26
  def initialize(s, options={})
25
-
27
+
26
28
  super()
27
29
 
28
30
  @params = {}
@@ -33,14 +35,14 @@ module Testdata
33
35
  # open the testdata document
34
36
  procs = {
35
37
  String: proc {|x|
36
-
38
+
37
39
  if x.strip[/^</] then
38
40
  x
39
41
  elsif x[/https?:\/\//] then
40
42
  read_url x
41
43
  else
42
44
  read_file x
43
- end
45
+ end
44
46
  },
45
47
  Polyrex: proc {|x| x.to_xml}
46
48
  }
@@ -48,26 +50,28 @@ module Testdata
48
50
  buffer = procs[s.class.to_s.to_sym].call(s)
49
51
 
50
52
  @doc = Rexle.new(buffer)
51
-
53
+
52
54
  o = {log: false}.merge(options)
53
55
 
54
56
  @log = o[:log] == true ? Rexle.new(tests) : nil
57
+
58
+
55
59
  end
56
60
 
57
- def run(raw_x=nil, debug2=nil)
58
-
61
+ def run(raw_x=nil, debug2=nil, results_file: nil)
62
+
59
63
  # verify the document has unique path numbers
60
-
64
+
61
65
  a = @doc.root.xpath('records/test/summary/path/text()')
62
66
  duplicates = a.select{ |e| a.count(e) > 1 }.uniq
63
-
67
+
64
68
  if duplicates.any? then
65
- raise 'Duplicate path found. Path: ' + duplicates.inspect
69
+ raise 'Duplicate path found. Path: ' + duplicates.inspect
66
70
  end
67
71
 
68
72
  @debug2 = debug2 ? true : false
69
73
  @success = []
70
-
74
+
71
75
  x = if raw_x and raw_x[/\d+\.\.\d+/] then
72
76
  x, y = raw_x.split('..').map(&:to_i)
73
77
  id = Range.new(x,y)
@@ -75,15 +79,16 @@ module Testdata
75
79
  raw_x
76
80
  end
77
81
 
78
- procs = {NilClass: :test_all, Range: :test_range, String: :test_id,
82
+ procs = {NilClass: :test_all, Range: :test_range, String: :test_id,
79
83
  Integer: :test_id, Fixnum: :test_id}
80
84
 
81
85
  method(procs[x.class.to_s.to_sym]).call(x)
86
+ @results_file = results_file if raw_x.nil? and results_file
82
87
  summary()
83
88
  end
84
-
89
+
85
90
  private
86
-
91
+
87
92
  def testdata_values(id)
88
93
 
89
94
  node = @doc.root.element "records/test[summary/path='#{id}']"
@@ -91,7 +96,7 @@ module Testdata
91
96
 
92
97
  path_no = node.text('summary/path')
93
98
 
94
- input_summary = node.element 'records/input/summary'
99
+ input_summary = node.element 'records/input/summary'
95
100
  input_summary.delete 'schema | format_mask | recordx_type'
96
101
 
97
102
  input_nodes = input_summary.xpath('*') #[1..-1]
@@ -105,8 +110,8 @@ module Testdata
105
110
 
106
111
  type, desc = summary.text('type'), summary.text('description')
107
112
 
108
- output_summary = node.element 'records/output/summary'
109
- output_summary.delete 'schema | format_mask | recordx_type'
113
+ output_summary = node.element 'records/output/summary'
114
+ output_summary.delete 'schema | format_mask | recordx_type'
110
115
 
111
116
  output_nodes = output_summary.xpath('*') #[1..-1]
112
117
  output_values = output_nodes.map{|x| x.texts.map(&:unescape).join.strip}
@@ -119,32 +124,32 @@ module Testdata
119
124
  x ||=(0..-1)
120
125
 
121
126
  break_on_fail = @doc.root.element('summary/break_on_fail/text()') == 'true'
122
-
127
+
123
128
  test_id = nil
124
129
 
125
130
  begin
126
-
131
+
127
132
  @doc.root.xpath("records/test/summary/path/text()")[x].each do |id|
128
-
133
+
129
134
  test_id = id
130
135
  puts 'testing id: ' + id.inspect
131
136
  result = test_id(id)
132
- break if result == false and break_on_fail
133
-
137
+ break if result == false and break_on_fail
138
+
134
139
  end
135
-
140
+
136
141
  rescue
137
142
 
138
143
  @success << [false, test_id.to_i]
139
144
  end
140
-
145
+
141
146
 
142
147
  end
143
148
 
144
149
  def test_id(id='')
145
150
 
146
151
 
147
- path_no, inputs, input_names, type, expected, @desc =
152
+ path_no, inputs, input_names, type, expected, @desc =
148
153
  testdata_values(id.to_s)
149
154
  @inputs = inputs
150
155
 
@@ -154,7 +159,7 @@ module Testdata
154
159
  puts "warning: no test route found for " + type unless raw_actual
155
160
 
156
161
  result = nil
157
- @success << [nil, path_no.to_i]
162
+ @success << [nil, path_no.to_i]
158
163
 
159
164
  begin
160
165
 
@@ -164,7 +169,7 @@ module Testdata
164
169
  b = expected.map(&:strip)
165
170
 
166
171
  if @debug == true or @debug2 == true then
167
-
172
+
168
173
  inputs = input_names.zip(inputs).map{|x| ' ' + x.join(": ")}\
169
174
  .join("\n")
170
175
 
@@ -176,18 +181,18 @@ module Testdata
176
181
 
177
182
  result = a.join.force_encoding("UTF-8") == \
178
183
  b.join.force_encoding("UTF-8")
179
-
184
+
180
185
  if (@debug == true or @debug2 == true) and result == false then
181
186
 
182
187
  # diff the expected and actual valuess
183
188
  puts DiffyC32.new(b.first, a.first).to_s
184
-
189
+
185
190
  end
186
191
  else
187
192
  result = [raw_actual].compact == expected
188
193
  end
189
194
 
190
- rescue Exception => e
195
+ rescue Exception => e
191
196
  err_label = e.message + " :: \n" + e.backtrace.join("\n")
192
197
  raise TestdataException, err_label
193
198
  result = false
@@ -198,15 +203,15 @@ module Testdata
198
203
  end
199
204
 
200
205
  def test_range(range)
201
-
206
+
202
207
  a = @doc.root.xpath("records/test/summary/path/text()")
203
208
  a[range].each {|x| test_id x}
204
209
  end
205
-
210
+
206
211
  def tests(*args)
207
212
  # override this method in the child class
208
213
  end
209
-
214
+
210
215
  def read_rdx(buffer)
211
216
  puts 'inside read_rdf: buffer: ' + buffer.inspect
212
217
  dx = Dynarex.new
@@ -232,7 +237,7 @@ module Testdata
232
237
  dx.all.each.with_index do |x, i|
233
238
 
234
239
  px.create.test(path: (i+1).to_s, type: dx.test_type) do |create|
235
-
240
+
236
241
  raw_inputs.each do |fld_in|
237
242
 
238
243
  create.input(fld_in[0..-4].to_sym => \
@@ -248,17 +253,17 @@ module Testdata
248
253
  end
249
254
 
250
255
  px.to_xml
251
-
256
+
252
257
  end
253
258
 
254
- def read_file(s)
255
- buffer = File.open(s, 'r').read
259
+ def read_file(s)
260
+ buffer = FileX.read(s)
256
261
  ext = s[/\.(\w+)$/,1]
257
- method(('read_' + ext).to_sym).call(buffer)
262
+ method(('read_' + ext).to_sym).call(buffer)
258
263
  end
259
-
264
+
260
265
  def read_url(url)
261
- buffer = open(url, 'UserAgent' => 'Testdata').read
266
+ buffer = URI.open(url, 'UserAgent' => 'Testdata').read
262
267
  ext = url[/.*\/[^\.]+\.(\w+)/,1]
263
268
  method(('read_' + ext).to_sym).call(buffer)
264
269
  end
@@ -266,7 +271,7 @@ module Testdata
266
271
  def read_xml(buffer)
267
272
  buffer
268
273
  end
269
-
274
+
270
275
  def read_td(buffer)
271
276
  puts 'buffer: ' + buffer
272
277
  TestdataText.parse buffer
@@ -278,6 +283,7 @@ module Testdata
278
283
  end
279
284
 
280
285
  def summary()
286
+
281
287
  success = @success.map(&:first)
282
288
  a = @success.map(&:last).sort
283
289
  h = {
@@ -285,73 +291,93 @@ module Testdata
285
291
  score: [success.grep(true), success].map(&:length).join('/'),
286
292
  failed: @success.select{|x| x[0] == false}.map(&:last).sort
287
293
  }
288
-
294
+
289
295
  def h.to_s()
290
296
  passed = self[:passed] ? self[:passed].to_s.light_green : self[:passed].to_s.light_red
291
- "{passed: #{passed}, score: #{self[:score]}, failed: #{self[:failed]}}"
292
-
297
+ "{passed: #{passed}, score: #{self[:score]}, failed: #{self[:failed]}}"
298
+
293
299
  end
294
-
295
- h
300
+
301
+ if @results_file then
302
+
303
+ dx = if FileX.exists?(@results_file) then
304
+ Dynarex.new @results_file
305
+ else
306
+ Dynarex.new schema: "gems/gemx(title, last_tested, passed, score)",
307
+ filepath: @results_file
308
+ end
309
+
310
+ title = @doc.root.element('summary/title/text()')
311
+ h2 = {title: title, last_tested: Time.now.to_s, passed: h[:passed].to_s, score: h[:score]}
312
+
313
+ dx.create(h2)
314
+ dx.save
315
+ puts 'results file saved at ' + @results_file.inspect if @debug
316
+
317
+ #puts dx.all.first
318
+
319
+ end
320
+
321
+ return h
296
322
  end
297
323
  end
298
324
 
299
325
  class Unit
300
-
326
+
301
327
  attr_reader :to_s
302
328
 
303
329
  def initialize(s)
304
-
330
+
305
331
  super()
306
332
  @a = []
307
-
308
- buffer, _ = RXFHelper.read(s)
333
+
334
+ buffer, _ = RXFReader.read(s)
309
335
 
310
336
  @doc = Rexle.new(buffer)
311
337
 
312
338
  @doc.root.xpath('records/test').map do |test|
313
-
314
- path, type, description = test.xpath('summary/*/text()')
315
- records = test.element('records')
316
-
339
+
340
+ path, type, description = test.xpath('summary/*/text()')
341
+ records = test.element('records')
342
+
317
343
  inputs = records.xpath('input/summary/*').map\
318
344
  {|x| [x.name, x.texts.join.strip]}
319
345
 
320
346
  outputs = records.xpath('output/summary/*').map\
321
347
  {|x| [x.name, x.texts.join.strip]}
322
-
348
+
323
349
  @a << {type: type, in: inputs, out: outputs}
324
-
350
+
325
351
  end
326
-
352
+
327
353
  end # end of initialize()
328
-
354
+
329
355
  def to_s()
330
356
  =begin
331
357
  s = %Q(
332
358
  require_relative "#{testgem}"
333
359
  require "test/unit"
334
-
360
+
335
361
  class #{testclass} < Test::Unit::TestCase
336
-
362
+
337
363
  def #{types[i]}
338
364
  #{@lines.join("\n ")}
339
365
  end
340
-
366
+
341
367
  end
342
368
  )
343
369
  =end
344
370
  #read the .rsf file
345
371
  script = @doc.root.element('summary/script/text()')
346
372
  raise 'script XML entry not found' unless script
347
-
373
+
348
374
  if script then
349
- filename = script[/[\/]+\.rsf$/]
350
- buffer, _ = RXFHelper.read(filename)
375
+ filename = script[/[\/]+\.rsf$/]
376
+ buffer, _ = RXFReader.read(filename)
351
377
  end
352
378
  #@a.group_by {|x| x[:type]}
353
-
354
-
379
+
380
+
355
381
  end
356
382
  end
357
383
  end
data.tar.gz.sig CHANGED
Binary file
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: 1.1.10
4
+ version: 1.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb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/hbzh/xzCuRatkvUkAHmtW1StGSbPn0Hoam6hwWp+NuuUfEU
33
- tA2AMgGW5/Ft/vBLFyCfMr/9x6QJEW3VtfwqL8zie4jp2sVCrW1gdotA3+4XdaEF
34
- fUI/y8o+W/4oN7aCyhUzCXTSlGzwEHLqqCYX3DFerUd+mdQhSNLYAQuJtj/4zoNc
35
- U1Tt/KPr9FeWlvj5ihis4H6UPWZxY2G9k94y2W7ylWkcKNXR8i45F+nCzDL3W0Ll
36
- Vt/9GDfEI95Jg3QNvXMDdzNf
28
+ BgkqhkiG9w0BAQsFAAOCAYEAH6QBlgGKUFJ0jpVgoi+xAQWMgkxZJbx545Ydhjkd
29
+ 9pK0QbiF831LkB/Fax2FYyySgcqtU9aVHY4TwXWZFvhf7MnZM0YnU+2GA367ZkkH
30
+ HFX88FqBnbVEiYeWbNyhH+Dp/EuoNPwoJKUHOnIjey2bQttpnAr0nl+rNn6DRDBd
31
+ SrOX6yrJp+TKxmtlJhmcE1G3dNSQYRZOBH/0DtDTQiHU2tiOHW57+5NZmEi/uZMW
32
+ /cfpafSJ1tENFWQJ1pATQoaJh/6LKnoDWkhrVwSuRJtD8qpOS/wjKqqscZlxS9m/
33
+ +61VC+IRSjjSHUZUzBHmRsONgYITuw8psX60aEc4oi4SOJuQLunsARvYDY+NO5S0
34
+ q8Xb225jZx4fdmDXd/EiMLn3hjva85JsJVfrE7eS0dPhZTNv36auPeHGMUEBDKmz
35
+ VPCX5Cuw6OER1XAXBrbU+Yxtynmu52uURikgRGv3kNN7uFNP2ObtG4bePdjcyRyF
36
+ ZoODyxvFiUzKN1ar4bIjsI+l
37
37
  -----END CERTIFICATE-----
38
- date: 2020-09-18 00:00:00.000000000 Z
38
+ date: 2022-02-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: app-routes
@@ -106,7 +106,7 @@ dependencies:
106
106
  version: '1.3'
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 1.3.1
109
+ version: 1.3.6
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
@@ -116,9 +116,9 @@ dependencies:
116
116
  version: '1.3'
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 1.3.1
119
+ version: 1.3.6
120
120
  description:
121
- email: james@jamesrobertson.eu
121
+ email: digital.robertson@gmail.com
122
122
  executables: []
123
123
  extensions: []
124
124
  extra_rdoc_files: []
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.0.3
146
+ rubygems_version: 3.2.22
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: A test framework which accepts test data in a Polyrex format.
metadata.gz.sig CHANGED
Binary file