testkit123 0.2.7 → 0.3.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
  SHA256:
3
- metadata.gz: 6c71572c20bbe4fe67752af0bf83c7c096e89baa74b177941cfaca9409f2f3fb
4
- data.tar.gz: 72bc398488905987600db9b1f10e6fb9200006d76ecf9002a8594912fe2c781b
3
+ metadata.gz: 78e24b1565f8efab12a23a79131432444dbef249f1b5cb341b2a970485bebe65
4
+ data.tar.gz: 891ecd6e1d304083f3abcb703828e784270bba141a26b743824e4413223e3a52
5
5
  SHA512:
6
- metadata.gz: c264eefc27f45dcd8c25f4553b85dcdb93832fcde33b43914021d362e8b9bbc9d9711ce20201a406595b36e26b9738e3a3f8802d2c4deb448b4612fcf7f7b9d6
7
- data.tar.gz: daeee25fdf8781a1fa6502f1c9b532bf4850cab8e3d0d2186aedfaed5bbf0a56a28e87cca294cd6829f23847b644d1ca5099ff31ec50515e8787fd6b02b45a8c
6
+ metadata.gz: a7f9971e4ccd66cdc623f8667520218f9e795c78d7b7dc599ef14e90fd6cc821ad06f0576396f00c8158d11a6e87ccd02268a4180a9202ed15587ced1703708e
7
+ data.tar.gz: d3d94f0ae845bd38f0ae4f56f9be9b7ea3cee7195918a8c5ebd6224b7ade291a3dfb1e9f67cb792a0ea103eead48e1cc61a660e7a1600db70bc4d10a93a14c7b
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -24,6 +24,8 @@ class TestKit123
24
24
  using StringFormat
25
25
  using ColouredText
26
26
 
27
+ attr_reader :testdata_file
28
+
27
29
  def initialize(templates: {testdata: nil, testx: nil}, project: nil,
28
30
  debug: false, localpath: nil, datapath: nil,
29
31
  gemtest_url: nil, rubyver: 'ruby-2.5.1')
@@ -41,9 +43,49 @@ class TestKit123
41
43
 
42
44
  @localpath, @datapath, @gemtest_url = localpath, datapath, gemtest_url
43
45
  @rubyver = rubyver
46
+
47
+ if File.exists? @project_config then
48
+
49
+ config = SimpleConfig.new(@project_config, debug: false).to_h
50
+ puts ('config: ' + config.inspect).debug if @debug
51
+
52
+ proj = config[:project]
53
+ puts 'create_standalone: proj: ' + proj.inspect if @debug
54
+
55
+ raise 'config[:data_path] not found' unless config[:data_path]
56
+
57
+ datafilepath = config[:data_path] + '/' + proj
58
+ test_rbfile = File.join(datafilepath, "test_#{proj}.rb")
59
+
60
+ ext = (config[:testdata_ext] and config[:testdata_ext][/\.?td$/]) ? 'td' : 'xml'
61
+ @testdata_file = File.join(datafilepath, "testdata_#{proj}.#{ext}")
62
+
63
+ end
44
64
 
45
65
  end
46
66
 
67
+ # expects a test node; see new_testnode()
68
+ #
69
+ def add_test(testnode)
70
+
71
+ s2 , filetype = RXFHelper.read @testdata_file
72
+ puts 'filetype: ' + filetype.inspect if @debug
73
+
74
+ xml = if s2.lstrip[0] == '<' then
75
+ s2
76
+ else
77
+ TestdataText.parse s2
78
+ end
79
+
80
+ puts 'xml: ' + xml.inspect if @debug
81
+
82
+ doc = Rexle.new(xml)
83
+ id = doc.root.xpath('records/test/summary/path/text()').last.to_i + 1
84
+ testnode.root.element('summary/path').text = id.to_s
85
+ doc.root.element('records').add testnode
86
+ return doc
87
+ end
88
+
47
89
  def create_files(project=@project_config)
48
90
 
49
91
  puts 'running create_files ...' if @debug
@@ -138,10 +180,13 @@ end
138
180
 
139
181
  proj = config[:project]
140
182
  puts 'create_standalone: proj: ' + proj.inspect if @debug
183
+
184
+ raise 'config[:data_path] not found' unless config[:data_path]
185
+
141
186
  datafilepath = config[:data_path] + '/' + proj
142
187
  test_rbfile = File.join(datafilepath, "test_#{proj}.rb")
143
188
 
144
- ext = config[:testdata_ext][/\.?td$/] ? 'td' : 'xml'
189
+ ext = (config[:testdata_ext] and config[:testdata_ext][/\.?td$/]) ? 'td' : 'xml'
145
190
  testdata_file = File.join(datafilepath, "testdata_#{proj}.#{ext}")
146
191
  puts 'testdata_file: ' + testdata_file.inspect if @debug
147
192
  puts 'source code filepath: ' + test_rbfile.inspect if @debug
@@ -205,7 +250,7 @@ end
205
250
  puts 'tests[i][1]: ' + tests[i][1].inspect
206
251
  puts 'zip: ' + tests[i][1].zip(input_vars).inspect
207
252
  tests[i][1].zip(input_vars).each do |x|
208
- testcode.gsub!(x[0], 'test_' + x[1])
253
+ testcode.gsub!(/\b#{x[0]}\b/, 'test_' + x[1])
209
254
  end
210
255
 
211
256
  args = testnode.xpath('records/input/summary/*').map do |input|
@@ -262,16 +307,24 @@ end
262
307
 
263
308
  end
264
309
 
265
- def make_testdata(s)
310
+ def new_testnode(s=nil, type: '', inputs: {}, outputs: {result: ''})
311
+
312
+ if s then
313
+
314
+ # the scan is intended to find the input variables from an
315
+ # example Ruby script
316
+
317
+ inputs = s.scan(/test_([\w]+) += +['"]([^'"]+)/)\
318
+ .inject({}){|r,x| r.merge(x.first.to_sym => x.last)}
319
+ end
266
320
 
267
- inputs = s.scan(/test_([\w]+) += +['"]([^'"]+)/)\
268
- .inject({}){|r,x| r.merge(x.first.to_sym => x.last)}
321
+ # observe *test* is masked with *_test* because it is a built-in method name.
269
322
 
270
323
  h = {
271
324
  _test: {
272
325
  summary: {
273
326
  path: '',
274
- type: '',
327
+ type: type,
275
328
  description: ''
276
329
  },
277
330
  records: {
@@ -280,7 +333,7 @@ end
280
333
  records: {}
281
334
  },
282
335
  output: {
283
- summary: {result: ''},
336
+ summary: outputs,
284
337
  records: {}
285
338
  }
286
339
  }
@@ -289,7 +342,7 @@ end
289
342
 
290
343
  a = RexleBuilder.new(h, debug: false).to_a
291
344
 
292
- Rexle.new(a).xml pretty: true
345
+ Rexle.new(a)
293
346
 
294
347
  end
295
348
 
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.7
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  owBtF8qd/v9x+t6h+/j/LPTmgwDrPhKl4HmH77oloyec9426T3EW7OvcMiMXAfQG
36
36
  KKJn9TVnRGoWZTIHtu1e5v36
37
37
  -----END CERTIFICATE-----
38
- date: 2019-10-07 00:00:00.000000000 Z
38
+ date: 2020-09-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rxfhelper
@@ -43,40 +43,40 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.9'
46
+ version: '1.0'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.9.1
49
+ version: 1.0.5
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '0.9'
56
+ version: '1.0'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.9.1
59
+ version: 1.0.5
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: simple-config
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '0.6'
66
+ version: '0.7'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.6.4
69
+ version: 0.7.1
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.6'
76
+ version: '0.7'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 0.6.4
79
+ version: 0.7.1
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: testdata_text
82
82
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file