testkit123 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/testkit123.rb +123 -23
- metadata +35 -31
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78e24b1565f8efab12a23a79131432444dbef249f1b5cb341b2a970485bebe65
|
4
|
+
data.tar.gz: 891ecd6e1d304083f3abcb703828e784270bba141a26b743824e4413223e3a52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7f9971e4ccd66cdc623f8667520218f9e795c78d7b7dc599ef14e90fd6cc821ad06f0576396f00c8158d11a6e87ccd02268a4180a9202ed15587ced1703708e
|
7
|
+
data.tar.gz: d3d94f0ae845bd38f0ae4f56f9be9b7ea3cee7195918a8c5ebd6224b7ade291a3dfb1e9f67cb792a0ea103eead48e1cc61a660e7a1600db70bc4d10a93a14c7b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/testkit123.rb
CHANGED
@@ -8,18 +8,29 @@ require 'testdata_text'
|
|
8
8
|
require 'simple-config'
|
9
9
|
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
module StringFormat
|
12
|
+
|
13
|
+
refine String do
|
14
|
+
|
15
|
+
def camelize
|
16
|
+
self.split('_').collect(&:capitalize).join
|
17
|
+
end
|
18
|
+
|
14
19
|
end
|
20
|
+
|
15
21
|
end
|
16
22
|
|
17
23
|
class TestKit123
|
18
|
-
|
24
|
+
using StringFormat
|
25
|
+
using ColouredText
|
26
|
+
|
27
|
+
attr_reader :testdata_file
|
28
|
+
|
19
29
|
def initialize(templates: {testdata: nil, testx: nil}, project: nil,
|
20
30
|
debug: false, localpath: nil, datapath: nil,
|
21
31
|
gemtest_url: nil, rubyver: 'ruby-2.5.1')
|
22
32
|
|
33
|
+
@debug = debug
|
23
34
|
@h = templates
|
24
35
|
|
25
36
|
@project_config = if project =~ /\.txt$/ then
|
@@ -27,13 +38,54 @@ class TestKit123
|
|
27
38
|
elsif project
|
28
39
|
File.join(localpath, project + '.txt')
|
29
40
|
end
|
41
|
+
puts '@project_config: ' + @project_config.inspect if @debug
|
30
42
|
|
31
|
-
|
43
|
+
|
32
44
|
@localpath, @datapath, @gemtest_url = localpath, datapath, gemtest_url
|
33
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
|
34
64
|
|
35
65
|
end
|
36
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
|
+
|
37
89
|
def create_files(project=@project_config)
|
38
90
|
|
39
91
|
puts 'running create_files ...' if @debug
|
@@ -123,24 +175,34 @@ end
|
|
123
175
|
|
124
176
|
# use the test number to find the test to copy from the test file
|
125
177
|
|
126
|
-
config = SimpleConfig.new(@project_config).to_h
|
178
|
+
config = SimpleConfig.new(@project_config, debug: false).to_h
|
179
|
+
puts ('config: ' + config.inspect).debug if @debug
|
127
180
|
|
128
181
|
proj = config[:project]
|
182
|
+
puts 'create_standalone: proj: ' + proj.inspect if @debug
|
183
|
+
|
184
|
+
raise 'config[:data_path] not found' unless config[:data_path]
|
185
|
+
|
129
186
|
datafilepath = config[:data_path] + '/' + proj
|
130
187
|
test_rbfile = File.join(datafilepath, "test_#{proj}.rb")
|
131
188
|
|
132
|
-
ext = config[:testdata_ext][/\.?td$/] ? 'td' : 'xml'
|
189
|
+
ext = (config[:testdata_ext] and config[:testdata_ext][/\.?td$/]) ? 'td' : 'xml'
|
133
190
|
testdata_file = File.join(datafilepath, "testdata_#{proj}.#{ext}")
|
134
191
|
puts 'testdata_file: ' + testdata_file.inspect if @debug
|
192
|
+
puts 'source code filepath: ' + test_rbfile.inspect if @debug
|
135
193
|
|
136
|
-
s = File.read
|
194
|
+
s = File.read(test_rbfile).gsub(/^( )?end/,'')
|
137
195
|
require_gems = s.scan(/^require +['"]([^'"]+)/).map(&:first)
|
138
|
-
|
196
|
+
|
197
|
+
before_test = s[/(?<=def tests\(\)).*/m].split(/ test /)[0].lstrip
|
198
|
+
puts '** before_test: ' + before_test.inspect
|
199
|
+
|
139
200
|
a = s.split(/(?= test )/)
|
140
201
|
a.shift
|
141
|
-
|
202
|
+
puts 'a: ' + a.inspect if @debug
|
203
|
+
|
142
204
|
tests = a.map do |x|
|
143
|
-
r =
|
205
|
+
r = x.match(/(?<=['"])(?<test>[^"']+)['"]\s+do\s+\|(?<raw_args>[^\|]+)/)
|
144
206
|
|
145
207
|
[r[:test], r[:raw_args].split(/, */)]
|
146
208
|
end
|
@@ -157,16 +219,43 @@ end
|
|
157
219
|
puts 'xml: ' + xml.inspect if @debug
|
158
220
|
|
159
221
|
doc = Rexle.new(xml)
|
160
|
-
|
222
|
+
puts 'after doc : ' if @debug
|
223
|
+
r = doc.root.xpath('records//test') || doc.root.xpath('records/test')
|
224
|
+
|
225
|
+
if @debug then
|
226
|
+
puts 'r: ' + r.inspect
|
227
|
+
puts 'r.length: ' + r.length.inspect
|
228
|
+
puts 'n: ' + n.inspect
|
229
|
+
end
|
230
|
+
|
231
|
+
testnode = r[n-1]
|
232
|
+
puts 'testnode: ' + testnode.xml.inspect if @debug
|
233
|
+
|
161
234
|
title = testnode.text('summary/type')
|
235
|
+
puts ('title: ' + title.inspect).debug if @debug
|
236
|
+
puts ('tests: ' + tests.inspect).debug if @debug
|
162
237
|
i = tests.index tests.assoc(title)
|
163
|
-
|
238
|
+
puts 'i: ' + i.inspect if @debug
|
239
|
+
|
164
240
|
testcode = a[i].strip.lines[1..-2].map do |line|
|
165
241
|
line.sub(/^ {6}/,'')
|
166
242
|
end.join
|
243
|
+
|
244
|
+
# replace the input variable names with the input variable names defined
|
245
|
+
# in the testdata file and prefix them with *test_*.
|
246
|
+
|
247
|
+
input_vars = testnode.xpath('records/input/summary/*/name()')
|
248
|
+
|
249
|
+
puts 'input_vars: ' + input_vars.inspect
|
250
|
+
puts 'tests[i][1]: ' + tests[i][1].inspect
|
251
|
+
puts 'zip: ' + tests[i][1].zip(input_vars).inspect
|
252
|
+
tests[i][1].zip(input_vars).each do |x|
|
253
|
+
testcode.gsub!(/\b#{x[0]}\b/, 'test_' + x[1])
|
254
|
+
end
|
167
255
|
|
168
256
|
args = testnode.xpath('records/input/summary/*').map do |input|
|
169
|
-
"test_%s
|
257
|
+
"test_%s =<<EOF\n%s\nEOF\n" % [input.name,
|
258
|
+
input.texts.join.gsub(/'/,"\'").strip]
|
170
259
|
end
|
171
260
|
|
172
261
|
vars = testnode.xpath('records/input/summary/*').map(&:name)
|
@@ -179,12 +268,15 @@ end
|
|
179
268
|
|
180
269
|
puts 'gems: ' + require_gems.inspect if @debug
|
181
270
|
|
271
|
+
codex = testcode.rstrip.lines
|
272
|
+
|
182
273
|
"# Test %d. Type: %s\n# Description: %s\n" \
|
183
274
|
% [n, title, testnode.text('summary/type')] + \
|
184
|
-
"#
|
275
|
+
"# --------------------------------------------\n\n" + \
|
185
276
|
"require '#{proj}'\n" + require_gems.map {|x| "require '%s'" \
|
186
277
|
% x}.join("\n") + "\n\n\n" \
|
187
|
-
+ args.join("\n")
|
278
|
+
+ before_test.gsub(/^ /,'') + "\n" + args.join("\n") \
|
279
|
+
+ codex[0..-2].join + 'puts ' + codex.last
|
188
280
|
|
189
281
|
end
|
190
282
|
|
@@ -215,16 +307,24 @@ end
|
|
215
307
|
|
216
308
|
end
|
217
309
|
|
218
|
-
def
|
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
|
219
320
|
|
220
|
-
|
221
|
-
.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.
|
222
322
|
|
223
323
|
h = {
|
224
324
|
_test: {
|
225
325
|
summary: {
|
226
326
|
path: '',
|
227
|
-
type:
|
327
|
+
type: type,
|
228
328
|
description: ''
|
229
329
|
},
|
230
330
|
records: {
|
@@ -233,16 +333,16 @@ end
|
|
233
333
|
records: {}
|
234
334
|
},
|
235
335
|
output: {
|
236
|
-
summary:
|
336
|
+
summary: outputs,
|
237
337
|
records: {}
|
238
338
|
}
|
239
339
|
}
|
240
340
|
}
|
241
341
|
}
|
242
342
|
|
243
|
-
a = RexleBuilder.new(h).to_a
|
343
|
+
a = RexleBuilder.new(h, debug: false).to_a
|
244
344
|
|
245
|
-
Rexle.new(a)
|
345
|
+
Rexle.new(a)
|
246
346
|
|
247
347
|
end
|
248
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,27 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkxMDA3MDk0NDMwWhcN
|
15
|
+
MjAxMDA2MDk0NDMwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDKZj/1
|
17
|
+
lg4PZhpHglK40avWXxaa6Kdmfd1VbYufjc8fAs5gyWJoOj7Sd0YSqHvBrJXngysg
|
18
|
+
eaWEw7q/6qeKTlOdESJPxDz9e7Aj6AV0DfblQciMQWGMIbdYKDgUQKlY1WHPZBeh
|
19
|
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mQXPqhUbwsOnJZM0s8m
|
34
|
+
mwmSZbk2b0bMllDLaDYMoUkkwRzBxEkKe6DMuC1q7/9lekcCdm2+1teA4j/l82cM
|
35
|
+
owBtF8qd/v9x+t6h+/j/LPTmgwDrPhKl4HmH77oloyec9426T3EW7OvcMiMXAfQG
|
36
|
+
KKJn9TVnRGoWZTIHtu1e5v36
|
32
37
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
38
|
+
date: 2020-09-06 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: rxfhelper
|
@@ -38,40 +43,40 @@ dependencies:
|
|
38
43
|
requirements:
|
39
44
|
- - "~>"
|
40
45
|
- !ruby/object:Gem::Version
|
41
|
-
version: '0
|
46
|
+
version: '1.0'
|
42
47
|
- - ">="
|
43
48
|
- !ruby/object:Gem::Version
|
44
|
-
version: 0.
|
49
|
+
version: 1.0.5
|
45
50
|
type: :runtime
|
46
51
|
prerelease: false
|
47
52
|
version_requirements: !ruby/object:Gem::Requirement
|
48
53
|
requirements:
|
49
54
|
- - "~>"
|
50
55
|
- !ruby/object:Gem::Version
|
51
|
-
version: '0
|
56
|
+
version: '1.0'
|
52
57
|
- - ">="
|
53
58
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
59
|
+
version: 1.0.5
|
55
60
|
- !ruby/object:Gem::Dependency
|
56
61
|
name: simple-config
|
57
62
|
requirement: !ruby/object:Gem::Requirement
|
58
63
|
requirements:
|
59
64
|
- - "~>"
|
60
65
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
66
|
+
version: '0.7'
|
62
67
|
- - ">="
|
63
68
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.
|
69
|
+
version: 0.7.1
|
65
70
|
type: :runtime
|
66
71
|
prerelease: false
|
67
72
|
version_requirements: !ruby/object:Gem::Requirement
|
68
73
|
requirements:
|
69
74
|
- - "~>"
|
70
75
|
- !ruby/object:Gem::Version
|
71
|
-
version: '0.
|
76
|
+
version: '0.7'
|
72
77
|
- - ">="
|
73
78
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.
|
79
|
+
version: 0.7.1
|
75
80
|
- !ruby/object:Gem::Dependency
|
76
81
|
name: testdata_text
|
77
82
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
123
|
- !ruby/object:Gem::Version
|
119
124
|
version: '0'
|
120
125
|
requirements: []
|
121
|
-
|
122
|
-
rubygems_version: 2.7.6
|
126
|
+
rubygems_version: 3.0.3
|
123
127
|
signing_key:
|
124
128
|
specification_version: 4
|
125
129
|
summary: Generates a test suite of files (for use with the testdata gem) from a config
|
metadata.gz.sig
CHANGED
Binary file
|