rspec-tracer 0.6.0 → 0.6.1

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: 885e868cf847ca1bab4ba2243cd4cd6a4bc3f936a3c8c10f677146433acc2068
4
- data.tar.gz: d60fcdeef0067a37faec3ea876ffa519bdd7039a1765ad59e551427bcf2c8e29
3
+ metadata.gz: 4dff7e48382045aef3821a6f863521c9f74823b5bbd12c16b09c41b47277124e
4
+ data.tar.gz: cff630db632b7fa96be3d3de675b994325f815c69613b84d891bc8313688ab67
5
5
  SHA512:
6
- metadata.gz: cffa43507448703f4471ed2a463e7ef486f105b06560663d307b21c3303368b0ae0260bb36bbc392f900bfb0e54482fdc8055d231ab75fb33e5a93360be46ac9
7
- data.tar.gz: d59157d318beda7c81a65cdd1a38ff3d849521a502e31c6c805916ace8f6f3568a5114f201bc03cdb33e63cae3c0a86ae5e81dd148c1c32f735d7d5d3cea5750
6
+ metadata.gz: 83348356f2a12e930d73cec63e867a13ffab85e428696fc3d91dfeab5a691bac4641d848330d0225e08bc7156d0902faffc8ecd8f4a8871b24c093513c6a8b0d
7
+ data.tar.gz: 2cc9084dbeb9ca0fa26997b33b486360e3c1fe8b7efbb91f28b3a1786bf0e966b32f75b5d7b98a3488c5ced8d1704005f1c1a5972e876e25d3877a40d8068379
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [0.6.1] - 2021-09-06
2
+
3
+ ### Fixed
4
+
5
+ Bug in time formatter (#24)
6
+
7
+ ### Added
8
+
9
+ Environment variable to control verbose output (#25)
10
+
1
11
  ## [0.6.0] - 2021-09-05
2
12
 
3
13
  ### Added
data/README.md CHANGED
@@ -39,6 +39,7 @@ integrating the gem into your project to better understand what is happening.
39
39
  * [RSPEC_TRACER_NO_SKIP](#rspec_tracer_no_skip)
40
40
  * [RSPEC_TRACER_S3_URI](#rspec_tracer_s3_uri)
41
41
  * [RSPEC_TRACER_UPLOAD_LOCAL_CACHE](#rspec_tracer_upload_local_cache)
42
+ * [RSPEC_TRACER_VERBOSE](#rspec_tracer_verbose)
42
43
  * [TEST_SUITES](#test_suites)
43
44
  * [TEST_SUITE_ID](#test_suite_id)
44
45
  * [Sample Reports](#sample-reports)
@@ -192,6 +193,14 @@ export RSPEC_TRACER_S3_URI=s3://ci-artifacts-bucket/rspec-tracer-cache
192
193
  By default, RSpec Tracer does not upload local cache files. You can set this
193
194
  environment variable to `true` to upload the local cache to S3.
194
195
 
196
+ ### RSPEC_TRACER_VERBOSE
197
+
198
+ To print the intermediate steps and time taken, use this environment variable:
199
+
200
+ ```sh
201
+ export RSPEC_TRACER_VERBOSE=true
202
+ ```
203
+
195
204
  ### TEST_SUITES
196
205
 
197
206
  Set this environment variable when using test suite id. It determines the total
@@ -49,7 +49,7 @@ module RSpecTracer
49
49
  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
50
50
  elpased = RSpecTracer::TimeFormatter.format_time(ending - starting)
51
51
 
52
- puts "RSpec tracer loaded cached examples coverage (took #{elpased})"
52
+ puts "RSpec tracer loaded cached examples coverage (took #{elpased})" if RSpecTracer.verbose?
53
53
 
54
54
  coverage
55
55
  end
@@ -102,6 +102,12 @@ module RSpecTracer
102
102
  @coverage_filters ||= []
103
103
  end
104
104
 
105
+ def verbose?
106
+ return @verbose if defined?(@verbose)
107
+
108
+ @verbose = ENV.fetch('RSPEC_TRACER_VERBOSE', 'false') == 'true'
109
+ end
110
+
105
111
  def configure(&block)
106
112
  Docile.dsl_eval(self, &block)
107
113
  end
@@ -140,7 +140,7 @@ module RSpecTracer
140
140
  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
141
141
  elpased = RSpecTracer::TimeFormatter.format_time(ending - starting)
142
142
 
143
- puts "RSpec tracer generated #{report_type.to_s.tr('_', ' ')} report (took #{elpased})"
143
+ puts "RSpec tracer generated #{report_type.to_s.tr('_', ' ')} report (took #{elpased})" if RSpecTracer.verbose?
144
144
  end
145
145
 
146
146
  @reporter.write_reports
@@ -162,7 +162,7 @@ module RSpecTracer
162
162
  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
163
163
  elpased = RSpecTracer::TimeFormatter.format_time(ending - starting)
164
164
 
165
- puts "RSpec tracer processed cache (took #{elpased})"
165
+ puts "RSpec tracer processed cache (took #{elpased})" if RSpecTracer.verbose?
166
166
  end
167
167
 
168
168
  def filter_by_example_status
@@ -270,7 +270,7 @@ module RSpecTracer
270
270
  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
271
271
  elpased = RSpecTracer::TimeFormatter.format_time(ending - starting)
272
272
 
273
- puts "RSpec tracer generated flaky, failed, and pending examples report (took #{elpased})"
273
+ puts "RSpec tracer generated flaky, failed, and pending examples report (took #{elpased})" if RSpecTracer.verbose?
274
274
  end
275
275
 
276
276
  def generate_all_files_report
@@ -21,11 +21,10 @@ module RSpecTracer
21
21
  next unless seconds.positive?
22
22
 
23
23
  seconds, remainder = seconds.divmod(count)
24
- remainder = format_duration(remainder)
25
24
 
26
25
  next if remainder.zero?
27
26
 
28
- duration << pluralize(remainder, unit)
27
+ duration << pluralize(format_duration(remainder), unit)
29
28
  end
30
29
 
31
30
  formatted_duration.reverse.join(' ')
@@ -36,17 +35,21 @@ module RSpecTracer
36
35
 
37
36
  precision = duration < 1 ? SECONDS_PRECISION : DEFAULT_PRECISION
38
37
 
39
- format("%<duration>0.#{precision}f", duration: duration)
38
+ strip_trailing_zeroes(format("%<duration>0.#{precision}f", duration: duration))
39
+ end
40
+
41
+ def strip_trailing_zeroes(formatted_duration)
42
+ formatted_duration.sub(/(?:(\..*[^0])0+|\.0+)$/, '\1')
40
43
  end
41
44
 
42
45
  def pluralize(duration, unit)
43
- if duration == 1
46
+ if (duration.to_f - 1).abs < Float::EPSILON
44
47
  "#{duration} #{unit}"
45
48
  else
46
49
  "#{duration} #{unit}s"
47
50
  end
48
51
  end
49
52
 
50
- private_class_method :format_duration, :pluralize
53
+ private_class_method :format_duration, :strip_trailing_zeroes, :pluralize
51
54
  end
52
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpecTracer
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
data/lib/rspec_tracer.rb CHANGED
@@ -201,7 +201,7 @@ module RSpecTracer
201
201
  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
202
202
  elpased = RSpecTracer::TimeFormatter.format_time(ending - starting)
203
203
 
204
- puts "RSpec tracer processed dependency (took #{elpased})"
204
+ puts "RSpec tracer processed dependency (took #{elpased})" if RSpecTracer.verbose?
205
205
  end
206
206
 
207
207
  def process_coverage
@@ -214,7 +214,7 @@ module RSpecTracer
214
214
  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
215
215
  elpased = RSpecTracer::TimeFormatter.format_time(ending - starting)
216
216
 
217
- puts "RSpec tracer processed coverage (took #{elpased})"
217
+ puts "RSpec tracer processed coverage (took #{elpased})" if RSpecTracer.verbose?
218
218
  end
219
219
 
220
220
  def run_simplecov_exit_task
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhimanyu Singh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-05 00:00:00.000000000 Z
11
+ date: 2021-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docile
@@ -107,7 +107,7 @@ licenses:
107
107
  - MIT
108
108
  metadata:
109
109
  homepage_uri: https://github.com/avmnu-sng/rspec-tracer
110
- source_code_uri: https://github.com/avmnu-sng/rspec-tracer/tree/v0.6.0
110
+ source_code_uri: https://github.com/avmnu-sng/rspec-tracer/tree/v0.6.1
111
111
  changelog_uri: https://github.com/avmnu-sng/rspec-tracer/blob/main/CHANGELOG.md
112
112
  bug_tracker_uri: https://github.com/avmnu-sng/rspec-tracer/issues
113
113
  post_install_message: