hiptest-publisher 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8049f09f41133f11370cfd75ae4db12158427869
4
- data.tar.gz: 538b61a5050e9fecb13b4887a89ada543c7bc632
3
+ metadata.gz: 2c3138437a3c18c0d3e956c485f2f085d1fd383b
4
+ data.tar.gz: dedf8903cf303e473351f27c0f69b07bf1d9f415
5
5
  SHA512:
6
- metadata.gz: 21554b0949d973c98299609b2636ea7bdfe7702ff53a72b073bc6764d5677d1a2d55037138729127cf08123ca53b38520f5b1ffe4e4d7493ae8f68ed25fb15e1
7
- data.tar.gz: b68c6cab3d17e151d1aaa988ec893a3cc1a5584d11d60b054c408a662dde9f79c6a0e2ea2cc99e5d691e6e9206ca5f05c95828a308068e832f542b81f5576504
6
+ metadata.gz: 14ff2e2432c753bf6cd200a0e32e5e9f66f2d307d51eb29fe35a6fb1a250524257c354a7b5d7d806ec7b3a6a152c9c0a7b2e0b6a8e71b903123b0a4e34f44a68
7
+ data.tar.gz: 4cef4b9b90fbc1a85543531ae28a75ec80a0e052a71eeed24162f46cd0073d1cd2c225bf271ce5e3f24197f4c5b502e9bdda1d0a12dec0c6da6a67293f01364f
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -24,21 +24,7 @@ module Hiptest
24
24
  @exit_on_bad_arguments = exit_on_bad_arguments
25
25
  end
26
26
 
27
- def normalize_cli_options!
28
- modified_cli_options = @cli_options.clone
29
- if @cli_options.actionwords_only
30
- modified_cli_options.only = 'actionwords'
31
- elsif @cli_options.tests_only
32
- modified_cli_options.only = 'tests'
33
- end
34
- if @cli_options.with_folders && @cli_options.language == 'cucumber'
35
- modified_cli_options.framework = 'folders_as_features'
36
- end
37
- @cli_options = modified_cli_options
38
- end
39
-
40
27
  def run
41
- normalize_cli_options!
42
28
  puts "URL: #{make_url(@cli_options)}".white if @cli_options.verbose
43
29
  begin
44
30
  CliOptionsChecker.new(@cli_options, reporter).check!
@@ -17,9 +17,10 @@ class ConsoleFormatter
17
17
  puts line.yellow
18
18
  end
19
19
 
20
- def show_options(options)
20
+ def show_options(options, message = nil)
21
21
  return unless verbose
22
- puts "Running Hiptest-publisher #{hiptest_publisher_version} with:".yellow
22
+ message ||= "Running Hiptest-publisher #{hiptest_publisher_version} with:"
23
+ puts message.yellow
23
24
  options.each { |k, v| puts " - #{k}: #{v.inspect}".white }
24
25
  end
25
26
  end
@@ -13,8 +13,8 @@ class Reporter
13
13
  notify(:dump_error, error, message)
14
14
  end
15
15
 
16
- def show_options(options)
17
- notify(:show_options, options)
16
+ def show_options(options, message = nil)
17
+ notify(:show_options, options, message)
18
18
  end
19
19
 
20
20
  def notify(message, *args)
@@ -335,6 +335,11 @@ module Hiptest
335
335
  super()
336
336
  @children = {:actionwords => actionwords}
337
337
  mark_actionwords_for_implementation
338
+ index_actionwords
339
+ end
340
+
341
+ def find_actionword(name)
342
+ return @actionwords_index[name]
338
343
  end
339
344
 
340
345
  private
@@ -350,6 +355,14 @@ module Hiptest
350
355
  end
351
356
  end
352
357
  end
358
+
359
+ def index_actionwords
360
+ @actionwords_index = {}
361
+
362
+ @children[:actionwords].each do |aw|
363
+ @actionwords_index[aw.children[:name]] = aw
364
+ end
365
+ end
353
366
  end
354
367
 
355
368
  class Scenarios < Node
@@ -54,6 +54,47 @@ class Option
54
54
  end
55
55
  end
56
56
 
57
+ class CliOptions < OpenStruct
58
+ def initialize(hash=nil)
59
+ hash ||= {}
60
+ hash[:language] ||= ""
61
+ hash[:framework] ||= ""
62
+ super(__cli_args: Set.new, __config_args: Set.new, **hash)
63
+ end
64
+
65
+ def normalize!(reporter = nil)
66
+ modified_options = self.clone
67
+ if actionwords_only
68
+ modified_options.only = 'actionwords'
69
+ elsif tests_only
70
+ modified_options.only = 'tests'
71
+ end
72
+
73
+ if language.include?('-')
74
+ modified_options.language, modified_options.framework = language.split("-", 2)
75
+ elsif framework.empty?
76
+ # pick first framework for the language
77
+ _, frameworks = OptionsParser.languages.find do |language, frameworks|
78
+ language.downcase.gsub(' ', '') == self.language.downcase.gsub(' ', '')
79
+ end
80
+ if frameworks
81
+ modified_options.framework = frameworks.first.downcase
82
+ end
83
+ end
84
+
85
+ if self != modified_options
86
+ delta = modified_options.table.select do |key, value|
87
+ modified_options[key] != self[key]
88
+ end
89
+ marshal_load(modified_options.marshal_dump)
90
+ if reporter
91
+ reporter.show_options(delta, 'Options have been normalized. Values updated:')
92
+ end
93
+ return delta
94
+ end
95
+ end
96
+ end
97
+
57
98
  class OptionsParser
58
99
  def self.languages
59
100
  # First framework is default framework
@@ -103,7 +144,7 @@ class OptionsParser
103
144
  end
104
145
 
105
146
  def self.parse(args, reporter)
106
- options = OpenStruct.new(__cli_args: Set.new, __config_args: Set.new)
147
+ options = CliOptions.new
107
148
  opt_parser = OptionParser.new do |opts|
108
149
  opts.version = hiptest_publisher_version if hiptest_publisher_version
109
150
  opts.banner = "Usage: ruby publisher.rb [options]"
@@ -147,6 +188,7 @@ class OptionsParser
147
188
  FileConfigParser.update_options(options, reporter)
148
189
 
149
190
  reporter.show_options(options.marshal_dump)
191
+ options.normalize!(reporter)
150
192
  options
151
193
  end
152
194
 
@@ -438,18 +480,19 @@ class LanguageConfigParser
438
480
  end
439
481
 
440
482
  def self.config_path_for(cli_options)
441
- config_path = [
442
- "#{hiptest_publisher_path}/lib/config/#{cli_options.language}-#{cli_options.framework}.conf",
443
- "#{hiptest_publisher_path}/lib/config/#{cli_options.language}.conf",
444
- ].map do |path|
445
- File.expand_path(path) if File.file?(path)
446
- end.compact.first
447
- if config_path.nil?
448
- message = "cannot find configuration file in \"#{hiptest_publisher_path}/config\" for language #{cli_options.language.inspect}"
483
+ config_name = if cli_options.framework.empty?
484
+ "#{cli_options.language}.conf"
485
+ else
486
+ "#{cli_options.language}-#{cli_options.framework}.conf"
487
+ end
488
+ config_path = File.expand_path("#{hiptest_publisher_path}/lib/config/#{config_name.downcase}")
489
+ if !File.file?(config_path)
490
+ message = "cannot find configuration file in \"#{hiptest_publisher_path}/lib/config\""
491
+ message << " for language #{cli_options.language.inspect}"
449
492
  message << " and framework #{cli_options.framework.inspect}" unless cli_options.framework.to_s.empty?
450
493
  raise ArgumentError.new(message)
451
494
  end
452
- config_path
495
+ File.expand_path(config_path)
453
496
  end
454
497
 
455
498
  def group_names
@@ -21,14 +21,14 @@ module Hiptest
21
21
 
22
22
  def gather_scenarios_argument_types(project)
23
23
  project.children[:scenarios].children[:scenarios].each do |scenario|
24
- @call_types.add_callable_item(scenario.children[:name])
24
+ @call_types.add_callable_item(scenario.children[:name], Scenario)
25
25
  add_arguments_from(scenario.children[:datatable])
26
26
  end
27
27
  end
28
28
 
29
29
  def gather_call_argument_types(project)
30
30
  project.each_sub_nodes(Call) do |call|
31
- @call_types.add_callable_item(call.children[:actionword])
31
+ @call_types.add_callable_item(call.children[:actionword], Actionword)
32
32
  add_arguments_from(call)
33
33
  end
34
34
  end
@@ -36,7 +36,7 @@ module Hiptest
36
36
  def write_parameter_types(project)
37
37
  project.each_sub_nodes(Actionword, Scenario) do |callable_item|
38
38
  callable_item.each_sub_nodes(Parameter) do |parameter|
39
- parameter.children[:type] = @call_types.type_of(callable_item.children[:name], parameter.children[:name])
39
+ parameter.children[:type] = @call_types.type_of(callable_item.children[:name], parameter.children[:name], callable_item.class)
40
40
  end
41
41
  end
42
42
  end
@@ -66,7 +66,8 @@ module Hiptest
66
66
  @current_callable_item = nil
67
67
  end
68
68
 
69
- def add_callable_item(name)
69
+ def add_callable_item(item_name, item_type)
70
+ name = "#{item_type}-#{item_name}"
70
71
  @callable_items[name] ||= {}
71
72
  @current_callable_item = @callable_items[name]
72
73
  end
@@ -76,8 +77,9 @@ module Hiptest
76
77
  @current_callable_item[name][:types] << type
77
78
  end
78
79
 
79
- def type_of(item_name, parameter_name)
80
- callable_item = @callable_items[item_name]
80
+ def type_of(item_name, parameter_name, item_type)
81
+ name = "#{item_type}-#{item_name}"
82
+ callable_item = @callable_items[name]
81
83
  return :String if callable_item.nil?
82
84
  parameter = callable_item[parameter_name]
83
85
 
@@ -0,0 +1,85 @@
1
+ require 'hiptest-publisher/nodes'
2
+
3
+ module Hiptest
4
+ # Builds a graph based on calls and computes
5
+ # longest path from the root.
6
+
7
+ class ProjectGrapher
8
+ attr_reader :graph, :distance_index
9
+
10
+ def initialize(project)
11
+ @project = project
12
+ @graph = {}
13
+ end
14
+
15
+ def compute_graph
16
+ add_nodes
17
+ add_root
18
+ end
19
+
20
+ def add_distances
21
+ add_node_weight(@graph[:root], [:root])
22
+ end
23
+
24
+ def index_by_distances
25
+ @distance_index = Hash.new { |hash, key| hash[key] = [] }
26
+ @graph.values.each do |value|
27
+ @distance_index[value[:from_root]] << value[:item] unless value[:item].nil?
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def add_nodes
34
+ @project.each_sub_nodes(Hiptest::Nodes::Scenario, Hiptest::Nodes::Actionword) do |item|
35
+ name = node_name(item)
36
+ @graph[name] = {
37
+ name: name,
38
+ item: item,
39
+ calls: [],
40
+ from_root: -1
41
+ }
42
+
43
+ item.each_sub_nodes(Hiptest::Nodes::Call) do |call|
44
+ aw_name = node_name(call.children[:actionword], Hiptest::Nodes::Actionword)
45
+ @graph[name][:calls] << aw_name
46
+ end
47
+ end
48
+ end
49
+
50
+ def add_root
51
+ @graph[:root] = {
52
+ calls: [],
53
+ from_root: 0
54
+ }
55
+
56
+ @project.each_sub_nodes(Hiptest::Nodes::Scenario) do |scenario|
57
+ @graph[:root][:calls] << node_name(scenario)
58
+ end
59
+ end
60
+
61
+ def add_node_weight(node, path)
62
+ path << node[:name]
63
+
64
+ node[:calls].map do |item_name|
65
+ next if path.include?(item_name)
66
+
67
+ called = @graph[item_name]
68
+ next if called.nil?
69
+
70
+ if called[:from_root] <= node[:from_root]
71
+ called[:from_root] = node[:from_root] + 1
72
+ add_node_weight(called, path)
73
+ end
74
+ end
75
+
76
+ path.pop
77
+ end
78
+
79
+ def node_name(node, cls = nil)
80
+ cls ||= node.class
81
+ name = node.is_a?(Hiptest::Nodes::Node) ? node.children[:name] : node
82
+ "#{cls}-#{name}"
83
+ end
84
+ end
85
+ end
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.2
4
+ version: 0.7.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-11-25 00:00:00.000000000 Z
11
+ date: 2015-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -239,17 +239,17 @@ extra_rdoc_files:
239
239
  files:
240
240
  - README.md
241
241
  - bin/hiptest-publisher
242
- - lib/config/csharp.conf
242
+ - lib/config/csharp-nunit.conf
243
243
  - lib/config/cucumber-java.conf
244
- - lib/config/cucumber.conf
244
+ - lib/config/cucumber-ruby.conf
245
+ - lib/config/java-junit.conf
245
246
  - lib/config/java-testng.conf
246
- - lib/config/java.conf
247
247
  - lib/config/javascript-jasmine.conf
248
- - lib/config/javascript.conf
249
- - lib/config/python.conf
248
+ - lib/config/javascript-qunit.conf
249
+ - lib/config/python-unittest.conf
250
250
  - lib/config/robotframework.conf
251
251
  - lib/config/ruby-minitest.conf
252
- - lib/config/ruby.conf
252
+ - lib/config/ruby-rspec.conf
253
253
  - lib/config/seleniumide.conf
254
254
  - lib/config/specflow.conf
255
255
  - lib/hiptest-publisher.rb
@@ -265,6 +265,7 @@ files:
265
265
  - lib/hiptest-publisher/options_parser.rb
266
266
  - lib/hiptest-publisher/parameter_type_adder.rb
267
267
  - lib/hiptest-publisher/parent_adder.rb
268
+ - lib/hiptest-publisher/project_grapher.rb
268
269
  - lib/hiptest-publisher/render_context_maker.rb
269
270
  - lib/hiptest-publisher/renderer.rb
270
271
  - lib/hiptest-publisher/signature_differ.rb
@@ -527,7 +528,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
527
528
  version: '0'
528
529
  requirements: []
529
530
  rubyforge_project:
530
- rubygems_version: 2.4.6
531
+ rubygems_version: 2.4.5
531
532
  signing_key:
532
533
  specification_version: 4
533
534
  summary: Export your tests from Hiptest into executable tests.