rpruby 1.2 → 1.2.1

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
  SHA256:
3
- metadata.gz: 3b8f13e3e486b8415730e16049b1f0ade2428cccb2a7b92a44ea1748fa47a7e2
4
- data.tar.gz: ff5067bbb7032169fe4f1ad8cc36ed92a9b8497bff93c0c773ac1fc248869c6a
3
+ metadata.gz: a8ed2dd18dc52909d31abb5a494a7c1432d91e39504081394f01b9108d79fe4c
4
+ data.tar.gz: f7c9c08261a080ba3b7ff39d76cdec3d3873630c081e2c7f540bf4f29bd6c3b5
5
5
  SHA512:
6
- metadata.gz: 8c0c0efa258f623509930c08ce26d1dc3fa96b5110d4e43fa8ce5cb0f97804488a0c586f1a30067d530266e5e14c650c91fea4200262cdf844dfa6b6ed1accc8
7
- data.tar.gz: 5baef57e73d287b13070b4b8066348766aca27c4a508e5615a7754c0ad80cdc532dd7c5e75443faa0a076bdc53ae38f0515562ad5cf6c72bb416a4cf19063490
6
+ metadata.gz: 60f7db611f6b0300dc5484f40f3312d70fc750ad739df6c25e4a30cd5408015756cd8c2f1319c5f5d35eb5b6db1a9bd9d2cbee027e17fd0dd770a27881f40501
7
+ data.tar.gz: '080b621a3672b2d671603930473d4296ae5f16a0336ff52a67256064e25b3f14d314d683a7b1ccb09abbd84791b0bf5bc7b5c42dc1beef1e1b49b62f91a45058'
data/.DS_Store ADDED
Binary file
@@ -0,0 +1,16 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.7.3
14
+ bundler-cache: true
15
+ - name: Run the default task
16
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-07-28
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jayak8390@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rpruby.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
13
+
14
+ gem 'cucumber', '~> 8'
15
+
16
+ gem 'parallel_tests'
17
+
18
+ gem 'rubytree', git: 'https://github.com/razboev/RubyTree'
19
+
20
+ gem 'log4r'
21
+ gem 'logging'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Jayachandra Konduru(JC)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Rpruby
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rpruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rpruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rpruby
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rpruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rpruby/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Rpruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rpruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ lib = File.expand_path('lib', __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require "bundler/gem_tasks"
6
+ require "rspec/core/rake_task"
7
+
8
+ require 'rpruby/tasks'
9
+
10
+ RSpec::Core::RakeTask.new(:spec)
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "rpruby"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ uuid: 12345678-1234-1234-1234-123456789012
2
+ endpoint: https://localhost:8080
3
+ launch: example_launch_name
4
+ project: default_personal
5
+ attributes:
6
+ - key: build
7
+ value: '0.1'
8
+ - value: test
9
+ #tags: [tag1, tag2, tag3] - DEPRECATED. Use attributes instead
10
+ #formatter_modes: [skip_reporting_hierarchy]
11
+ #is_debug: true
12
+ #disable_ssl_verification: true
@@ -0,0 +1,87 @@
1
+ require_relative '../../rpruby'
2
+
3
+ CucumberMessagesVersion=[8,0,0]
4
+
5
+ module Rpruby
6
+ module Cucumber
7
+ class Formatter
8
+ # @api private
9
+ def initialize(config)
10
+ ENV['REPORT_PORTAL_USED'] = 'true'
11
+
12
+ setup_message_processing
13
+
14
+ @io = config.out_stream
15
+
16
+ @ast_lookup = if (::Cucumber::VERSION.split('.').map(&:to_i) <=> CucumberMessagesVersion) > 0
17
+ require 'cucumber/formatter/ast_lookup'
18
+ ::Cucumber::Formatter::AstLookup.new(config)
19
+ else
20
+ nil
21
+ end
22
+
23
+ %i[test_case_started test_case_finished test_step_started test_step_finished test_run_finished].each do |event_name|
24
+ config.on_event event_name do |event|
25
+ process_message(event_name, event)
26
+ end
27
+ end
28
+ config.on_event(:test_run_finished) { finish_message_processing }
29
+ end
30
+
31
+ def puts(message)
32
+ process_message(:puts, message)
33
+ @io.puts(message)
34
+ @io.flush
35
+ end
36
+
37
+ def embed(*args)
38
+ process_message(:embed, *args)
39
+ end
40
+
41
+ private
42
+
43
+ def report
44
+ if @ast_lookup.nil?
45
+ require_relative 'report'
46
+ @report ||= Rpruby::Cucumber::Report.new
47
+ else
48
+ require_relative 'messagesreport'
49
+ @report ||= Rpruby::Cucumber::MessagesReport.new(@ast_lookup)
50
+ end
51
+ end
52
+
53
+ def setup_message_processing
54
+ return if use_same_thread_for_reporting?
55
+
56
+ @queue = Queue.new
57
+ @thread = Thread.new do
58
+ loop do
59
+ method_arr = @queue.pop
60
+ report.public_send(*method_arr)
61
+ end
62
+ end
63
+ @thread.abort_on_exception = true
64
+ end
65
+
66
+ def finish_message_processing
67
+ return if use_same_thread_for_reporting?
68
+
69
+ sleep 0.03 while !@queue.empty? || @queue.num_waiting.zero? # TODO: how to interrupt launch if the user aborted execution
70
+ @thread.kill
71
+ end
72
+
73
+ def process_message(report_method_name, *method_args)
74
+ args = [report_method_name, *method_args, Rpruby.now]
75
+ if use_same_thread_for_reporting?
76
+ report.public_send(*args)
77
+ else
78
+ @queue.push(args)
79
+ end
80
+ end
81
+
82
+ def use_same_thread_for_reporting?
83
+ Rpruby::Settings.instance.formatter_modes.include?('use_same_thread_for_reporting')
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,224 @@
1
+ require 'cucumber/formatter/io'
2
+ require 'tree'
3
+ require 'securerandom'
4
+
5
+ require_relative '../../rpruby'
6
+ require_relative '../logging/logger'
7
+
8
+ module Rpruby
9
+ module Cucumber
10
+ # @api private
11
+ class MessagesReport
12
+ def parallel?
13
+ false
14
+ end
15
+
16
+ def attach_to_launch?
17
+ Rpruby::Settings.instance.formatter_modes.include?('attach_to_launch')
18
+ end
19
+
20
+ def initialize(ast_lookup)
21
+ @last_used_time = 0
22
+ @root_node = Tree::TreeNode.new('')
23
+ @parent_item_node = @root_node
24
+ @ast_lookup = ast_lookup
25
+ start_launch
26
+ end
27
+
28
+ def start_launch(desired_time = Rpruby.now)
29
+ if attach_to_launch?
30
+ Rpruby.launch_id =
31
+ if Rpruby::Settings.instance.launch_id
32
+ Rpruby::Settings.instance.launch_id
33
+ else
34
+ file_path = Rpruby::Settings.instance.file_with_launch_id || (Pathname(Dir.tmpdir) + 'rp_launch_id.tmp')
35
+ File.read(file_path)
36
+ end
37
+ $stdout.puts "Attaching to launch #{Rpruby.launch_id}"
38
+ else
39
+ description = Rpruby::Settings.instance.description
40
+ description ||= ARGV.map { |arg| arg.gsub(/rp_uuid=.+/, 'rp_uuid=[FILTERED]') }.join(' ')
41
+ Rpruby.start_launch(description, time_to_send(desired_time))
42
+ end
43
+ end
44
+
45
+ # TODO: time should be a required argument
46
+ def test_case_started(event, desired_time = Rpruby.now)
47
+ test_case = event.test_case
48
+ test_source = @ast_lookup.scenario_source(test_case).scenario
49
+ gherkin_source = @ast_lookup.gherkin_document(test_case.location.file)
50
+ if report_hierarchy? && !same_feature_as_previous_test_case?(gherkin_source)
51
+ end_feature(desired_time) unless @parent_item_node.is_root?
52
+ start_feature_with_parentage(gherkin_source, desired_time)
53
+ end
54
+
55
+ name = "#{test_source.keyword}: #{test_source.name}"
56
+ description = test_case.location.to_s
57
+ tags = test_case.tags.map(&:name)
58
+ type = :STEP
59
+
60
+ Rpruby.current_scenario = Rpruby::TestItem.new(name: name, type: type, id: nil, start_time: time_to_send(desired_time), description: description, closed: false, tags: tags)
61
+ scenario_node = Tree::TreeNode.new(SecureRandom.hex, Rpruby.current_scenario)
62
+ @parent_item_node << scenario_node
63
+ Rpruby.current_scenario.id = Rpruby.start_item(scenario_node)
64
+ end
65
+
66
+ def test_case_finished(event, desired_time = Rpruby.now)
67
+ result = event.result
68
+ status = result.to_sym
69
+ issue = nil
70
+ if %i[undefined pending].include?(status)
71
+ status = :failed
72
+ issue = result.message
73
+ end
74
+ Rpruby.finish_item(Rpruby.current_scenario, status, time_to_send(desired_time), issue)
75
+ Rpruby.current_scenario = nil
76
+ end
77
+
78
+ def test_step_started(event, desired_time = Rpruby.now)
79
+ test_step = event.test_step
80
+ if step?(test_step) # `after_test_step` is also invoked for hooks
81
+ step_source = step_source = @ast_lookup.step_source(test_step).step
82
+ message = "-- #{step_source.keyword}#{step_source.text} --"
83
+ if test_step.multiline_arg.doc_string?
84
+ message << %(\n"""\n#{test_step.multiline_arg.content}\n""")
85
+ elsif test_step.multiline_arg.data_table?
86
+ message << test_step.multiline_arg.raw.reduce("\n") { |acc, row| acc << "| #{row.join(' | ')} |\n" }
87
+ end
88
+ Rpruby.send_log(:trace, message, time_to_send(desired_time))
89
+ end
90
+ end
91
+
92
+ def test_step_finished(event, desired_time = Rpruby.now)
93
+ test_step = event.test_step
94
+ result = event.result
95
+ status = result.to_sym
96
+
97
+ if %i[failed pending undefined].include?(status)
98
+ exception_info = if %i[failed pending].include?(status)
99
+ ex = result.exception
100
+ format("%s: %s\n %s", ex.class.name, ex.message, ex.backtrace.join("\n "))
101
+ else
102
+ format("Undefined step: %s:\n%s", test_step.text, test_step.source.last.backtrace_line)
103
+ end
104
+ Rpruby.send_log(:error, exception_info, time_to_send(desired_time))
105
+ end
106
+
107
+ if status != :passed
108
+ log_level = status == :skipped ? :warn : :error
109
+ step_type = if step?(test_step)
110
+ 'Step'
111
+ else
112
+ # TODO: Find out what this looks like in Cucumber3, to try and track down
113
+ # how we ought to behave
114
+ hook_class_name = test_step.text
115
+ location = test_step.location.to_s
116
+ "#{hook_class_name} at `#{location}`"
117
+ end
118
+ Rpruby.send_log(log_level, "#{step_type} #{status}", time_to_send(desired_time))
119
+ end
120
+ end
121
+
122
+ def test_run_finished(_event, desired_time = Rpruby.now)
123
+ end_feature(desired_time) unless @parent_item_node.is_root?
124
+
125
+ unless attach_to_launch?
126
+ close_all_children_of(@root_node) # Folder items are closed here as they can't be closed after finishing a feature
127
+ time_to_send = time_to_send(desired_time)
128
+ Rpruby.finish_launch(time_to_send)
129
+ end
130
+ end
131
+
132
+ def puts(message, desired_time = Rpruby.now)
133
+ Rpruby.send_log(:info, message, time_to_send(desired_time))
134
+ end
135
+
136
+ def embed(path_or_src, mime_type, label, desired_time = Rpruby.now)
137
+ Rpruby.send_file(:info, path_or_src, label, time_to_send(desired_time), mime_type)
138
+ end
139
+
140
+ private
141
+
142
+ # Report Portal sorts logs by time. However, several logs might have the same time.
143
+ # So to get Report Portal sort them properly the time should be different in all logs related to the same item.
144
+ # And thus it should be stored.
145
+ # Only the last time needs to be stored as:
146
+ # * only one test framework process/thread may send data for a single Report Portal item
147
+ # * that process/thread can't start the next test until it's done with the previous one
148
+ def time_to_send(desired_time)
149
+ time_to_send = desired_time
150
+ if time_to_send <= @last_used_time
151
+ time_to_send = @last_used_time + 1
152
+ end
153
+ @last_used_time = time_to_send
154
+ end
155
+
156
+ def same_feature_as_previous_test_case?(gherkin_source)
157
+ @parent_item_node.name == gherkin_source.uri.split(File::SEPARATOR).last
158
+ end
159
+
160
+ def start_feature_with_parentage(gherkin_source, desired_time)
161
+ parent_node = @root_node
162
+ child_node = nil
163
+ feature = gherkin_source.feature
164
+ path_components = gherkin_source.uri.split(File::SEPARATOR)
165
+ path_components.each_with_index do |path_component, index|
166
+ child_node = parent_node[path_component]
167
+ unless child_node # if child node was not created yet
168
+ if index < path_components.size - 1
169
+ name = "Folder: #{path_component}"
170
+ description = nil
171
+ tags = []
172
+ type = :SUITE
173
+ else
174
+ name = "#{feature.keyword}: #{feature.name}"
175
+ description = gherkin_source.uri # TODO: consider adding feature description and comments
176
+ tags = feature.tags.map(&:name)
177
+ type = :TEST
178
+ end
179
+ # TODO: multithreading # Parallel formatter always executes scenarios inside the same feature in the same process
180
+ if parallel? &&
181
+ index < path_components.size - 1 && # is folder?
182
+ (id_of_created_item = Rpruby.item_id_of(name, parent_node)) # get id for folder from report portal
183
+ # get child id from other process
184
+ item = Rpruby::TestItem.new(name: name, type: type, id: id_of_created_item, start_time: time_to_send(desired_time), description: description, closed: false, tags: tags)
185
+ child_node = Tree::TreeNode.new(path_component, item)
186
+ parent_node << child_node
187
+ else
188
+ item = Rpruby::TestItem.new(name: name, type: type, id: nil, start_time: time_to_send(desired_time), description: description, closed: false, tags: tags)
189
+ child_node = Tree::TreeNode.new(path_component, item)
190
+ parent_node << child_node
191
+ item.id = Rpruby.start_item(child_node) # TODO: multithreading
192
+ end
193
+ end
194
+ parent_node = child_node
195
+ end
196
+ @parent_item_node = child_node
197
+ end
198
+
199
+ def end_feature(desired_time)
200
+ Rpruby.finish_item(@parent_item_node.content, nil, time_to_send(desired_time))
201
+ # Folder items can't be finished here because when the folder started we didn't track
202
+ # which features the folder contains.
203
+ # It's not easy to do it using Cucumber currently:
204
+ # https://github.com/cucumber/cucumber-ruby/issues/887
205
+ end
206
+
207
+ def close_all_children_of(root_node)
208
+ root_node.postordered_each do |node|
209
+ if !node.is_root? && !node.content.closed
210
+ Rpruby.finish_item(node.content)
211
+ end
212
+ end
213
+ end
214
+
215
+ def step?(test_step)
216
+ !test_step.hook?
217
+ end
218
+
219
+ def report_hierarchy?
220
+ !Rpruby::Settings.instance.formatter_modes.include?('skip_reporting_hierarchy')
221
+ end
222
+ end
223
+ end
224
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'formatter'
2
+ require_relative 'parallel_report'
3
+
4
+ module Rpruby
5
+ module Cucumber
6
+ class ParallelFormatter < Formatter
7
+ private
8
+
9
+ def report
10
+ @report ||= Rpruby::Cucumber::ParallelReport.new
11
+ end
12
+ end
13
+ end
14
+ end