allure-ruby-commons 2.13.5.rc.3 → 2.13.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0c7c6cb2ddafe344d7a59a771a4dcdc39b8a78b644206376012be9d4dc1a5c4
4
- data.tar.gz: 2ee7ec7bbb3e329574a37737bd86456bb51d86d826738296a10ddec3509fc934
3
+ metadata.gz: a51c9949322455ac55cd973f942ba0392f51171fad89f23d0e16cbe16224014b
4
+ data.tar.gz: 7b4c8ccfca17187f553e9f5192a19fbe23dc84c780b73d057a29da9eed92ed61
5
5
  SHA512:
6
- metadata.gz: 29df8dfe87a6e0b04806bc675b4bac14025a105cc6bcf046cc3a89b53c25bddce5bb75bb46868408feb6786e6476eb6d1aef8a49e7655e5b00007c07aabb9ed1
7
- data.tar.gz: ed580b0d2d76b7d672a25829d7697650ca3bde73b6877eec48c041aa8829a6d9296b4a7ce53ccf45cfa844a3b1a689e1422a65e809800d33300c50662a42e56b
6
+ metadata.gz: e71a93d78c8efdfd477953644f58a1495fa6baca06592ddd5206c4abfc088d292a8f3a61ae72fe98d4db589144d4c0c8194a18a9e675cbecaeeb98d80265079b
7
+ data.tar.gz: 6d44b2fed79aa4258cfca49e4f0bc709f2aef144292fa6760191772eae4d4a4b763510f9ded50c8b146df635a44d80bf6725ac059843839f030ecd649553ad2c
data/README.md CHANGED
@@ -35,6 +35,10 @@ Getting the configuration object:
35
35
  Allure.configuration
36
36
  ```
37
37
 
38
+ ### Log level
39
+
40
+ Log level can be also configured via environment variable `ALLURE_LOG_LEVEL` which accepts one of the following values: `DEBUG INFO WARN ERROR FATAL UNKNOWN`.
41
+
38
42
  ## Allure lifecycle
39
43
 
40
44
  Reports are built using API defined in AllureLifecycle class and using allure specific entities defined in models.
@@ -3,6 +3,7 @@
3
3
 
4
4
  require "require_all"
5
5
  require "uuid"
6
+
6
7
  require_rel "allure_ruby_commons/**/*rb"
7
8
 
8
9
  # Namespace for classes that handle allure report generation and different framework adaptors
@@ -169,7 +170,7 @@ module Allure
169
170
  lifecycle.start_test_step(StepResult.new(name: name, stage: Stage::RUNNING))
170
171
  yield
171
172
  lifecycle.update_test_step { |step| step.status = Status::PASSED }
172
- rescue => e
173
+ rescue StandardError => e
173
174
  lifecycle.update_test_step do |step|
174
175
  step.status = ResultUtils.status(e)
175
176
  step.status_details = ResultUtils.status_details(e)
@@ -5,13 +5,13 @@ require "forwardable"
5
5
 
6
6
  module Allure
7
7
  # Main class for creating and writing allure results
8
- class AllureLifecycle
8
+ class AllureLifecycle # rubocop:disable Metrics/ClassLength
9
9
  extend Forwardable
10
10
 
11
11
  def initialize
12
12
  @test_context = []
13
13
  @step_context = []
14
- @logger = Logger.new(STDOUT, level: Config.instance.logging_level)
14
+ @logger = Logger.new($stdout, level: Config.instance.logging_level)
15
15
  @file_writer = FileWriter.new
16
16
  end
17
17
 
@@ -22,6 +22,8 @@ module Allure
22
22
  # @return [Allure::TestResultContainer]
23
23
  def start_test_container(test_result_container)
24
24
  test_result_container.tap do |container|
25
+ logger.debug { "Starting test container: #{container.name}" }
26
+
25
27
  container.start = ResultUtils.timestamp
26
28
  @test_context.push(container)
27
29
  end
@@ -36,7 +38,7 @@ module Allure
36
38
  # @return [void]
37
39
  def update_test_container
38
40
  unless current_test_result_container
39
- return logger.error("Could not update test container, no container is running.")
41
+ return logger.error { "Could not update test container, no container is running." }
40
42
  end
41
43
 
42
44
  yield(current_test_result_container)
@@ -46,10 +48,11 @@ module Allure
46
48
  # @return [void]
47
49
  def stop_test_container
48
50
  unless current_test_result_container
49
- return logger.error("Could not stop test container, no container is running.")
51
+ return logger.error { "Could not stop test container, no container is running." }
50
52
  end
51
53
 
52
54
  current_test_result_container.tap do |container|
55
+ logger.debug { "Stopping container: #{container.name}" }
53
56
  container.stop = ResultUtils.timestamp
54
57
  file_writer.write_test_result_container(container)
55
58
  clear_last_test_container
@@ -62,9 +65,10 @@ module Allure
62
65
  def start_test_case(test_result)
63
66
  clear_step_context
64
67
  unless current_test_result_container
65
- return logger.error("Could not start test case, test container is not started")
68
+ return logger.error { "Could not start test case, test container is not started" }
66
69
  end
67
70
 
71
+ logger.debug("Starting test case: #{test_result.name}")
68
72
  test_result.start = ResultUtils.timestamp
69
73
  test_result.stage = Stage::RUNNING
70
74
  test_result.labels.push(ResultUtils.thread_label, ResultUtils.host_label, ResultUtils.language_label)
@@ -80,7 +84,7 @@ module Allure
80
84
  # @yieldreturn [void]
81
85
  # @return [void]
82
86
  def update_test_case
83
- return logger.error("Could not update test case, no test case running") unless @current_test_case
87
+ return logger.error { "Could not update test case, no test case running" } unless @current_test_case
84
88
 
85
89
  yield(@current_test_case)
86
90
  end
@@ -88,8 +92,9 @@ module Allure
88
92
  # Stop current test case and write result
89
93
  # @return [void]
90
94
  def stop_test_case
91
- return logger.error("Could not stop test case, no test case is running") unless @current_test_case
95
+ return logger.error { "Could not stop test case, no test case is running" } unless @current_test_case
92
96
 
97
+ logger.debug { "Stopping test case: #{@current_test_case.name}" }
93
98
  @current_test_case.stop = ResultUtils.timestamp
94
99
  @current_test_case.stage = Stage::FINISHED
95
100
  file_writer.write_test_result(@current_test_case)
@@ -101,8 +106,9 @@ module Allure
101
106
  # @param [Allure::StepResult] step_result
102
107
  # @return [Allure::StepResult]
103
108
  def start_test_step(step_result)
104
- return logger.error("Could not start test step, no test case is running") unless @current_test_case
109
+ return logger.error { "Could not start test step, no test case is running" } unless @current_test_case
105
110
 
111
+ logger.debug { "Starting test step: #{step_result.name}" }
106
112
  step_result.start = ResultUtils.timestamp
107
113
  step_result.stage = Stage::RUNNING
108
114
  add_test_step(step_result)
@@ -117,7 +123,7 @@ module Allure
117
123
  # @yieldreturn [void]
118
124
  # @return [void]
119
125
  def update_test_step
120
- return logger.error("Could not update test step, no step is running") unless current_test_step
126
+ return logger.error { "Could not update test step, no step is running" } unless current_test_step
121
127
 
122
128
  yield(current_test_step)
123
129
  end
@@ -125,8 +131,9 @@ module Allure
125
131
  # Stop current test step
126
132
  # @return [void]
127
133
  def stop_test_step
128
- return logger.error("Could not stop test step, no step is running") unless current_test_step
134
+ return logger.error { "Could not stop test step, no step is running" } unless current_test_step
129
135
 
136
+ logger.debug { "Stopping test step: #{current_test_step.name}" }
130
137
  current_test_step.stop = ResultUtils.timestamp
131
138
  current_test_step.stage = Stage::FINISHED
132
139
  clear_last_test_step
@@ -160,6 +167,7 @@ module Allure
160
167
  return false
161
168
  end
162
169
 
170
+ logger.debug { "Starting fixture: #{fixture_result.name}" }
163
171
  fixture_result.start = ResultUtils.timestamp
164
172
  fixture_result.stage = Stage::RUNNING
165
173
  end
@@ -172,7 +180,7 @@ module Allure
172
180
  # @yieldreturn [void]
173
181
  # @return [void]
174
182
  def update_fixture
175
- return logger.error("Could not update fixture, fixture is not started") unless @current_fixture
183
+ return logger.error { "Could not update fixture, fixture is not started" } unless @current_fixture
176
184
 
177
185
  yield(@current_fixture)
178
186
  end
@@ -180,8 +188,9 @@ module Allure
180
188
  # Stop current test fixture
181
189
  # @return [void]
182
190
  def stop_fixture
183
- return logger.error("Could not stop fixture, fixture is not started") unless @current_fixture
191
+ return logger.error { "Could not stop fixture, fixture is not started" } unless @current_fixture
184
192
 
193
+ logger.debug { "Stopping fixture: #{@current_fixture.name}" }
185
194
  @current_fixture.stop = ResultUtils.timestamp
186
195
  @current_fixture.stage = Stage::FINISHED
187
196
  clear_current_fixture
@@ -195,13 +204,14 @@ module Allure
195
204
  # @param [Boolean] test_case add attachment to current test case
196
205
  # @return [void]
197
206
  def add_attachment(name:, source:, type:, test_case: false)
198
- attachment = ResultUtils.prepare_attachment(name, type) || begin
199
- return logger.error("Can't add attachment, unrecognized mime type: #{type}")
200
- end
201
- executable_item = (test_case && @current_test_case) || current_executable
202
- executable_item&.attachments&.push(attachment) || begin
203
- return logger.error("Can't add attachment, no test, step or fixture is running")
204
- end
207
+ attachment = ResultUtils.prepare_attachment(name, type)
208
+ return logger.error { "Can't add attachment, unrecognized mime type: #{type}" } unless attachment
209
+
210
+ executable_item = test_case ? @current_test_case : current_executable
211
+ return logger.error { "Can't add attachment, no test, step or fixture is running" } unless executable_item
212
+
213
+ executable_item.attachments.push(attachment)
214
+ logger.debug { "Adding attachment '#{name}' to '#{executable_item.name}'" }
205
215
  write_attachment(source, attachment)
206
216
  end
207
217
 
@@ -218,7 +228,7 @@ module Allure
218
228
  # @return [void]
219
229
  def clean_results_dir
220
230
  Allure.configuration.tap do |c|
221
- FileUtils.rm_f(Dir.glob("#{c.results_directory}/*")) if c.clean_results_directory
231
+ FileUtils.rm_f(Dir.glob("#{c.results_directory}/**/*")) if c.clean_results_directory
222
232
  end
223
233
  end
224
234
 
@@ -8,20 +8,14 @@ module Allure
8
8
  class Config
9
9
  include Singleton
10
10
 
11
- # @return [String] default allure results directory
12
- DEFAULT_RESULTS_DIRECTORY = "reports/allure-results"
13
- # @return [String] default loggin level
14
- DEFAULT_LOGGING_LEVEL = Logger::INFO
11
+ # @return [Array<String>] valid log levels
12
+ LOGLEVELS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN].freeze
15
13
 
16
- attr_accessor :link_tms_pattern, :link_issue_pattern, :clean_results_directory
17
- attr_writer :results_directory, :logging_level
18
-
19
- def results_directory
20
- @results_directory || DEFAULT_RESULTS_DIRECTORY
14
+ def initialize
15
+ @results_directory = "reports/allure-results"
16
+ @logging_level = LOGLEVELS.index(ENV.fetch("ALLURE_LOG_LEVEL", "INFO")) || Logger::INFO
21
17
  end
22
18
 
23
- def logging_level
24
- @logging_level || DEFAULT_LOGGING_LEVEL
25
- end
19
+ attr_accessor :results_directory, :logging_level, :link_tms_pattern, :link_issue_pattern, :clean_results_directory
26
20
  end
27
21
  end
@@ -18,14 +18,14 @@ module Allure
18
18
  # @param [Allure::TestResult] test_result
19
19
  # @return [void]
20
20
  def write_test_result(test_result)
21
- write("#{test_result.uuid}#{TEST_RESULT_SUFFIX}", test_result.to_json)
21
+ write("#{test_result.uuid}#{TEST_RESULT_SUFFIX}", Oj.dump(test_result))
22
22
  end
23
23
 
24
24
  # Write test result container
25
25
  # @param [Allure::TestResultContainer] test_container_result
26
26
  # @return [void]
27
27
  def write_test_result_container(test_container_result)
28
- write("#{test_container_result.uuid}#{TEST_RESULT_CONTAINER_SUFFIX}", test_container_result.to_json)
28
+ write("#{test_container_result.uuid}#{TEST_RESULT_CONTAINER_SUFFIX}", Oj.dump(test_container_result))
29
29
  end
30
30
 
31
31
  # Write allure attachment file
@@ -52,7 +52,7 @@ module Allure
52
52
  if categories.is_a?(File)
53
53
  copy(categories.path, CATEGORIES_FILE)
54
54
  else
55
- write(CATEGORIES_FILE, categories.to_json)
55
+ write(CATEGORIES_FILE, Oj.dump(categories))
56
56
  end
57
57
  end
58
58
 
@@ -9,6 +9,8 @@ module Allure
9
9
  # @param [String] type attachment type, {Allure::ContentType}
10
10
  # @param [String] source attachment file name
11
11
  def initialize(name:, type:, source:)
12
+ super()
13
+
12
14
  @name = name
13
15
  @type = type
14
16
  @source = source
@@ -10,6 +10,8 @@ module Allure
10
10
  # @param [String, Regexp] message_regex
11
11
  # @param [String, Regexp] trace_regex
12
12
  def initialize(name:, matched_statuses: nil, message_regex: nil, trace_regex: nil)
13
+ super()
14
+
13
15
  @name = name
14
16
  @matched_statuses = matched_statuses
15
17
  @message_regex = message_regex
@@ -16,6 +16,8 @@ module Allure
16
16
  # @option options [Array<Allure::Attachment>] :attachments ([])
17
17
  # @option options [Array<Allure::Parameter>] :parameters ([])
18
18
  def initialize(**options)
19
+ super()
20
+
19
21
  @name = options[:name]
20
22
  @description = options[:description]
21
23
  @description_html = options[:description_html]
@@ -1,14 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "json"
3
+ require "oj"
4
4
 
5
5
  module Allure
6
6
  # General jsonable object implementation
7
7
  class JSONable
8
- # Return object has represantation
9
- # @param [Hash] _options
8
+ Oj.default_options = { mode: :custom, use_to_hash: true, ascii_only: true }
9
+
10
+ # Return object hash represantation
10
11
  # @return [Hash]
11
- def as_json(_options = {})
12
+ def to_hash
12
13
  instance_variables.each_with_object({}) do |var, map|
13
14
  key = camelcase(var.to_s.delete_prefix("@"))
14
15
  value = instance_variable_get(var)
@@ -16,13 +17,6 @@ module Allure
16
17
  end
17
18
  end
18
19
 
19
- # Convert object to json string
20
- # @param [Array<Object>] options
21
- # @return [String]
22
- def to_json(*options)
23
- as_json(*options).to_json(*options)
24
- end
25
-
26
20
  # Object comparator
27
21
  # @param [JSONable] other
28
22
  # @return [Booelan]
@@ -6,6 +6,8 @@ module Allure
6
6
  # Allure model label object
7
7
  class Label < JSONable
8
8
  def initialize(name, value)
9
+ super()
10
+
9
11
  @name = name
10
12
  @value = value
11
13
  end
@@ -6,6 +6,8 @@ module Allure
6
6
  # Allure model link object
7
7
  class Link < JSONable
8
8
  def initialize(type, name, url)
9
+ super()
10
+
9
11
  @type = type
10
12
  @name = name
11
13
  @url = url
@@ -6,6 +6,8 @@ module Allure
6
6
  # Allure model parameter object
7
7
  class Parameter < JSONable
8
8
  def initialize(name, value)
9
+ super()
10
+
9
11
  @name = name
10
12
  @value = value
11
13
  end
@@ -9,6 +9,8 @@ module Allure
9
9
  # @param [String] message
10
10
  # @param [String] trace
11
11
  def initialize(known: false, muted: false, flaky: false, message: nil, trace: nil)
12
+ super()
13
+
12
14
  @known = known
13
15
  @muted = muted
14
16
  @flaky = flaky
@@ -6,6 +6,8 @@ module Allure
6
6
  # Allure model step result container
7
7
  class TestResultContainer < JSONable
8
8
  def initialize(uuid: UUID.generate, name: "Unnamed")
9
+ super()
10
+
9
11
  @uuid = uuid
10
12
  @name = name
11
13
  @children = []
metadata CHANGED
@@ -1,83 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-ruby-commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.5.rc.3
4
+ version: 2.13.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-04 00:00:00.000000000 Z
11
+ date: 2020-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: uuid
14
+ name: mime-types
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.3'
19
+ version: '3.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.3'
26
+ version: '3.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: require_all
28
+ name: oj
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '2'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '4'
33
+ version: '3.10'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
- version: '2'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '4'
40
+ version: '3.10'
47
41
  - !ruby/object:Gem::Dependency
48
- name: json
42
+ name: require_all
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: '1.8'
47
+ version: '2'
54
48
  - - "<"
55
49
  - !ruby/object:Gem::Version
56
- version: '3'
50
+ version: '4'
57
51
  type: :runtime
58
52
  prerelease: false
59
53
  version_requirements: !ruby/object:Gem::Requirement
60
54
  requirements:
61
55
  - - ">="
62
56
  - !ruby/object:Gem::Version
63
- version: '1.8'
57
+ version: '2'
64
58
  - - "<"
65
59
  - !ruby/object:Gem::Version
66
- version: '3'
60
+ version: '4'
67
61
  - !ruby/object:Gem::Dependency
68
- name: mime-types
62
+ name: uuid
69
63
  requirement: !ruby/object:Gem::Requirement
70
64
  requirements:
71
- - - "~>"
65
+ - - ">="
72
66
  - !ruby/object:Gem::Version
73
- version: '3.3'
67
+ version: '2.3'
74
68
  type: :runtime
75
69
  prerelease: false
76
70
  version_requirements: !ruby/object:Gem::Requirement
77
71
  requirements:
78
- - - "~>"
72
+ - - ">="
79
73
  - !ruby/object:Gem::Version
80
- version: '3.3'
74
+ version: '2.3'
81
75
  description: Utilities allowing to implement allure result generation by other test
82
76
  frameworks
83
77
  email: andrejs.cunskis@gmail.com
@@ -126,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
120
  version: 2.5.0
127
121
  required_rubygems_version: !ruby/object:Gem::Requirement
128
122
  requirements:
129
- - - ">"
123
+ - - ">="
130
124
  - !ruby/object:Gem::Version
131
- version: 1.3.1
125
+ version: '0'
132
126
  requirements: []
133
127
  rubygems_version: 3.1.2
134
128
  signing_key: