allure-ruby-commons 2.13.6.1 → 2.13.6.2

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: a81d940f25f1d5ce8c0182f5db774847543a9f5f27adafd11ba3097d7f35799b
4
- data.tar.gz: 5f15450ce98e2bd96fb56963bfd4ec7531bb7fa363ab783c5a2c3617d4d1b7de
3
+ metadata.gz: 2dde5d93b183282927b03e256e2d9cbe933fd234aa9230545b7d91f074111a20
4
+ data.tar.gz: 8c05594912decb62f1fc9cc52ebdc85ff9a506c6bd1cbb8cb0a71f7d54102dca
5
5
  SHA512:
6
- metadata.gz: 1654746b1f49194bb3bcda1185b8b69a78c869e51adbbac8a8e740052b454b38e48a3082c58bb2f912cbabc4321340e08949adc8f5c52754bf01c72b7e9b472b
7
- data.tar.gz: aaeeb44926a120ec16c592724043db8e48e62822f9dee29ae9825d2f22468d64f49f41871fd670f2b90843df2d1b3984987bc1ae2a13fdaccee62b86d3b71ada
6
+ metadata.gz: f8feed62b8a1f8c1182566623ac01e35356f6ce43dc86479b76175ae0cee0480517df3f5bc349a624a8ae4769acc1e72e10ccde649fc204debe508dd8b104783
7
+ data.tar.gz: f58060aa2b39d17b5a28b7ae222c049d96d734a64ea238d27a2fa536fd4010015fe11c3abbd43cb6ce28ec1b7548dffa245dc7c75f1fdf622c1e0cb04a24551c
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.
@@ -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 { "Stoping test step: #{current_test_step.stop}" }
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
@@ -196,12 +205,13 @@ module Allure
196
205
  # @return [void]
197
206
  def add_attachment(name:, source:, type:, test_case: false)
198
207
  attachment = ResultUtils.prepare_attachment(name, type) || begin
199
- return logger.error("Can't add attachment, unrecognized mime type: #{type}")
208
+ return logger.error { "Can't add attachment, unrecognized mime type: #{type}" }
200
209
  end
201
210
  executable_item = (test_case && @current_test_case) || current_executable
202
211
  executable_item&.attachments&.push(attachment) || begin
203
- return logger.error("Can't add attachment, no test, step or fixture is running")
212
+ return logger.error { "Can't add attachment, no test, step or fixture is running" }
204
213
  end
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,17 @@ 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}", JSON.generate(test_result, max_nesting: false))
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(
29
+ "#{test_container_result.uuid}#{TEST_RESULT_CONTAINER_SUFFIX}",
30
+ JSON.generate(test_container_result, max_nesting: false),
31
+ )
29
32
  end
30
33
 
31
34
  # Write allure attachment file
@@ -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]
@@ -6,9 +6,9 @@ module Allure
6
6
  # General jsonable object implementation
7
7
  class JSONable
8
8
  # Return object has represantation
9
- # @param [Hash] _options
9
+ # @param [Array<Object>] _options
10
10
  # @return [Hash]
11
- def as_json(_options = {})
11
+ def as_json(*_options)
12
12
  instance_variables.each_with_object({}) do |var, map|
13
13
  key = camelcase(var.to_s.delete_prefix("@"))
14
14
  value = instance_variable_get(var)
@@ -20,7 +20,7 @@ module Allure
20
20
  # @param [Array<Object>] options
21
21
  # @return [String]
22
22
  def to_json(*options)
23
- as_json(*options).to_json(*options)
23
+ as_json.to_json(*options)
24
24
  end
25
25
 
26
26
  # Object comparator
@@ -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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-ruby-commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.6.1
4
+ version: 2.13.6.2
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-06-27 00:00:00.000000000 Z
11
+ date: 2020-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuid