testkit123 0.4.0 → 0.5.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/lib/testkit123.rb +90 -90
- data.tar.gz.sig +0 -0
- metadata +5 -5
- 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: 2bb68a709ae975a1f5fdb89fd11258535f4245868ca3a788027cb222bd379d4a
|
4
|
+
data.tar.gz: 3f3406a2e22fce8f96a0d9c357bfd285fcfd9220ed722dee9a5699bbff766e9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7cc861ff7fa8782c0e5457b47f62130c3d0daa7e511640ece793477b2c9aff91d8ed0daec117b41b099522ba5cb240fca7e4848170694cfd4bbb35c0a505be
|
7
|
+
data.tar.gz: eb47de3581c38f7010589c1b885e9bca6bb160859303270e1749f43758e60492d55ce6649346939287ae4df82d49c639742c2209f307e66b46263b148c7cd7fb
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/testkit123.rb
CHANGED
@@ -9,70 +9,70 @@ require 'rxfreadwrite'
|
|
9
9
|
|
10
10
|
|
11
11
|
module StringFormat
|
12
|
-
|
12
|
+
|
13
13
|
refine String do
|
14
|
-
|
14
|
+
|
15
15
|
def camelize
|
16
|
-
self.split('_').collect(&:capitalize).join
|
16
|
+
self.split('_').collect(&:capitalize).join
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
end
|
22
22
|
|
23
23
|
class TestKit123
|
24
24
|
using StringFormat
|
25
25
|
using ColouredText
|
26
|
-
|
26
|
+
|
27
27
|
attr_reader :testdata_file
|
28
|
-
|
29
|
-
def initialize(templates: {testdata: nil, testx: nil}, project: nil,
|
30
|
-
debug: true, localpath: nil, datapath: nil,
|
28
|
+
|
29
|
+
def initialize(templates: {testdata: nil, testx: nil}, project: nil,
|
30
|
+
debug: true, localpath: nil, datapath: nil,
|
31
31
|
gemtest_url: nil, rubyver: 'ruby-2.5.1')
|
32
32
|
|
33
33
|
@debug = debug
|
34
34
|
@h = templates
|
35
|
-
|
35
|
+
|
36
36
|
#return unless project
|
37
|
-
|
37
|
+
|
38
38
|
@localpath, @datapath, @gemtest_url = localpath, datapath, gemtest_url
|
39
|
-
@rubyver = rubyver
|
40
|
-
|
39
|
+
@rubyver = rubyver
|
40
|
+
|
41
41
|
return unless project
|
42
|
-
|
42
|
+
|
43
43
|
@project_config = if project =~ /\.txt$/ then
|
44
44
|
project
|
45
45
|
else
|
46
|
-
File.join(localpath, project + '.txt')
|
46
|
+
File.join(localpath, project + '.txt')
|
47
47
|
end
|
48
|
-
|
49
|
-
puts '@project_config: ' + @project_config.inspect if @debug
|
48
|
+
|
49
|
+
puts '@project_config: ' + @project_config.inspect if @debug
|
50
50
|
puts 'localpath: ' + localpath.inspect if @debug
|
51
|
-
|
52
|
-
if File.
|
53
|
-
|
51
|
+
|
52
|
+
if File.exist? @project_config then
|
53
|
+
|
54
54
|
config = SimpleConfig.new(@project_config, debug: false).to_h
|
55
55
|
puts ('config: ' + config.inspect).debug if @debug
|
56
|
-
|
56
|
+
|
57
57
|
proj = config[:project]
|
58
58
|
puts 'create_standalone: proj: ' + proj.inspect if @debug
|
59
|
-
|
59
|
+
|
60
60
|
raise 'config[:data_path] not found' unless config[:data_path]
|
61
|
-
|
61
|
+
|
62
62
|
datafilepath = config[:data_path] + '/' + proj
|
63
|
-
test_rbfile = File.join(datafilepath, "test_#{proj}.rb")
|
64
|
-
|
63
|
+
test_rbfile = File.join(datafilepath, "test_#{proj}.rb")
|
64
|
+
|
65
65
|
ext = (config[:testdata_ext] and config[:testdata_ext][/\.?td$/]) ? 'td' : 'xml'
|
66
|
-
@testdata_file = File.join(datafilepath, "testdata_#{proj}.#{ext}")
|
67
|
-
|
66
|
+
@testdata_file = File.join(datafilepath, "testdata_#{proj}.#{ext}")
|
67
|
+
|
68
68
|
end
|
69
69
|
|
70
70
|
end
|
71
71
|
|
72
72
|
# expects a test node; see new_testnode()
|
73
73
|
#
|
74
|
-
def add_test(testnode)
|
75
|
-
|
74
|
+
def add_test(testnode)
|
75
|
+
|
76
76
|
s2 , filetype = RXFReader.read @testdata_file
|
77
77
|
puts 'filetype: ' + filetype.inspect if @debug
|
78
78
|
|
@@ -83,13 +83,13 @@ class TestKit123
|
|
83
83
|
end
|
84
84
|
|
85
85
|
puts 'xml: ' + xml.inspect if @debug
|
86
|
-
|
86
|
+
|
87
87
|
doc = Rexle.new(xml)
|
88
88
|
id = doc.root.xpath('records/test/summary/path/text()').last.to_i + 1
|
89
89
|
testnode.root.element('summary/path').text = id.to_s
|
90
90
|
doc.root.element('records').add testnode
|
91
91
|
return doc
|
92
|
-
end
|
92
|
+
end
|
93
93
|
|
94
94
|
def create_files(project=@project_config)
|
95
95
|
|
@@ -97,12 +97,12 @@ class TestKit123
|
|
97
97
|
|
98
98
|
puts '1) Reading the config file' if @debug
|
99
99
|
raise "missing the config file " unless @project_config
|
100
|
-
raise "config file not found" unless File.
|
100
|
+
raise "config file not found" unless File.exist? @project_config
|
101
101
|
|
102
102
|
config_file = @project_config
|
103
|
-
|
103
|
+
|
104
104
|
puts 'config_file: ' + config_file.inspect if @debug
|
105
|
-
|
105
|
+
|
106
106
|
config = SimpleConfig.new(config_file).to_h
|
107
107
|
puts 'config : ' + config.inspect if @debug
|
108
108
|
|
@@ -137,17 +137,17 @@ class TestKit123
|
|
137
137
|
testdata = @h[:testdata].gsub(/(?<=\.)\w+$/, ext)
|
138
138
|
puts 'testdata: ' + testdata.inspect if @debug
|
139
139
|
buffer_testdata, _ = RXFReader.read(testdata)
|
140
|
-
|
140
|
+
|
141
141
|
FileUtils.mkdir_p datafilepath
|
142
|
-
|
142
|
+
|
143
143
|
testdata_file = File.join(datafilepath, "testdata_#{proj}.#{ext}")
|
144
|
-
File.write testdata_file, eval('%{' + buffer_testdata + '}')
|
144
|
+
File.write testdata_file, eval('%{' + buffer_testdata + '}')
|
145
145
|
|
146
146
|
test_template_rsf = @h[:testx]
|
147
147
|
buffer_test, _ = RXFReader.read(test_template_rsf)
|
148
148
|
|
149
149
|
test_rsffile = File.join(config[:data_path], "#{proj}.rsf")
|
150
|
-
File.write test_rsffile, eval('%{' + buffer_test + '}')
|
150
|
+
File.write test_rsffile, eval('%{' + buffer_test + '}')
|
151
151
|
|
152
152
|
buffer_rb = %{#!/usr/bin/env ruby
|
153
153
|
|
@@ -155,9 +155,9 @@ buffer_rb = %{#!/usr/bin/env ruby
|
|
155
155
|
|
156
156
|
#require 'timecop'
|
157
157
|
|
158
|
-
|
158
|
+
|
159
159
|
class Test#{config[:classname]} < Testdata::Base
|
160
|
-
|
160
|
+
|
161
161
|
# 2011-07-24 19:52:15
|
162
162
|
#Timecop.freeze(Time.local(2011, 7, 24, 19, 52, 15))
|
163
163
|
|
@@ -171,45 +171,45 @@ end
|
|
171
171
|
|
172
172
|
test_rbfile = File.join(datafilepath, "test_#{proj}.rb")
|
173
173
|
puts 'reading the ruby template file ...' if @debug
|
174
|
-
File.write test_rbfile, eval('%{' + buffer_rb + '}')
|
174
|
+
File.write test_rbfile, eval('%{' + buffer_rb + '}')
|
175
175
|
|
176
176
|
"finished processing #{proj}"
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
179
|
def create_standalone(n)
|
180
|
-
|
180
|
+
|
181
181
|
# use the test number to find the test to copy from the test file
|
182
182
|
puts '@project_config: ' + @project_config.inspect
|
183
183
|
|
184
184
|
config = SimpleConfig.new(@project_config, debug: false).to_h
|
185
185
|
puts ('config: ' + config.inspect).debug if @debug
|
186
|
-
|
186
|
+
|
187
187
|
proj = config[:project]
|
188
188
|
puts 'create_standalone: proj: ' + proj.inspect if @debug
|
189
|
-
|
189
|
+
|
190
190
|
raise 'config[:data_path] not found' unless config[:data_path]
|
191
|
-
|
191
|
+
|
192
192
|
datafilepath = config[:data_path] + '/' + proj
|
193
|
-
test_rbfile = File.join(datafilepath, "test_#{proj}.rb")
|
194
|
-
|
193
|
+
test_rbfile = File.join(datafilepath, "test_#{proj}.rb")
|
194
|
+
|
195
195
|
ext = (config[:testdata_ext] and config[:testdata_ext][/\.?td$/]) ? 'td' : 'xml'
|
196
196
|
testdata_file = File.join(datafilepath, "testdata_#{proj}.#{ext}")
|
197
197
|
puts 'testdata_file: ' + testdata_file.inspect if @debug
|
198
198
|
puts 'source code filepath: ' + test_rbfile.inspect if @debug
|
199
|
-
|
199
|
+
|
200
200
|
s = File.read(test_rbfile).gsub(/^( )?end/,'')
|
201
201
|
require_gems = s.scan(/^require +['"]([^'"]+)/).map(&:first)
|
202
|
-
|
202
|
+
|
203
203
|
before_test = s[/(?<=def tests\(\)).*/m].split(/ test /)[0].lstrip
|
204
204
|
puts '** before_test: ' + before_test.inspect
|
205
205
|
|
206
206
|
a = s.split(/(?= test )/)
|
207
207
|
a.shift
|
208
208
|
puts 'a: ' + a.inspect if @debug
|
209
|
-
|
209
|
+
|
210
210
|
tests = a.map do |x|
|
211
211
|
r = x.match(/(?<=['"])(?<test>[^"']+)['"]\s+do\s+\|(?<raw_args>[^\|]+)/)
|
212
|
-
|
212
|
+
|
213
213
|
[r[:test], r[:raw_args].split(/, */)]
|
214
214
|
end
|
215
215
|
|
@@ -223,35 +223,35 @@ end
|
|
223
223
|
end
|
224
224
|
|
225
225
|
puts 'xml: ' + xml.inspect if @debug
|
226
|
-
|
226
|
+
|
227
227
|
doc = Rexle.new(xml)
|
228
228
|
puts 'after doc : ' if @debug
|
229
229
|
r = doc.root.xpath('records//test') || doc.root.xpath('records/test')
|
230
|
-
|
230
|
+
|
231
231
|
if @debug then
|
232
|
-
puts 'r: ' + r.inspect
|
232
|
+
puts 'r: ' + r.inspect
|
233
233
|
puts 'r.length: ' + r.length.inspect
|
234
234
|
puts 'n: ' + n.inspect
|
235
235
|
end
|
236
|
-
|
236
|
+
|
237
237
|
testnode = r[n-1]
|
238
238
|
puts 'testnode: ' + testnode.xml.inspect if @debug
|
239
|
-
|
239
|
+
|
240
240
|
title = testnode.text('summary/type')
|
241
241
|
puts ('title: ' + title.inspect).debug if @debug
|
242
242
|
puts ('tests: ' + tests.inspect).debug if @debug
|
243
243
|
i = tests.index tests.assoc(title)
|
244
244
|
puts 'i: ' + i.inspect if @debug
|
245
|
-
|
245
|
+
|
246
246
|
testcode = a[i].strip.lines[1..-2].map do |line|
|
247
247
|
line.sub(/^ {6}/,'')
|
248
248
|
end.join
|
249
|
-
|
250
|
-
# replace the input variable names with the input variable names defined
|
249
|
+
|
250
|
+
# replace the input variable names with the input variable names defined
|
251
251
|
# in the testdata file and prefix them with *test_*.
|
252
|
-
|
252
|
+
|
253
253
|
input_vars = testnode.xpath('records/input/summary/*/name()')
|
254
|
-
|
254
|
+
|
255
255
|
if @debug then
|
256
256
|
puts 'input_vars: ' + input_vars.inspect
|
257
257
|
puts 'tests[i][1]: ' + tests[i][1].inspect
|
@@ -260,7 +260,7 @@ end
|
|
260
260
|
|
261
261
|
tests[i][1].zip(input_vars).each do |x|
|
262
262
|
testcode.gsub!(/\b#{x[0]}\b/, 'test_' + x[1])
|
263
|
-
end
|
263
|
+
end
|
264
264
|
|
265
265
|
args = testnode.xpath('records/input/summary/*').map do |input|
|
266
266
|
|
@@ -273,19 +273,19 @@ end
|
|
273
273
|
end
|
274
274
|
|
275
275
|
end
|
276
|
-
|
276
|
+
|
277
277
|
vars = testnode.xpath('records/input/summary/*').map(&:name)
|
278
|
-
|
279
|
-
puts 'args: ' + args.inspect if @debug
|
280
|
-
|
278
|
+
|
279
|
+
puts 'args: ' + args.inspect if @debug
|
280
|
+
|
281
281
|
vars.each do |var|
|
282
|
-
testcode.gsub!(/\b#{var}\b/, 'test_' + var)
|
282
|
+
testcode.gsub!(/\b#{var}[^:]\b/, 'test_' + var)
|
283
283
|
end
|
284
|
-
|
284
|
+
|
285
285
|
puts 'gems: ' + require_gems.inspect if @debug
|
286
|
-
|
286
|
+
|
287
287
|
codex = testcode.rstrip.lines
|
288
|
-
|
288
|
+
|
289
289
|
"# Test %d. Type: %s\n# Description: %s\n" \
|
290
290
|
% [n, title, testnode.text('summary/type')] + \
|
291
291
|
"# --------------------------------------------\n\n" + \
|
@@ -298,45 +298,45 @@ end
|
|
298
298
|
end
|
299
299
|
|
300
300
|
def delete_files(s=nil)
|
301
|
-
|
301
|
+
|
302
302
|
filepath = if s =~ /\.txt$/ then
|
303
303
|
project
|
304
304
|
elsif s
|
305
|
-
File.join(@localpath, s + '.txt')
|
305
|
+
File.join(@localpath, s + '.txt')
|
306
306
|
else
|
307
307
|
@project_config
|
308
308
|
end
|
309
|
-
|
309
|
+
|
310
310
|
puts 'filepath: ' + filepath.inspect if @debug
|
311
|
-
|
311
|
+
|
312
312
|
config = SimpleConfig.new(filepath).to_h
|
313
|
-
|
313
|
+
|
314
314
|
proj = config[:project]
|
315
315
|
datafilepath = config[:data_path] + '/' + proj
|
316
316
|
FileUtils.rm_rf datafilepath
|
317
|
-
|
317
|
+
|
318
318
|
filepath = config[:local_path] + '/' + proj
|
319
319
|
FileUtils.rm_rf filepath
|
320
|
-
|
320
|
+
|
321
321
|
FileUtils.rm File.join(config[:data_path], "#{proj}.rsf")
|
322
|
-
|
322
|
+
|
323
323
|
proj + ' test files deleted'
|
324
|
-
|
324
|
+
|
325
325
|
end
|
326
|
-
|
326
|
+
|
327
327
|
def new_testnode(s=nil, type: '', inputs: {}, outputs: {result: ''})
|
328
|
-
|
328
|
+
|
329
329
|
if s then
|
330
|
-
|
331
|
-
# the scan is intended to find the input variables from an
|
330
|
+
|
331
|
+
# the scan is intended to find the input variables from an
|
332
332
|
# example Ruby script
|
333
|
-
|
333
|
+
|
334
334
|
inputs = s.scan(/test_([\w]+) += +['"]([^'"]+)/)\
|
335
|
-
.inject({}){|r,x| r.merge(x.first.to_sym => x.last)}
|
335
|
+
.inject({}){|r,x| r.merge(x.first.to_sym => x.last)}
|
336
336
|
end
|
337
|
-
|
337
|
+
|
338
338
|
# observe *test* is masked with *_test* because it is a built-in method name.
|
339
|
-
|
339
|
+
|
340
340
|
h = {
|
341
341
|
_test: {
|
342
342
|
summary: {
|
@@ -353,14 +353,14 @@ end
|
|
353
353
|
summary: outputs,
|
354
354
|
records: {}
|
355
355
|
}
|
356
|
-
}
|
356
|
+
}
|
357
357
|
}
|
358
358
|
}
|
359
359
|
|
360
360
|
a = RexleBuilder.new(h, debug: false).to_a
|
361
361
|
|
362
362
|
Rexle.new(a)
|
363
|
-
|
363
|
+
|
364
364
|
end
|
365
365
|
|
366
366
|
def new_project(project='myproject', classname=nil, save: false)
|
data.tar.gz.sig
CHANGED
Binary file
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
DN5UNRowuQ2fXKFO7nmgUH33wBhFAs2KXZPPR6sWn2JxLUlMMngzSypdB7zQn7my
|
36
36
|
FmX/ZG5sgd+RpEYbxgC2cdNk
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2023-02-02 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: simple-config
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '0.7'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.7.
|
49
|
+
version: 0.7.3
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version: '0.7'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.7.
|
59
|
+
version: 0.7.3
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: testdata_text
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
106
|
+
rubygems_version: 3.4.4
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Generates a test suite of files (for use with the testdata gem) from a config
|
metadata.gz.sig
CHANGED
Binary file
|