hiptest-publisher 0.5.10 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -5
- data/bin/hiptest-publisher +7 -0
- data/lib/config/cucumber-folders_as_features.conf +18 -0
- data/lib/config/cucumber.conf +18 -0
- data/lib/{templates/java/output_config → config/java.conf} +6 -4
- data/lib/{templates/javascript/jasmine/output_config → config/javascript-jasmine.conf} +0 -0
- data/lib/{templates/javascript/output_config → config/javascript.conf} +1 -1
- data/lib/{templates/python/output_config → config/python.conf} +3 -2
- data/lib/{templates/robotframework/output_config → config/robotframework.conf} +4 -3
- data/lib/{templates/ruby/minitest/output_config → config/ruby-minitest.conf} +0 -0
- data/lib/{templates/ruby/output_config → config/ruby.conf} +1 -1
- data/lib/{templates/seleniumide/output_config → config/seleniumide.conf} +4 -4
- data/lib/hiptest-publisher.rb +96 -76
- data/lib/hiptest-publisher/cli_options_checker.rb +107 -0
- data/lib/hiptest-publisher/handlebars_helper.rb +1 -1
- data/lib/hiptest-publisher/nodes.rb +39 -11
- data/lib/hiptest-publisher/nodes_walker.rb +2 -2
- data/lib/hiptest-publisher/options_parser.rb +304 -45
- data/lib/hiptest-publisher/parent_adder.rb +2 -2
- data/lib/hiptest-publisher/renderer.rb +7 -58
- data/lib/hiptest-publisher/utils.rb +5 -1
- data/lib/hiptest-publisher/xml_parser.rb +2 -1
- data/lib/templates/cucumber/folders_as_features/folder.hbs +4 -0
- data/lib/templates/cucumber/folders_as_features/single_scenario.hbs +14 -0
- data/lib/templates/java/dataset.hbs +1 -1
- data/lib/templates/java/scenarios.hbs +3 -3
- data/lib/templates/java/single_scenario.hbs +3 -3
- data/lib/templates/java/single_test.hbs +3 -3
- data/lib/templates/java/testng/dataset.hbs +1 -1
- data/lib/templates/java/testng/single_scenario.hbs +3 -3
- data/lib/templates/java/testng/single_test.hbs +3 -3
- data/lib/templates/java/tests.hbs +3 -3
- metadata +15 -11
- data/lib/templates/cucumber/output_config +0 -11
@@ -0,0 +1,107 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
class CliOptionsChecker
|
5
|
+
attr_reader :reporter, :cli_options
|
6
|
+
def initialize(cli_options, reporter)
|
7
|
+
@cli_options = cli_options
|
8
|
+
@reporter = reporter
|
9
|
+
end
|
10
|
+
|
11
|
+
def bad_arguments?
|
12
|
+
# ensure config file was readable if specified
|
13
|
+
begin
|
14
|
+
ParseConfig.new(cli_options.config) if present?(cli_options.config)
|
15
|
+
rescue Errno::EACCES => err
|
16
|
+
puts "Error with --config: the file \"#{cli_options.config}\" does not exist or is not readable"
|
17
|
+
return true
|
18
|
+
end
|
19
|
+
|
20
|
+
if cli_options.only == 'list'
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
unless cli_options.push.nil? || cli_options.push.empty?
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
# secret token
|
29
|
+
if missing?(cli_options.token) || empty?(cli_options.token)
|
30
|
+
puts "Missing argument --token: you must specify project secret token with --token=<project-token>"
|
31
|
+
puts ""
|
32
|
+
puts "The project secret token can be found on Hiptest in the settings section, under"
|
33
|
+
puts "'Publication settings'. It is a sequence of numbers uniquely identifying your"
|
34
|
+
puts "project."
|
35
|
+
puts ""
|
36
|
+
puts "Note that settings section is available only to administrators of the project."
|
37
|
+
return true
|
38
|
+
end
|
39
|
+
|
40
|
+
unless numeric?(cli_options.token)
|
41
|
+
puts "Invalid format --token=\"#{@cli_options.token}\": the project secret token must be numeric"
|
42
|
+
return true
|
43
|
+
end
|
44
|
+
|
45
|
+
# output directory
|
46
|
+
parent = first_existing_parent(cli_options.output_directory)
|
47
|
+
if !parent.writable?
|
48
|
+
if parent.realpath === Pathname.new(cli_options.output_directory).cleanpath
|
49
|
+
puts "Error with --output-directory: the directory \"#{@cli_options.output_directory}\" is not writable"
|
50
|
+
else
|
51
|
+
puts "Error with --output-directory: the directory \"#{@cli_options.output_directory}\" can not be created because \"#{parent.realpath}\" is not writable"
|
52
|
+
end
|
53
|
+
return true
|
54
|
+
elsif !parent.directory?
|
55
|
+
puts "Error with --output-directory: the file \"#{@cli_options.output_directory}\" is not a directory"
|
56
|
+
return true
|
57
|
+
end
|
58
|
+
|
59
|
+
# actionwords signature file
|
60
|
+
if cli_options.actionwords_diff || cli_options.aw_deleted || cli_options.aw_created || cli_options.aw_renamed || cli_options.aw_signature_changed
|
61
|
+
actionwords_signature_file = Pathname.new(cli_options.output_directory).join("actionwords_signature.yaml")
|
62
|
+
if actionwords_signature_file.directory?
|
63
|
+
puts "Bad Action Words signature file: the file \"#{actionwords_signature_file.realpath}\" is a directory"
|
64
|
+
return true
|
65
|
+
elsif !actionwords_signature_file.exist?
|
66
|
+
full_path = File.expand_path(cli_options.output_directory)
|
67
|
+
puts "Missing Action Words signature file: the file \"actionwords_signature.yaml\" could not be found in directory \"#{full_path}\""
|
68
|
+
puts "Use --actionwords-signature to generate the file \"#{full_path}/actionwords_signature.yaml\""
|
69
|
+
return true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# test run id
|
74
|
+
if present?(cli_options.test_run_id) && !numeric?(cli_options.test_run_id)
|
75
|
+
puts "Invalid format --test-run-id=\"#{@cli_options.test_run_id}\": the test run id must be numeric"
|
76
|
+
return true
|
77
|
+
end
|
78
|
+
|
79
|
+
return false
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def numeric?(arg)
|
85
|
+
arg =~ /^\d*$/
|
86
|
+
end
|
87
|
+
|
88
|
+
def missing?(arg)
|
89
|
+
arg.nil?
|
90
|
+
end
|
91
|
+
|
92
|
+
def empty?(arg)
|
93
|
+
arg.strip.empty?
|
94
|
+
end
|
95
|
+
|
96
|
+
def present?(arg)
|
97
|
+
arg && !arg.strip.empty?
|
98
|
+
end
|
99
|
+
|
100
|
+
def first_existing_parent(path)
|
101
|
+
pathname = Pathname.new(path)
|
102
|
+
while !pathname.exist?
|
103
|
+
pathname = pathname.parent
|
104
|
+
end
|
105
|
+
pathname.realpath
|
106
|
+
end
|
107
|
+
end
|
@@ -14,8 +14,8 @@ module Hiptest
|
|
14
14
|
super - [:@parent] # do not overload pry output
|
15
15
|
end
|
16
16
|
|
17
|
-
def render(
|
18
|
-
return Hiptest::Renderer.render(self,
|
17
|
+
def render(rendering_context)
|
18
|
+
return Hiptest::Renderer.render(self, rendering_context)
|
19
19
|
end
|
20
20
|
|
21
21
|
def find_sub_nodes(types = [])
|
@@ -49,6 +49,14 @@ module Hiptest
|
|
49
49
|
other.class == self.class && other.children == @children
|
50
50
|
end
|
51
51
|
|
52
|
+
def project
|
53
|
+
project = self
|
54
|
+
while project && !project.is_a?(Hiptest::Nodes::Project)
|
55
|
+
project = project.parent
|
56
|
+
end
|
57
|
+
project
|
58
|
+
end
|
59
|
+
|
52
60
|
private
|
53
61
|
|
54
62
|
def all_sub_nodes
|
@@ -278,6 +286,10 @@ module Hiptest
|
|
278
286
|
def set_uid(uid)
|
279
287
|
@children[:uid] = uid
|
280
288
|
end
|
289
|
+
|
290
|
+
def folder
|
291
|
+
project && project.children[:test_plan] && project.children[:test_plan].find_folder_by_uid(folder_uid)
|
292
|
+
end
|
281
293
|
end
|
282
294
|
|
283
295
|
class Test < Node
|
@@ -291,6 +303,10 @@ module Hiptest
|
|
291
303
|
:body => body
|
292
304
|
}
|
293
305
|
end
|
306
|
+
|
307
|
+
def folder
|
308
|
+
nil
|
309
|
+
end
|
294
310
|
end
|
295
311
|
|
296
312
|
class Datatable < Node
|
@@ -358,10 +374,9 @@ module Hiptest
|
|
358
374
|
end
|
359
375
|
|
360
376
|
class Folder < Node
|
361
|
-
attr_reader :uid, :
|
362
|
-
attr_writer :parent
|
377
|
+
attr_reader :uid, :parent_uid
|
363
378
|
|
364
|
-
def initialize(uid, parent_uid, name)
|
379
|
+
def initialize(uid, parent_uid, name, description)
|
365
380
|
super()
|
366
381
|
|
367
382
|
@uid = uid
|
@@ -369,10 +384,19 @@ module Hiptest
|
|
369
384
|
|
370
385
|
@children = {
|
371
386
|
:name => name,
|
387
|
+
:description => description,
|
372
388
|
:subfolders => [],
|
373
389
|
:scenarios => []
|
374
390
|
}
|
375
391
|
end
|
392
|
+
|
393
|
+
def root?
|
394
|
+
parent_uid == nil
|
395
|
+
end
|
396
|
+
|
397
|
+
def folder
|
398
|
+
root? ? nil : parent
|
399
|
+
end
|
376
400
|
end
|
377
401
|
|
378
402
|
class TestPlan < Node
|
@@ -386,16 +410,19 @@ module Hiptest
|
|
386
410
|
end
|
387
411
|
|
388
412
|
def organize_folders
|
413
|
+
@children[:root_folder] = @children[:folders].find(&:root?)
|
414
|
+
@children[:root_folder].parent = self if @children[:root_folder]
|
415
|
+
|
389
416
|
@children[:folders].each do |folder|
|
390
417
|
@uids_mapping[folder.uid] = folder
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
end
|
418
|
+
end
|
419
|
+
|
420
|
+
@children[:folders].each do |folder|
|
421
|
+
next if folder.root?
|
396
422
|
|
423
|
+
parent = find_folder_by_uid(folder.parent_uid) || @children[:root_folder]
|
397
424
|
folder.parent = parent
|
398
|
-
parent.children[:subfolders] << folder
|
425
|
+
parent.children[:subfolders] << folder unless parent.children[:subfolders].include?(folder)
|
399
426
|
end
|
400
427
|
end
|
401
428
|
|
@@ -407,6 +434,7 @@ module Hiptest
|
|
407
434
|
class Project < Node
|
408
435
|
def initialize(name, description = '', test_plan = TestPlan.new, scenarios = Scenarios.new, actionwords = Actionwords.new, tests = Tests.new)
|
409
436
|
super()
|
437
|
+
test_plan.parent = self if test_plan.respond_to?(:parent=)
|
410
438
|
scenarios.parent = self
|
411
439
|
tests.parent = self
|
412
440
|
|
@@ -22,7 +22,7 @@ module Hiptest
|
|
22
22
|
node_class = node.class.name.split('::').last.downcase
|
23
23
|
walk_method_name = "walk_#{node_class}".to_sym
|
24
24
|
|
25
|
-
if
|
25
|
+
if respond_to? walk_method_name
|
26
26
|
self.send(walk_method_name, node)
|
27
27
|
end
|
28
28
|
end
|
@@ -42,4 +42,4 @@ module Hiptest
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
-
end
|
45
|
+
end
|
@@ -80,14 +80,16 @@ class OptionsParser
|
|
80
80
|
Option.new(nil, 'test-run-id=ID', '', String, "Export data from a test run", :test_run_id),
|
81
81
|
Option.new(nil, 'scenario-ids=IDS', '', String, "Filter scenarios by ids", :filter_ids),
|
82
82
|
Option.new(nil, 'scenario-tags=TAGS', '', String, "Filter scenarios by tags", :filter_tags),
|
83
|
-
Option.new(nil, '
|
84
|
-
Option.new(nil, '
|
85
|
-
Option.new(nil, 'actionwords-
|
83
|
+
Option.new(nil, 'only=CATEGORIES', nil, String, "Restrict export to given file categories (--only=list to list them)", :only),
|
84
|
+
Option.new(nil, 'tests-only', false, nil, "(deprecated) alias for --only=tests", :tests_only),
|
85
|
+
Option.new(nil, 'actionwords-only', false, nil, "(deprecated) alias for --only=actionwords", :actionwords_only),
|
86
|
+
Option.new(nil, 'actionwords-signature', false, nil, "Export actionwords signature", :actionwords_signature),
|
86
87
|
Option.new(nil, 'show-actionwords-diff', false, nil, "Show actionwords diff since last update (summary)", :actionwords_diff),
|
87
88
|
Option.new(nil, 'show-actionwords-deleted', false, nil, "Output signature of deleted action words", :aw_deleted),
|
88
89
|
Option.new(nil, 'show-actionwords-created', false, nil, "Output code for new action words", :aw_created),
|
89
90
|
Option.new(nil, 'show-actionwords-renamed', false, nil, "Output signatures of renamed action words", :aw_renamed),
|
90
91
|
Option.new(nil, 'show-actionwords-signature-changed', false, nil, "Output signatures of action words for which signature changed", :aw_signature_changed),
|
92
|
+
Option.new(nil, 'with-folders', false, nil, "Use folders hierarchy to export files in respective directories, to be used with --split-scenarios", :with_folders),
|
91
93
|
Option.new(nil, 'split-scenarios', false, nil, "Export each scenario in a single file", :split_scenarios),
|
92
94
|
Option.new(nil, 'leafless-export', false, nil, "Use only last level action word", :leafless_export),
|
93
95
|
Option.new('s', 'site=SITE', 'https://hiptest.net', String, "Site to fetch from", :site),
|
@@ -171,54 +173,309 @@ class OptionsParser
|
|
171
173
|
end
|
172
174
|
end
|
173
175
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
176
|
+
|
177
|
+
class NodeRenderingContext
|
178
|
+
|
179
|
+
def initialize(properties)
|
180
|
+
# should contain :node, :path, :template_dirs, :description, :indentation
|
181
|
+
@properties = OpenStruct.new(properties)
|
179
182
|
end
|
180
183
|
|
181
|
-
def
|
182
|
-
|
183
|
-
|
184
|
-
|
184
|
+
def method_missing(name, *)
|
185
|
+
@properties[name]
|
186
|
+
end
|
187
|
+
|
188
|
+
def node
|
189
|
+
@properties.node
|
190
|
+
end
|
191
|
+
|
192
|
+
def [](key)
|
193
|
+
@properties[key]
|
194
|
+
end
|
195
|
+
|
196
|
+
def has_key?(key)
|
197
|
+
@properties.respond_to?(key)
|
198
|
+
end
|
199
|
+
|
200
|
+
def filename
|
201
|
+
File.basename(@properties.path)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
class TemplateFinder
|
207
|
+
attr_reader :language, :framework, :overriden_templates, :forced_templates, :fallback_template
|
208
|
+
|
209
|
+
def initialize(
|
210
|
+
language: "ruby",
|
211
|
+
framework: nil,
|
212
|
+
overriden_templates: nil,
|
213
|
+
indentation: ' ',
|
214
|
+
forced_templates: nil,
|
215
|
+
fallback_template: nil,
|
216
|
+
**)
|
217
|
+
@language = language
|
218
|
+
@framework = framework
|
219
|
+
@overriden_templates = overriden_templates
|
220
|
+
@compiled_handlebars = {}
|
221
|
+
@forced_templates = forced_templates || {}
|
222
|
+
@fallback_template = fallback_template
|
223
|
+
@context = {indentation: indentation}
|
224
|
+
end
|
225
|
+
|
226
|
+
def dirs
|
227
|
+
dirs = []
|
228
|
+
dirs << "#{language}/#{framework}" if framework
|
229
|
+
dirs << language
|
230
|
+
dirs << "common"
|
231
|
+
dirs.map! { |path| "#{hiptest_publisher_path}/lib/templates/#{path}" }
|
232
|
+
|
233
|
+
dirs.unshift(overriden_templates) if overriden_templates
|
234
|
+
dirs
|
235
|
+
end
|
236
|
+
|
237
|
+
def get_compiled_handlebars(template)
|
238
|
+
@compiled_handlebars[template] ||= handlebars.compile(File.read(template))
|
239
|
+
end
|
240
|
+
|
241
|
+
def get_template_by_name(name, extension)
|
242
|
+
return if name.nil?
|
243
|
+
dirs.map do |path|
|
244
|
+
template_path = File.join(path, "#{name}.#{extension}")
|
245
|
+
template_path if File.file?(template_path)
|
185
246
|
end.compact.first
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
247
|
+
end
|
248
|
+
|
249
|
+
def get_template_path(template_name, extension = 'hbs')
|
250
|
+
get_template_by_name(template_name, extension) || get_template_by_name(@fallback_template, extension)
|
251
|
+
end
|
252
|
+
|
253
|
+
def get_template(template_name, extension = 'hbs')
|
254
|
+
template_file = get_template_path(template_name, extension = 'hbs')
|
255
|
+
if template_file
|
256
|
+
get_compiled_handlebars(template).call(render_context)
|
257
|
+
else
|
258
|
+
raise ArgumentError.new("no template with name #{template_name}")
|
190
259
|
end
|
191
|
-
config_path
|
192
260
|
end
|
193
261
|
|
194
|
-
def
|
195
|
-
|
196
|
-
|
262
|
+
def register_partials
|
263
|
+
dirs.reverse.each do |path|
|
264
|
+
next unless File.directory?(path)
|
265
|
+
Dir.entries(path).select do |file_name|
|
266
|
+
file_path = File.join(path, file_name)
|
267
|
+
next unless File.file?(file_path) && file_name.start_with?('_')
|
268
|
+
@handlebars.register_partial(file_name[1..-5], File.read(file_path))
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
private
|
274
|
+
|
275
|
+
def handlebars
|
276
|
+
if !@handlebars
|
277
|
+
@handlebars = Handlebars::Handlebars.new
|
278
|
+
register_partials
|
279
|
+
Hiptest::HandlebarsHelper.register_helpers(@handlebars, @context)
|
280
|
+
end
|
281
|
+
@handlebars
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
class LanguageGroupConfig
|
286
|
+
def initialize(user_params, language_group_params = nil)
|
287
|
+
@output_directory = user_params.output_directory || ""
|
288
|
+
@split_scenarios = user_params.split_scenarios
|
289
|
+
@with_folders = user_params.with_folders
|
290
|
+
@leafless_export = user_params.leafless_export
|
291
|
+
@user_language = user_params.language
|
292
|
+
@user_framework = user_params.framework
|
293
|
+
@language_group_params = language_group_params || {}
|
294
|
+
end
|
295
|
+
|
296
|
+
def [](key)
|
297
|
+
@language_group_params[key]
|
298
|
+
end
|
299
|
+
|
300
|
+
def with_folders?
|
301
|
+
@with_folders
|
302
|
+
end
|
303
|
+
|
304
|
+
def splitted_files?
|
305
|
+
if self[:scenario_filename].nil?
|
306
|
+
false
|
307
|
+
elsif self[:filename].nil?
|
308
|
+
true
|
309
|
+
else
|
310
|
+
@split_scenarios
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
def nodes(project)
|
315
|
+
case node_name
|
316
|
+
when :tests, :scenarios, :actionwords
|
317
|
+
get_children(project, node_name)
|
318
|
+
when :folders
|
319
|
+
project.children[:test_plan].children[:folders].select {|folder| folder.children[:scenarios].length > 0}
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
def forced_templates
|
324
|
+
forced = {}
|
325
|
+
if splitted_files?
|
326
|
+
forced.merge!(
|
327
|
+
"scenario" => "single_scenario",
|
328
|
+
"test" => "single_test",
|
329
|
+
)
|
330
|
+
end
|
331
|
+
if @language_group_params[:forced_templates]
|
332
|
+
forced.merge!(@language_group_params[:forced_templates])
|
333
|
+
end
|
334
|
+
forced
|
335
|
+
end
|
336
|
+
|
337
|
+
def template_finder
|
338
|
+
@template_finder ||= TemplateFinder.new(
|
339
|
+
language: @language_group_params[:language] || @user_language,
|
340
|
+
framework: @language_group_params[:framework] || @user_framework,
|
341
|
+
overriden_templates: @language_group_params[:overriden_templates],
|
342
|
+
indentation: indentation,
|
343
|
+
forced_templates: forced_templates,
|
344
|
+
fallback_template: @language_group_params[:fallback_template],
|
345
|
+
)
|
346
|
+
end
|
347
|
+
|
348
|
+
def template_dirs
|
349
|
+
template_finder.dirs
|
350
|
+
end
|
351
|
+
|
352
|
+
def each_node_rendering_context(project)
|
353
|
+
return to_enum(:each_node_rendering_context, project) unless block_given?
|
354
|
+
nodes(project).each do |node|
|
355
|
+
yield build_node_rendering_context(node)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def indentation
|
360
|
+
@language_group_params[:indentation] || ' '
|
361
|
+
end
|
362
|
+
|
363
|
+
def build_node_rendering_context(node)
|
364
|
+
path = File.join(@output_directory, output_file(node))
|
365
|
+
|
366
|
+
if splitted_files?
|
367
|
+
description = "#{singularize(node_name)} \"#{node.children[:name]}\""
|
197
368
|
else
|
198
|
-
|
369
|
+
description = node_name.to_s
|
199
370
|
end
|
200
371
|
|
201
|
-
|
372
|
+
NodeRenderingContext.new(
|
373
|
+
path: path,
|
374
|
+
indentation: indentation,
|
375
|
+
template_dirs: template_dirs,
|
376
|
+
template_finder: template_finder,
|
377
|
+
forced_templates: forced_templates,
|
378
|
+
description: description,
|
379
|
+
node: node,
|
380
|
+
fallback_template: @language_group_params[:fallback_template],
|
381
|
+
call_prefix: @language_group_params[:call_prefix],
|
382
|
+
package: @language_group_params[:package],
|
383
|
+
)
|
202
384
|
end
|
203
385
|
|
204
|
-
def
|
205
|
-
|
386
|
+
def output_directory(node)
|
387
|
+
folder = node.folder
|
388
|
+
hierarchy = []
|
389
|
+
while folder && !folder.root?
|
390
|
+
hierarchy << normalized_filename(folder.children[:name])
|
391
|
+
folder = folder.parent
|
392
|
+
end
|
393
|
+
File.join(*hierarchy.reverse)
|
206
394
|
end
|
207
395
|
|
208
|
-
def
|
209
|
-
|
396
|
+
def output_file(node)
|
397
|
+
if splitted_files?
|
398
|
+
name = normalized_filename(node.children[:name])
|
399
|
+
filename = self[:scenario_filename].gsub('%s', name)
|
400
|
+
directory = with_folders? ? output_directory(node) : ""
|
401
|
+
File.join(directory, filename)
|
402
|
+
else
|
403
|
+
self[:filename]
|
404
|
+
end
|
210
405
|
end
|
211
406
|
|
212
|
-
|
213
|
-
|
407
|
+
private
|
408
|
+
|
409
|
+
def node_name
|
410
|
+
if self[:node_name] == "tests" || self[:node_name] == "scenarios" || self[:group_name] == "tests"
|
411
|
+
@leafless_export ? :tests : :scenarios
|
412
|
+
elsif self[:node_name] == "actionwords" || self[:group_name] == "actionwords"
|
413
|
+
:actionwords
|
414
|
+
elsif self[:node_name] == "folders"
|
415
|
+
:folders
|
416
|
+
else
|
417
|
+
raise "Invalid node_name #{self[:node_name]} in language group [#{self[:group_name]}]"
|
418
|
+
end
|
214
419
|
end
|
215
420
|
|
216
|
-
def
|
217
|
-
|
421
|
+
def get_children(project, node_key)
|
422
|
+
if splitted_files?
|
423
|
+
project.children[node_key].children[node_key]
|
424
|
+
else
|
425
|
+
[project.children[node_key]]
|
426
|
+
end
|
218
427
|
end
|
219
428
|
|
220
|
-
def
|
221
|
-
|
429
|
+
def normalized_filename(name)
|
430
|
+
filename_convention = @language_group_params[:filename_convention] || :normalize
|
431
|
+
name.send(filename_convention)
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
|
436
|
+
class LanguageConfigParser
|
437
|
+
def initialize(cli_options, language_config_path = nil)
|
438
|
+
@cli_options = cli_options
|
439
|
+
language_config_path ||= LanguageConfigParser.config_path_for(cli_options)
|
440
|
+
@config = ParseConfig.new(language_config_path)
|
441
|
+
end
|
442
|
+
|
443
|
+
def self.config_path_for(cli_options)
|
444
|
+
config_path = [
|
445
|
+
"#{hiptest_publisher_path}/lib/config/#{cli_options.language}-#{cli_options.framework}.conf",
|
446
|
+
"#{hiptest_publisher_path}/lib/config/#{cli_options.language}.conf",
|
447
|
+
].map do |path|
|
448
|
+
File.expand_path(path) if File.file?(path)
|
449
|
+
end.compact.first
|
450
|
+
if config_path.nil?
|
451
|
+
message = "cannot find configuration file in \"#{hiptest_publisher_path}/config\" for language #{cli_options.language.inspect}"
|
452
|
+
message << " and framework #{cli_options.framework.inspect}" if cli_options.framework
|
453
|
+
raise ArgumentError.new(message)
|
454
|
+
end
|
455
|
+
config_path
|
456
|
+
end
|
457
|
+
|
458
|
+
def group_names
|
459
|
+
@config.groups.reject {|group_name|
|
460
|
+
group_name.start_with?('_')
|
461
|
+
}
|
462
|
+
end
|
463
|
+
|
464
|
+
def filtered_group_names
|
465
|
+
if @cli_options.only
|
466
|
+
groups_to_keep = @cli_options.only.split(",")
|
467
|
+
group_names.select {|group_name| groups_to_keep.include?(group_name)}
|
468
|
+
else
|
469
|
+
group_names
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
def include_group?(group_name)
|
474
|
+
filtered_group_names.include?(group_name)
|
475
|
+
end
|
476
|
+
|
477
|
+
def language_group_configs
|
478
|
+
filtered_group_names.map { |group_name| make_language_group_config(group_name) }
|
222
479
|
end
|
223
480
|
|
224
481
|
def name_action_word(name)
|
@@ -226,24 +483,26 @@ class LanguageConfigParser
|
|
226
483
|
end
|
227
484
|
|
228
485
|
private
|
229
|
-
def make_context group
|
230
|
-
context = {
|
231
|
-
:forced_templates => {}
|
232
|
-
}
|
233
486
|
|
234
|
-
|
235
|
-
|
236
|
-
|
487
|
+
def group_config(group_name)
|
488
|
+
if @config[group_name]
|
489
|
+
@config[group_name].map { |key, value| [key.to_sym, value] }.to_h
|
490
|
+
else
|
491
|
+
{}
|
237
492
|
end
|
493
|
+
end
|
238
494
|
|
239
|
-
|
240
|
-
|
495
|
+
def make_language_group_config group_name
|
496
|
+
language_group_params = group_config('_common')
|
497
|
+
language_group_params.merge!(group_config(group_name))
|
498
|
+
language_group_params[:group_name] = group_name
|
499
|
+
language_group_params[:package] = @cli_options.package if @cli_options.package
|
500
|
+
language_group_params[:framework] = @cli_options.framework if @cli_options.framework
|
241
501
|
|
242
|
-
unless @
|
243
|
-
|
502
|
+
unless @cli_options.overriden_templates.nil? || @cli_options.overriden_templates.empty?
|
503
|
+
language_group_params[:overriden_templates] = @cli_options.overriden_templates
|
244
504
|
end
|
245
505
|
|
246
|
-
@
|
247
|
-
context
|
506
|
+
LanguageGroupConfig.new(@cli_options, language_group_params)
|
248
507
|
end
|
249
508
|
end
|