hiptest-publisher 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiptest-publisher.rb +33 -40
- data/lib/hiptest-publisher/actionword_indexer.rb +1 -1
- data/lib/hiptest-publisher/call_arguments_adder.rb +1 -1
- data/lib/hiptest-publisher/cli_options_checker.rb +30 -15
- data/lib/hiptest-publisher/gherkin_adder.rb +1 -1
- data/lib/hiptest-publisher/nodes.rb +30 -36
- data/lib/hiptest-publisher/nodes_walker.rb +17 -16
- data/lib/hiptest-publisher/options_parser.rb +28 -34
- data/lib/hiptest-publisher/parameter_type_adder.rb +12 -15
- data/lib/hiptest-publisher/parent_adder.rb +3 -3
- data/lib/hiptest-publisher/render_context_maker.rb +12 -3
- data/lib/hiptest-publisher/renderer.rb +2 -16
- data/lib/hiptest-publisher/utils.rb +29 -11
- data/lib/hiptest-publisher/xml_parser.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da8ec8699aae12338c795fa1fb399a78ecd748ff
|
4
|
+
data.tar.gz: 7d73cb2f8c7d16f650af43472c07f4f5308a4d78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fbebc2dddcc47b090219432ff98adebe85182947db14086450153b86779af7db619d60040046f230e4751c693c992e2a8f2fa5f3403f19e361523d878f2a661
|
7
|
+
data.tar.gz: 409ffd0c3c4e37196e6d3e74d2f40a966442ae60f6ae6faacf0e4820eebf90a0adbf113ef98ea7f1b43755830abbdc994bbfa40e3d2821bc9c611257992dcecb
|
data/lib/hiptest-publisher.rb
CHANGED
@@ -39,6 +39,7 @@ module Hiptest
|
|
39
39
|
|
40
40
|
def run
|
41
41
|
normalize_cli_options!
|
42
|
+
puts "URL: #{make_url(@cli_options)}".white if @cli_options.verbose
|
42
43
|
begin
|
43
44
|
CliOptionsChecker.new(@cli_options, reporter).check!
|
44
45
|
rescue CliOptionError => e
|
@@ -52,12 +53,16 @@ module Hiptest
|
|
52
53
|
return
|
53
54
|
end
|
54
55
|
|
55
|
-
|
56
|
+
if push?(@cli_options)
|
56
57
|
post_results
|
57
58
|
return
|
58
59
|
end
|
59
60
|
|
60
|
-
|
61
|
+
if @cli_options.xml_file
|
62
|
+
xml = IO.read(@cli_options.xml_file)
|
63
|
+
else
|
64
|
+
xml = fetch_xml_file
|
65
|
+
end
|
61
66
|
return if xml.nil?
|
62
67
|
|
63
68
|
@project = get_project(xml)
|
@@ -76,39 +81,32 @@ module Hiptest
|
|
76
81
|
end
|
77
82
|
|
78
83
|
def fetch_xml_file
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
return xml
|
84
|
+
with_status_message "Fetching data from Hiptest" do
|
85
|
+
fetch_project_export(@cli_options)
|
86
|
+
end
|
84
87
|
rescue Exception => err
|
85
|
-
show_status_message "Fetching data from Hiptest", :failure
|
86
88
|
puts "Unable to open the file, please check that the token is correct".red
|
87
89
|
reporter.dump_error(err)
|
88
90
|
end
|
89
91
|
|
90
92
|
def get_project(xml)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
with_status_message "Extracting data" do
|
94
|
+
parser = Hiptest::XMLParser.new(xml, reporter)
|
95
|
+
return parser.build_project
|
96
|
+
end
|
97
|
+
rescue Exception => err
|
98
|
+
reporter.dump_error(err)
|
96
99
|
end
|
97
100
|
|
98
101
|
def write_to_file(path, message)
|
99
|
-
|
100
|
-
begin
|
101
|
-
show_status_message status_message
|
102
|
+
with_status_message "#{message}: #{path}" do
|
102
103
|
mkdirs_for(path)
|
103
104
|
File.open(path, 'w') do |file|
|
104
105
|
file.write(yield)
|
105
106
|
end
|
106
|
-
|
107
|
-
show_status_message status_message, :success
|
108
|
-
rescue Exception => err
|
109
|
-
show_status_message status_message, :failure
|
110
|
-
reporter.dump_error(err)
|
111
107
|
end
|
108
|
+
rescue Exception => err
|
109
|
+
reporter.dump_error(err)
|
112
110
|
end
|
113
111
|
|
114
112
|
def mkdirs_for(path)
|
@@ -148,13 +146,9 @@ module Hiptest
|
|
148
146
|
end
|
149
147
|
|
150
148
|
def show_actionwords_diff
|
151
|
-
|
152
|
-
|
149
|
+
old = nil
|
150
|
+
with_status_message "Loading previous definition" do
|
153
151
|
old = YAML.load_file("#{@cli_options.output_directory}/actionwords_signature.yaml")
|
154
|
-
show_status_message("Loading previous definition", :success)
|
155
|
-
rescue Exception => err
|
156
|
-
show_status_message("Loading previous definition", :failure)
|
157
|
-
reporter.dump_error(err)
|
158
152
|
end
|
159
153
|
|
160
154
|
@language_config = LanguageConfigParser.new(@cli_options)
|
@@ -242,16 +236,20 @@ module Hiptest
|
|
242
236
|
puts "No action words changed"
|
243
237
|
puts ""
|
244
238
|
end
|
239
|
+
rescue Exception => err
|
240
|
+
reporter.dump_error(err)
|
245
241
|
end
|
246
242
|
|
247
243
|
def export
|
248
244
|
return if @project.nil?
|
249
245
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
246
|
+
with_status_message "Analyzing data" do
|
247
|
+
@language_config = LanguageConfigParser.new(@cli_options)
|
248
|
+
Hiptest::Nodes::ParentAdder.add(@project)
|
249
|
+
Hiptest::Nodes::ParameterTypeAdder.add(@project)
|
250
|
+
Hiptest::DefaultArgumentAdder.add(@project)
|
251
|
+
Hiptest::GherkinAdder.add(@project)
|
252
|
+
end
|
255
253
|
|
256
254
|
export_files
|
257
255
|
export_actionword_signature if @language_config.include_group?("actionwords")
|
@@ -277,16 +275,11 @@ module Hiptest
|
|
277
275
|
end
|
278
276
|
|
279
277
|
def post_results
|
280
|
-
|
281
|
-
show_status_message(status_message)
|
282
|
-
|
283
|
-
begin
|
278
|
+
with_status_message "Posting #{@cli_options.push} to #{@cli_options.site}" do
|
284
279
|
push_results(@cli_options)
|
285
|
-
show_status_message(status_message, :success)
|
286
|
-
rescue Exception => err
|
287
|
-
show_status_message(status_message, :failure)
|
288
|
-
reporter.dump_error(err)
|
289
280
|
end
|
281
|
+
rescue Exception => err
|
282
|
+
reporter.dump_error(err)
|
290
283
|
end
|
291
284
|
end
|
292
285
|
end
|
@@ -23,25 +23,27 @@ module Hiptest
|
|
23
23
|
return
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
if push?(cli_options)
|
27
27
|
return
|
28
28
|
end
|
29
29
|
|
30
30
|
# secret token
|
31
|
-
if
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
31
|
+
if absent?(cli_options.xml_file)
|
32
|
+
if absent?(cli_options.token)
|
33
|
+
raise CliOptionError, [
|
34
|
+
"Missing argument --token: you must specify project secret token with --token=<project-token>",
|
35
|
+
"",
|
36
|
+
"The project secret token can be found on Hiptest in the settings section, under",
|
37
|
+
"'Publication settings'. It is a sequence of numbers uniquely identifying your",
|
38
|
+
"project.",
|
39
|
+
"",
|
40
|
+
"Note that settings section is available only to administrators of the project.",
|
41
|
+
].join("\n")
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
unless numeric?(cli_options.token)
|
45
|
+
raise CliOptionError, "Invalid format --token=\"#{@cli_options.token}\": the project secret token must be numeric"
|
46
|
+
end
|
45
47
|
end
|
46
48
|
|
47
49
|
# output directory
|
@@ -70,6 +72,15 @@ module Hiptest
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
75
|
+
# xml file
|
76
|
+
if cli_options.xml_file
|
77
|
+
if !File.readable?(cli_options.xml_file)
|
78
|
+
raise CliOptionError, "Error with --xml-file: the file \"#{cli_options.xml_file}\" does not exist or is not readable"
|
79
|
+
elsif !File.file?(cli_options.xml_file)
|
80
|
+
raise CliOptionError, "Error with --xml-file: the file \"#{cli_options.xml_file}\" is not a regular file"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
73
84
|
# test run id
|
74
85
|
if present?(cli_options.test_run_id) && !numeric?(cli_options.test_run_id)
|
75
86
|
raise CliOptionError, "Invalid format --test-run-id=\"#{@cli_options.test_run_id}\": the test run id must be numeric"
|
@@ -90,8 +101,12 @@ module Hiptest
|
|
90
101
|
arg.strip.empty?
|
91
102
|
end
|
92
103
|
|
104
|
+
def absent?(arg)
|
105
|
+
missing?(arg) || empty?(arg)
|
106
|
+
end
|
107
|
+
|
93
108
|
def present?(arg)
|
94
|
-
|
109
|
+
!absent?(arg)
|
95
110
|
end
|
96
111
|
|
97
112
|
def first_existing_parent(path)
|
@@ -13,7 +13,7 @@ module Hiptest
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def update_calls
|
16
|
-
@project.
|
16
|
+
@project.each_sub_nodes(Hiptest::Nodes::Call) do |call|
|
17
17
|
call.children[:gherkin_text] ||= "#{text_annotation(call)} #{prettified(call)}"
|
18
18
|
if actionword = get_actionword(call)
|
19
19
|
actionword.children[:gherkin_annotation] ||= code_annotation(call)
|
@@ -18,31 +18,36 @@ module Hiptest
|
|
18
18
|
return Hiptest::Renderer.render(self, rendering_context)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
21
|
+
def each_sub_nodes(*types)
|
22
|
+
return to_enum(:each_sub_nodes, *types) unless block_given?
|
23
|
+
path = [self]
|
24
|
+
parsed_nodes_id = Set.new
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
until path.empty?
|
27
|
+
current_node = path.shift
|
28
|
+
|
29
|
+
if current_node.is_a?(Node)
|
30
|
+
next if parsed_nodes_id.include? current_node.object_id
|
31
|
+
|
32
|
+
if types.empty? || types.any? {|type| current_node.is_a?(type)}
|
33
|
+
yield current_node
|
34
|
+
end
|
35
|
+
parsed_nodes_id << current_node.object_id
|
36
|
+
current_node.children.each_value {|item| path << item}
|
37
|
+
elsif current_node.is_a?(Array)
|
38
|
+
current_node.each {|item| path << item}
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
33
42
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
children.each do |key, child|
|
43
|
+
def each_direct_children
|
44
|
+
children.each_value do |child|
|
38
45
|
if child.is_a? Hiptest::Nodes::Node
|
39
|
-
|
46
|
+
yield child
|
40
47
|
elsif child.is_a? Array
|
41
|
-
child.each {|c|
|
48
|
+
child.each {|c| yield c if c.is_a? Hiptest::Nodes::Node }
|
42
49
|
end
|
43
50
|
end
|
44
|
-
|
45
|
-
direct
|
46
51
|
end
|
47
52
|
|
48
53
|
def ==(other)
|
@@ -57,27 +62,16 @@ module Hiptest
|
|
57
62
|
project
|
58
63
|
end
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
parsed_nodes_id = Set.new
|
66
|
-
|
67
|
-
until path.empty?
|
68
|
-
current_node = path.pop
|
65
|
+
def kind
|
66
|
+
node_kinds[self.class] ||= begin
|
67
|
+
self.class.name.split('::').last.downcase
|
68
|
+
end
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
-
next if parsed_nodes_id.include? current_node.object_id
|
71
|
+
private
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
current_node.children.values.reverse.each {|item| path << item}
|
76
|
-
elsif current_node.is_a?(Array)
|
77
|
-
current_node.reverse.each {|item| path << item}
|
78
|
-
end
|
79
|
-
end
|
80
|
-
children
|
73
|
+
def node_kinds
|
74
|
+
@@node_kinds ||= {}
|
81
75
|
end
|
82
76
|
end
|
83
77
|
|
@@ -254,7 +248,7 @@ module Hiptest
|
|
254
248
|
|
255
249
|
def declared_variables_names
|
256
250
|
p_names = children[:parameters].map {|p| p.children[:name]}
|
257
|
-
|
251
|
+
each_sub_nodes(Hiptest::Nodes::Variable).map do |var|
|
258
252
|
v_name = var.children[:name]
|
259
253
|
p_names.include?(v_name) ? nil : v_name
|
260
254
|
end.uniq.compact
|
@@ -1,40 +1,41 @@
|
|
1
1
|
module Hiptest
|
2
2
|
module Nodes
|
3
3
|
class Walker
|
4
|
-
def initialize(order = :parent_first)
|
5
|
-
@order = order
|
6
|
-
end
|
7
|
-
|
8
|
-
def walk_node(node)
|
9
|
-
self.send(@order, node)
|
10
|
-
end
|
11
|
-
|
12
4
|
private
|
13
5
|
|
14
6
|
def walk_children(node)
|
15
7
|
return unless node.is_a? Hiptest::Nodes::Node
|
16
|
-
node.children.
|
8
|
+
node.children.each_value {|child| walk_node(child)}
|
17
9
|
end
|
18
10
|
|
19
11
|
def call_node_walker(node)
|
20
12
|
return unless node.is_a? Hiptest::Nodes::Node
|
21
13
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
if respond_to? walk_method_name
|
26
|
-
self.send(walk_method_name, node)
|
14
|
+
if respond_to? walk_method_name(node)
|
15
|
+
self.send(walk_method_name(node), node)
|
27
16
|
end
|
28
17
|
end
|
29
18
|
|
30
|
-
def
|
19
|
+
def walk_method_name(node)
|
20
|
+
walk_method_names[node.class] ||= "walk_#{node.kind}".to_sym
|
21
|
+
end
|
22
|
+
|
23
|
+
def walk_method_names
|
24
|
+
@walk_method_names ||= {}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class ParentFirstWalker < Walker
|
29
|
+
def walk_node(node)
|
31
30
|
call_node_walker(node)
|
32
31
|
node.each {|item| walk_node(item)} if node.is_a? Array
|
33
32
|
|
34
33
|
walk_children(node)
|
35
34
|
end
|
35
|
+
end
|
36
36
|
|
37
|
-
|
37
|
+
class ChildrenFirstWalker < Walker
|
38
|
+
def walk_node(node)
|
38
39
|
walk_children(node)
|
39
40
|
|
40
41
|
node.each {|item| walk_node(item)} if node.is_a? Array
|
@@ -81,6 +81,7 @@ class OptionsParser
|
|
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
83
|
Option.new(nil, 'only=CATEGORIES', nil, String, "Restrict export to given file categories (--only=list to list them)", :only),
|
84
|
+
Option.new('x', 'xml-file=PROJECT_XML', nil, String, "XML file to use instead of fetching it from Hiptest", :xml_file),
|
84
85
|
Option.new(nil, 'tests-only', false, nil, "(deprecated) alias for --only=tests", :tests_only),
|
85
86
|
Option.new(nil, 'actionwords-only', false, nil, "(deprecated) alias for --only=actionwords", :actionwords_only),
|
86
87
|
Option.new(nil, 'actionwords-signature', false, nil, "Export actionwords signature", :actionwords_signature),
|
@@ -177,7 +178,7 @@ end
|
|
177
178
|
class NodeRenderingContext
|
178
179
|
|
179
180
|
def initialize(properties)
|
180
|
-
# should contain :node, :path, :
|
181
|
+
# should contain :node, :path, :description, :indentation
|
181
182
|
@properties = OpenStruct.new(properties)
|
182
183
|
end
|
183
184
|
|
@@ -218,49 +219,49 @@ class TemplateFinder
|
|
218
219
|
@framework = framework
|
219
220
|
@overriden_templates = overriden_templates
|
220
221
|
@compiled_handlebars = {}
|
222
|
+
@template_path_by_name = {}
|
221
223
|
@forced_templates = forced_templates || {}
|
222
224
|
@fallback_template = fallback_template
|
223
225
|
@context = {indentation: indentation}
|
224
226
|
end
|
225
227
|
|
226
228
|
def dirs
|
227
|
-
dirs
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
229
|
+
@dirs ||= begin
|
230
|
+
search_dirs = []
|
231
|
+
search_dirs << "#{language}/#{framework}" if framework
|
232
|
+
search_dirs << language
|
233
|
+
search_dirs << "common"
|
234
|
+
search_dirs.map! { |path| "#{hiptest_publisher_path}/lib/templates/#{path}" }
|
235
|
+
|
236
|
+
search_dirs.unshift(overriden_templates) if overriden_templates
|
237
|
+
search_dirs
|
238
|
+
end
|
235
239
|
end
|
236
240
|
|
237
|
-
def get_compiled_handlebars(
|
238
|
-
|
241
|
+
def get_compiled_handlebars(template_name)
|
242
|
+
template_path = get_template_path(template_name)
|
243
|
+
@compiled_handlebars[template_path] ||= handlebars.compile(File.read(template_path))
|
239
244
|
end
|
240
245
|
|
241
|
-
def get_template_by_name(name
|
246
|
+
def get_template_by_name(name)
|
242
247
|
return if name.nil?
|
243
|
-
|
244
|
-
|
245
|
-
template_path
|
246
|
-
|
247
|
-
|
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)
|
248
|
+
name = forced_templates.fetch(name, name)
|
249
|
+
dirs.each do |path|
|
250
|
+
template_path = File.join(path, "#{name}.hbs")
|
251
|
+
return template_path if File.file?(template_path)
|
252
|
+
end
|
253
|
+
nil
|
251
254
|
end
|
252
255
|
|
253
|
-
def
|
254
|
-
|
255
|
-
|
256
|
-
get_compiled_handlebars(template).call(render_context)
|
257
|
-
else
|
258
|
-
raise ArgumentError.new("no template with name #{template_name}")
|
256
|
+
def get_template_path(template_name)
|
257
|
+
unless @template_path_by_name.has_key?(template_name)
|
258
|
+
@template_path_by_name[template_name] = get_template_by_name(template_name) || get_template_by_name(@fallback_template)
|
259
259
|
end
|
260
|
+
@template_path_by_name[template_name] or raise ArgumentError.new("no template with name #{template_name}")
|
260
261
|
end
|
261
262
|
|
262
263
|
def register_partials
|
263
|
-
dirs.
|
264
|
+
dirs.reverse_each do |path|
|
264
265
|
next unless File.directory?(path)
|
265
266
|
Dir.entries(path).select do |file_name|
|
266
267
|
file_path = File.join(path, file_name)
|
@@ -345,10 +346,6 @@ class LanguageGroupConfig
|
|
345
346
|
)
|
346
347
|
end
|
347
348
|
|
348
|
-
def template_dirs
|
349
|
-
template_finder.dirs
|
350
|
-
end
|
351
|
-
|
352
349
|
def each_node_rendering_context(project)
|
353
350
|
return to_enum(:each_node_rendering_context, project) unless block_given?
|
354
351
|
nodes(project).each do |node|
|
@@ -372,12 +369,9 @@ class LanguageGroupConfig
|
|
372
369
|
NodeRenderingContext.new(
|
373
370
|
path: path,
|
374
371
|
indentation: indentation,
|
375
|
-
template_dirs: template_dirs,
|
376
372
|
template_finder: template_finder,
|
377
|
-
forced_templates: forced_templates,
|
378
373
|
description: description,
|
379
374
|
node: node,
|
380
|
-
fallback_template: @language_group_params[:fallback_template],
|
381
375
|
call_prefix: @language_group_params[:call_prefix],
|
382
376
|
package: @language_group_params[:package],
|
383
377
|
)
|
@@ -2,7 +2,7 @@ require 'hiptest-publisher/nodes_walker'
|
|
2
2
|
|
3
3
|
module Hiptest
|
4
4
|
module Nodes
|
5
|
-
class ParameterTypeAdder <
|
5
|
+
class ParameterTypeAdder < ParentFirstWalker
|
6
6
|
attr_reader :call_types
|
7
7
|
|
8
8
|
def self.add(project)
|
@@ -12,10 +12,6 @@ module Hiptest
|
|
12
12
|
Hiptest::Nodes::TypeWriter.new(walker.call_types).walk_node(project)
|
13
13
|
end
|
14
14
|
|
15
|
-
def initialize
|
16
|
-
super(:parent_first)
|
17
|
-
end
|
18
|
-
|
19
15
|
def walk_project(project)
|
20
16
|
@call_types = CallTypes.new
|
21
17
|
end
|
@@ -41,16 +37,17 @@ module Hiptest
|
|
41
37
|
private
|
42
38
|
|
43
39
|
def get_literal_values(node)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
values = []
|
41
|
+
node.each_sub_nodes(StringLiteral, NumericLiteral, BooleanLiteral) do |literal|
|
42
|
+
values << [literal.class, literal.children[:value]]
|
43
|
+
end
|
44
|
+
values << [NullLiteral, nil] if values.empty?
|
45
|
+
values
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
51
|
-
class TypeWriter <
|
49
|
+
class TypeWriter < ParentFirstWalker
|
52
50
|
def initialize(call_types)
|
53
|
-
super(:parent_first)
|
54
51
|
@call_types = call_types
|
55
52
|
@callable_item_name = nil
|
56
53
|
end
|
@@ -79,7 +76,7 @@ module Hiptest
|
|
79
76
|
end
|
80
77
|
|
81
78
|
def add_callable_item(name)
|
82
|
-
@callable_items[name] = {} unless @callable_items.
|
79
|
+
@callable_items[name] = {} unless @callable_items.has_key?(name)
|
83
80
|
select_callable_item(name)
|
84
81
|
end
|
85
82
|
|
@@ -94,7 +91,7 @@ module Hiptest
|
|
94
91
|
end
|
95
92
|
|
96
93
|
def type_of(item_name, parameter_name)
|
97
|
-
return unless @callable_items.
|
94
|
+
return unless @callable_items.has_key?(item_name)
|
98
95
|
parameter = @callable_items[item_name][parameter_name]
|
99
96
|
|
100
97
|
return :String if parameter.nil? || parameter[:values].empty?
|
@@ -104,7 +101,7 @@ module Hiptest
|
|
104
101
|
private
|
105
102
|
|
106
103
|
def add_parameter(name)
|
107
|
-
return if @current.
|
104
|
+
return if @current.has_key?(name)
|
108
105
|
@current[name] = {default: nil, values: []}
|
109
106
|
end
|
110
107
|
|
@@ -136,4 +133,4 @@ module Hiptest
|
|
136
133
|
end
|
137
134
|
end
|
138
135
|
end
|
139
|
-
end
|
136
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module Hiptest
|
2
2
|
module Nodes
|
3
|
-
class ParentAdder <
|
3
|
+
class ParentAdder < ParentFirstWalker
|
4
4
|
def self.add(project)
|
5
|
-
Hiptest::Nodes::ParentAdder.new
|
5
|
+
Hiptest::Nodes::ParentAdder.new.walk_node(project)
|
6
6
|
end
|
7
7
|
|
8
8
|
def walk_node(node)
|
9
9
|
super(node)
|
10
10
|
return unless node.is_a? Hiptest::Nodes::Node
|
11
11
|
|
12
|
-
node.
|
12
|
+
node.each_direct_children {|child|
|
13
13
|
child.parent ||= node
|
14
14
|
}
|
15
15
|
end
|
@@ -4,7 +4,7 @@ module Hiptest
|
|
4
4
|
{
|
5
5
|
:has_parameters? => !item.children[:parameters].empty?,
|
6
6
|
:has_tags? => !item.children[:tags].empty?,
|
7
|
-
:has_step? =>
|
7
|
+
:has_step? => has_step?(item),
|
8
8
|
:is_empty? => item.children[:body].empty?,
|
9
9
|
:declared_variables => item.declared_variables_names
|
10
10
|
}
|
@@ -38,7 +38,7 @@ module Hiptest
|
|
38
38
|
{
|
39
39
|
:has_parameters? => false,
|
40
40
|
:has_tags? => !test.children[:tags].empty?,
|
41
|
-
:has_step? =>
|
41
|
+
:has_step? => has_step?(test),
|
42
42
|
:is_empty? => test.children[:body].empty?,
|
43
43
|
:has_datasets? => false,
|
44
44
|
:project_name => test.parent.parent.children[:name],
|
@@ -89,5 +89,14 @@ module Hiptest
|
|
89
89
|
:variable_names => variable_names
|
90
90
|
}
|
91
91
|
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def has_step?(item)
|
96
|
+
item.each_sub_nodes do |node|
|
97
|
+
return true if node.is_a?(Hiptest::Nodes::Step)
|
98
|
+
end
|
99
|
+
false
|
100
|
+
end
|
92
101
|
end
|
93
|
-
end
|
102
|
+
end
|
@@ -6,7 +6,7 @@ require 'hiptest-publisher/handlebars_helper'
|
|
6
6
|
require 'hiptest-publisher/render_context_maker'
|
7
7
|
|
8
8
|
module Hiptest
|
9
|
-
class Renderer < Hiptest::Nodes::
|
9
|
+
class Renderer < Hiptest::Nodes::ChildrenFirstWalker
|
10
10
|
attr_reader :rendered
|
11
11
|
include RenderContextMaker
|
12
12
|
|
@@ -17,7 +17,6 @@ module Hiptest
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def initialize(context)
|
20
|
-
super(:children_first)
|
21
20
|
@rendered = {}
|
22
21
|
@context = context
|
23
22
|
@template_finder = context.template_finder
|
@@ -41,20 +40,7 @@ module Hiptest
|
|
41
40
|
render_context[:rendered_children] = @rendered_children
|
42
41
|
render_context[:context] = @context
|
43
42
|
|
44
|
-
|
45
|
-
if template
|
46
|
-
@template_finder.get_compiled_handlebars(template).call(render_context)
|
47
|
-
else
|
48
|
-
raise ArgumentError.new("no template for node #{node.class}")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def normalized_name(node)
|
53
|
-
normalized_name = node.class.name.split('::').last.downcase
|
54
|
-
unless @context[:forced_templates][normalized_name].nil?
|
55
|
-
normalized_name = @context[:forced_templates][normalized_name]
|
56
|
-
end
|
57
|
-
normalized_name
|
43
|
+
@template_finder.get_compiled_handlebars(node.kind).call(render_context)
|
58
44
|
end
|
59
45
|
end
|
60
46
|
end
|
@@ -33,18 +33,25 @@ def make_filter(options)
|
|
33
33
|
tags = options.filter_tags.split(',').map {|tag| "filter[]=tag:#{tag}"}
|
34
34
|
|
35
35
|
filter = (ids + tags).join("&")
|
36
|
-
filter.empty? ? '' : "
|
36
|
+
filter.empty? ? '' : "?#{filter}"
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
url = "#{url}/#{options.leafless_export ? 'leafless_tests' : 'project'}?future=1#{make_filter(options)}"
|
39
|
+
def make_url(options)
|
40
|
+
if push?(options)
|
41
|
+
"#{options.site}/import_test_results/#{options.token}/#{options.push_format}"
|
43
42
|
else
|
44
|
-
|
43
|
+
base_url = "#{options.site}/publication/#{options.token}"
|
44
|
+
if options.test_run_id.nil? || options.test_run_id.empty?
|
45
|
+
"#{base_url}/#{options.leafless_export ? 'leafless_tests' : 'project'}#{make_filter(options)}"
|
46
|
+
else
|
47
|
+
"#{base_url}/test_run/#{options.test_run_id}"
|
48
|
+
end
|
45
49
|
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def fetch_project_export(options)
|
53
|
+
url = make_url(options)
|
46
54
|
|
47
|
-
puts "URL: #{url}".white if options.verbose
|
48
55
|
open(url, "User-Agent" => 'Ruby/hiptest-publisher', :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)
|
49
56
|
end
|
50
57
|
|
@@ -63,14 +70,25 @@ def show_status_message(message, status=nil)
|
|
63
70
|
output.print "[#{status_icon}] #{message}\r#{line_end}"
|
64
71
|
end
|
65
72
|
|
66
|
-
def
|
67
|
-
|
73
|
+
def with_status_message(message, &blk)
|
74
|
+
show_status_message message
|
75
|
+
status = :success
|
76
|
+
yield
|
77
|
+
rescue
|
78
|
+
status = :failure
|
79
|
+
raise
|
80
|
+
ensure
|
81
|
+
show_status_message message, status
|
82
|
+
end
|
83
|
+
|
84
|
+
def push?(options)
|
85
|
+
options.push && !options.push.empty?
|
68
86
|
end
|
69
87
|
|
70
88
|
def push_results(options)
|
71
89
|
# Code from: https://github.com/nicksieger/multipart-post
|
72
|
-
url = URI.parse(
|
73
|
-
use_ssl =
|
90
|
+
url = URI.parse(make_url(options))
|
91
|
+
use_ssl = (url.scheme == 'https')
|
74
92
|
|
75
93
|
File.open(options.push) do |results|
|
76
94
|
req = Net::HTTP::Post::Multipart.new(url.path, "file" => UploadIO.new(results, "text", "results.tap"))
|
@@ -213,7 +213,7 @@ module Hiptest
|
|
213
213
|
|
214
214
|
def build_scenarioSnapshot(scs)
|
215
215
|
scenario = build_scenario(scs)
|
216
|
-
datasets = scenario.
|
216
|
+
datasets = scenario.each_sub_nodes(Hiptest::Nodes::Dataset).to_a
|
217
217
|
|
218
218
|
if datasets.empty?
|
219
219
|
scenario.set_uid(css_first_content(scs, 'testSnapshot > uid'))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiptest-publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiptest R&D
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|