hiptest-publisher 0.7.3 → 0.7.4
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 +1 -1
- data/lib/hiptest-publisher/cli_options_checker.rb +25 -3
- data/lib/hiptest-publisher/options_parser.rb +39 -6
- data/lib/hiptest-publisher/parameter_type_adder.rb +37 -13
- data/lib/hiptest-publisher/project_grapher.rb +16 -7
- data/lib/hiptest-publisher/utils.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 148f9a7098c7adfccab35b99273a86acefeb3a36
|
4
|
+
data.tar.gz: 45f5d9873598afb71725f32f36050acd76291951
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72a2707a042b4c31fef0569183d7c210a53515c343cf5135e3bdee54fc8e72bd102a37452afe82cb269e19a4f7a9e09166c8fec4397c2dcdcf9f69219bb29862
|
7
|
+
data.tar.gz: 76884068c660e72d97eca82d5f57b183667f28b484a199aa4c69cd35517cbec1d595b91fb6ff8cd80eddbab3a5672ba949e0e3bbe956ac033ce21b1fd5b046af
|
data/lib/hiptest-publisher.rb
CHANGED
@@ -58,7 +58,7 @@ module Hiptest
|
|
58
58
|
return
|
59
59
|
end
|
60
60
|
|
61
|
-
if @cli_options.actionwords_diff
|
61
|
+
if @cli_options.actionwords_diff?
|
62
62
|
show_actionwords_diff
|
63
63
|
return
|
64
64
|
end
|
@@ -59,7 +59,7 @@ module Hiptest
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# actionwords signature file
|
62
|
-
if cli_options.actionwords_diff
|
62
|
+
if cli_options.actionwords_diff?
|
63
63
|
actionwords_signature_file = Pathname.new(cli_options.output_directory).join("actionwords_signature.yaml")
|
64
64
|
if actionwords_signature_file.directory?
|
65
65
|
raise CliOptionError, "Bad Action Words signature file: the file \"#{actionwords_signature_file.realpath}\" is a directory"
|
@@ -86,13 +86,26 @@ module Hiptest
|
|
86
86
|
raise CliOptionError, "Invalid format --test-run-id=\"#{@cli_options.test_run_id}\": the test run id must be numeric"
|
87
87
|
end
|
88
88
|
|
89
|
-
# language
|
89
|
+
# language and --only
|
90
90
|
if present?(cli_options.language)
|
91
91
|
begin
|
92
|
-
LanguageConfigParser.
|
92
|
+
language_config_parser = LanguageConfigParser.new(cli_options)
|
93
93
|
rescue ArgumentError => err
|
94
94
|
raise CliOptionError, err.message
|
95
95
|
end
|
96
|
+
|
97
|
+
if present?(cli_options.only)
|
98
|
+
if language_config_parser.filtered_group_names != cli_options.groups_to_keep
|
99
|
+
unknown_categories = cli_options.groups_to_keep - language_config_parser.group_names
|
100
|
+
if unknown_categories.length == 1
|
101
|
+
message = "the category #{formatted_categories(unknown_categories)} does not exist"
|
102
|
+
else
|
103
|
+
message = "the categories #{formatted_categories(unknown_categories)} do not exist"
|
104
|
+
end
|
105
|
+
raise CliOptionError, "Error with --only: #{message} for language #{cli_options.language_framework}. " +
|
106
|
+
"Available categories are #{formatted_categories(language_config_parser.group_names)}."
|
107
|
+
end
|
108
|
+
end
|
96
109
|
end
|
97
110
|
end
|
98
111
|
|
@@ -118,6 +131,15 @@ module Hiptest
|
|
118
131
|
!absent?(arg)
|
119
132
|
end
|
120
133
|
|
134
|
+
def formatted_categories(categories)
|
135
|
+
formatted_categories = categories.map(&:inspect)
|
136
|
+
if formatted_categories.length == 1
|
137
|
+
formatted_categories.first
|
138
|
+
else
|
139
|
+
formatted_categories[0...-1].join(", ") + " and " + formatted_categories.last
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
121
143
|
def first_existing_parent(path)
|
122
144
|
pathname = Pathname.new(path)
|
123
145
|
while !pathname.exist?
|
@@ -62,6 +62,22 @@ class CliOptions < OpenStruct
|
|
62
62
|
super(__cli_args: Set.new, __config_args: Set.new, **hash)
|
63
63
|
end
|
64
64
|
|
65
|
+
def actionwords_diff?
|
66
|
+
actionwords_diff || aw_deleted || aw_created || aw_renamed || aw_signature_changed
|
67
|
+
end
|
68
|
+
|
69
|
+
def language_framework
|
70
|
+
if framework.empty?
|
71
|
+
language
|
72
|
+
else
|
73
|
+
"#{language}-#{framework}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def groups_to_keep
|
78
|
+
only.split(",") if only
|
79
|
+
end
|
80
|
+
|
65
81
|
def normalize!(reporter = nil)
|
66
82
|
modified_options = self.clone
|
67
83
|
if actionwords_only
|
@@ -329,6 +345,8 @@ class LanguageGroupConfig
|
|
329
345
|
@with_folders = user_params.with_folders
|
330
346
|
@leafless_export = user_params.leafless_export
|
331
347
|
@language_group_params = language_group_params || {}
|
348
|
+
|
349
|
+
@user_params = user_params
|
332
350
|
end
|
333
351
|
|
334
352
|
def [](key)
|
@@ -402,7 +420,7 @@ class LanguageGroupConfig
|
|
402
420
|
end
|
403
421
|
|
404
422
|
def build_node_rendering_context(node)
|
405
|
-
path = File.join(
|
423
|
+
path = File.join(language_group_output_directory, output_file(node))
|
406
424
|
|
407
425
|
if splitted_files?
|
408
426
|
description = "#{singularize(node_name)} \"#{node.children[:name]}\""
|
@@ -422,6 +440,10 @@ class LanguageGroupConfig
|
|
422
440
|
)
|
423
441
|
end
|
424
442
|
|
443
|
+
def language_group_output_directory
|
444
|
+
@user_params["#{@language_group_params[:group_name]}_output_dir"] || @output_directory
|
445
|
+
end
|
446
|
+
|
425
447
|
def output_directory(node)
|
426
448
|
folder = node.folder
|
427
449
|
hierarchy = []
|
@@ -502,9 +524,8 @@ class LanguageConfigParser
|
|
502
524
|
end
|
503
525
|
|
504
526
|
def filtered_group_names
|
505
|
-
if @cli_options.
|
506
|
-
|
507
|
-
group_names.select {|group_name| groups_to_keep.include?(group_name)}
|
527
|
+
if @cli_options.groups_to_keep
|
528
|
+
group_names.select {|group_name| @cli_options.groups_to_keep.include?(group_name)}
|
508
529
|
else
|
509
530
|
group_names
|
510
531
|
end
|
@@ -534,12 +555,24 @@ class LanguageConfigParser
|
|
534
555
|
end
|
535
556
|
|
536
557
|
def make_language_group_config group_name
|
558
|
+
# List of options that can be set in the config file but not in command line
|
559
|
+
non_visible_options = {
|
560
|
+
:package => @cli_options.package,
|
561
|
+
:namespace => @cli_options.namespace,
|
562
|
+
:test_export_dir => @cli_options.test_export_dir,
|
563
|
+
:tests_ouput_dir => @cli_options.tests_ouput_dir,
|
564
|
+
:features_output_directory => @cli_options.features_output_directory,
|
565
|
+
:step_definitions_output_directory => @cli_options.step_definitions_output_directory,
|
566
|
+
:actionwords_output_directory => @cli_options.actionwords_output_directory
|
567
|
+
}
|
568
|
+
|
537
569
|
language_group_params = group_config('_common')
|
538
570
|
language_group_params.merge!(group_config(group_name))
|
539
571
|
language_group_params[:group_name] = group_name
|
540
|
-
language_group_params[:package] = @cli_options.package if @cli_options.package
|
541
|
-
language_group_params[:namespace] = @cli_options.namespace if @cli_options.namespace
|
542
572
|
|
573
|
+
non_visible_options.each do |key, value|
|
574
|
+
language_group_params[key] = value if value
|
575
|
+
end
|
543
576
|
|
544
577
|
unless @cli_options.overriden_templates.nil? || @cli_options.overriden_templates.empty?
|
545
578
|
language_group_params[:overriden_templates] = @cli_options.overriden_templates
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'hiptest-publisher/nodes_walker'
|
2
|
+
require 'hiptest-publisher/project_grapher'
|
3
|
+
|
2
4
|
|
3
5
|
module Hiptest
|
4
6
|
module Nodes
|
@@ -15,8 +17,17 @@ module Hiptest
|
|
15
17
|
|
16
18
|
def process(project)
|
17
19
|
gather_scenarios_argument_types(project)
|
18
|
-
|
19
|
-
|
20
|
+
|
21
|
+
# To have the most accurate type, the closest calls must be computed
|
22
|
+
# first, and deepest calls must be computed last (because they depend
|
23
|
+
# on previous calls types).
|
24
|
+
distances_index = Hiptest::ProjectGrapher.distances_index(project)
|
25
|
+
distances_index.each_value do |items| # distances_index items are sorted by distance, from closest to deepest
|
26
|
+
items.each do |item|
|
27
|
+
write_parameter_types_to_item(item)
|
28
|
+
gather_call_argument_types(item)
|
29
|
+
end
|
30
|
+
end
|
20
31
|
end
|
21
32
|
|
22
33
|
def gather_scenarios_argument_types(project)
|
@@ -26,38 +37,50 @@ module Hiptest
|
|
26
37
|
end
|
27
38
|
end
|
28
39
|
|
29
|
-
def gather_call_argument_types(
|
30
|
-
|
40
|
+
def gather_call_argument_types(node)
|
41
|
+
node.each_sub_nodes(Call) do |call|
|
31
42
|
@call_types.add_callable_item(call.children[:actionword], Actionword)
|
32
|
-
add_arguments_from(call)
|
43
|
+
add_arguments_from(call, node)
|
33
44
|
end
|
34
45
|
end
|
35
46
|
|
36
|
-
def
|
37
|
-
|
38
|
-
callable_item.
|
39
|
-
parameter.children[:type] = @call_types.type_of(callable_item.children[:name], parameter.children[:name], callable_item.class)
|
40
|
-
end
|
47
|
+
def write_parameter_types_to_item(callable_item)
|
48
|
+
callable_item.each_sub_nodes(Parameter) do |parameter|
|
49
|
+
parameter.children[:type] = @call_types.type_of(callable_item.children[:name], parameter.children[:name], callable_item.class)
|
41
50
|
end
|
42
51
|
end
|
43
52
|
|
44
|
-
def add_arguments_from(node)
|
53
|
+
def add_arguments_from(node, context = nil)
|
45
54
|
node.each_sub_nodes(Argument) do |argument|
|
46
|
-
@call_types.add_argument_type(argument.children[:name], get_type(argument))
|
55
|
+
@call_types.add_argument_type(argument.children[:name], get_type(argument, context))
|
47
56
|
end
|
48
57
|
end
|
49
58
|
|
50
59
|
private
|
51
60
|
|
52
|
-
def get_type(node)
|
61
|
+
def get_type(node, context = nil)
|
53
62
|
value = node.children[:value]
|
63
|
+
|
54
64
|
case value
|
55
65
|
when StringLiteral, Template then :String
|
56
66
|
when NumericLiteral then value.children[:value].include?(".") ? :float : :int
|
57
67
|
when BooleanLiteral then :bool
|
68
|
+
when Variable then get_var_value(value.children[:name], context)
|
58
69
|
else :null
|
59
70
|
end
|
60
71
|
end
|
72
|
+
|
73
|
+
def get_var_value(name, context)
|
74
|
+
return :null if context.nil? || context.children[:parameters].nil?
|
75
|
+
|
76
|
+
context.children[:parameters].each do |param|
|
77
|
+
if param.children[:name] == name
|
78
|
+
return param.children[:type] || :null
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
return :null
|
83
|
+
end
|
61
84
|
end
|
62
85
|
|
63
86
|
class CallTypes
|
@@ -81,6 +104,7 @@ module Hiptest
|
|
81
104
|
name = "#{item_type}-#{item_name}"
|
82
105
|
callable_item = @callable_items[name]
|
83
106
|
return :String if callable_item.nil?
|
107
|
+
|
84
108
|
parameter = callable_item[parameter_name]
|
85
109
|
|
86
110
|
return :String if parameter.nil?
|
@@ -7,6 +7,15 @@ module Hiptest
|
|
7
7
|
class ProjectGrapher
|
8
8
|
attr_reader :graph, :distance_index
|
9
9
|
|
10
|
+
def self.distances_index(project)
|
11
|
+
instance = ProjectGrapher.new(project)
|
12
|
+
instance.compute_graph
|
13
|
+
instance.add_distances
|
14
|
+
instance.index_by_distances
|
15
|
+
|
16
|
+
return instance.distance_index
|
17
|
+
end
|
18
|
+
|
10
19
|
def initialize(project)
|
11
20
|
@project = project
|
12
21
|
@graph = {}
|
@@ -23,8 +32,8 @@ module Hiptest
|
|
23
32
|
|
24
33
|
def index_by_distances
|
25
34
|
@distance_index = Hash.new { |hash, key| hash[key] = [] }
|
26
|
-
@graph.
|
27
|
-
@distance_index[value[:
|
35
|
+
@graph.each_value do |value|
|
36
|
+
@distance_index[value[:distance_from_root]] << value[:item] if value[:item]
|
28
37
|
end
|
29
38
|
end
|
30
39
|
|
@@ -37,7 +46,7 @@ module Hiptest
|
|
37
46
|
name: name,
|
38
47
|
item: item,
|
39
48
|
calls: [],
|
40
|
-
|
49
|
+
distance_from_root: -1
|
41
50
|
}
|
42
51
|
|
43
52
|
item.each_sub_nodes(Hiptest::Nodes::Call) do |call|
|
@@ -50,7 +59,7 @@ module Hiptest
|
|
50
59
|
def add_root
|
51
60
|
@graph[:root] = {
|
52
61
|
calls: [],
|
53
|
-
|
62
|
+
distance_from_root: 0
|
54
63
|
}
|
55
64
|
|
56
65
|
@project.each_sub_nodes(Hiptest::Nodes::Scenario) do |scenario|
|
@@ -61,14 +70,14 @@ module Hiptest
|
|
61
70
|
def add_node_weight(node, path)
|
62
71
|
path << node[:name]
|
63
72
|
|
64
|
-
node[:calls].
|
73
|
+
node[:calls].each do |item_name|
|
65
74
|
next if path.include?(item_name)
|
66
75
|
|
67
76
|
called = @graph[item_name]
|
68
77
|
next if called.nil?
|
69
78
|
|
70
|
-
if called[:
|
71
|
-
called[:
|
79
|
+
if called[:distance_from_root] <= node[:distance_from_root]
|
80
|
+
called[:distance_from_root] = node[:distance_from_root] + 1
|
72
81
|
add_node_weight(called, path)
|
73
82
|
end
|
74
83
|
end
|
@@ -15,12 +15,16 @@ rescue
|
|
15
15
|
File.read("#{hiptest_publisher_path}/VERSION").strip if File.exists?("#{hiptest_publisher_path}/VERSION")
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def pluralize_word(count, singular, plural=nil)
|
19
19
|
word = if count == 1
|
20
20
|
singular
|
21
21
|
else
|
22
22
|
"#{singular}s"
|
23
23
|
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def pluralize(count, singular, plural=nil)
|
27
|
+
word = pluralize_word(count, singular, plural)
|
24
28
|
"#{count} #{word}"
|
25
29
|
end
|
26
30
|
|
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.7.
|
4
|
+
version: 0.7.4
|
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-
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -528,7 +528,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
528
528
|
version: '0'
|
529
529
|
requirements: []
|
530
530
|
rubyforge_project:
|
531
|
-
rubygems_version: 2.4.
|
531
|
+
rubygems_version: 2.4.6
|
532
532
|
signing_key:
|
533
533
|
specification_version: 4
|
534
534
|
summary: Export your tests from Hiptest into executable tests.
|