tldr 0.9.5 → 0.10.0

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: 6929795fbe4a33bf03bc8bb107a4902b6f125bfc879edf0ec0441b5ec7e5d7a5
4
- data.tar.gz: 52df3f72b9fcd4dd046d5513fd1c0c1ce69a04a6559f3edfc2c50c58fb7aa073
3
+ metadata.gz: 99a624f1917fbfcd057cf445c09e01c41dbbe9666d9e30219dae66ca63d2ae96
4
+ data.tar.gz: 19aa8844384432251b27c3303d714535f688b48ee1b0813eb3adaf22fdc8c094
5
5
  SHA512:
6
- metadata.gz: d065a84fd62ebc48fdac9223a615540c02b570172e4337c07e362dcdd8fec94037fbb64447b1099e127641c8909e0148f465252fc5f2e48c5d2af2128b5d4e28
7
- data.tar.gz: cbfbaee9dbbbc6854d48c415f3818611f9b980527a0afb5ce7d032484edce9753bf902c0f737b44480e1717484e74fac96221cc2104844a96d2b1e9c2b5eaaf5
6
+ metadata.gz: 92077e5052669276a18135bcb14fc04d70ba84d7b6af4d6c74afb234fb4fbbe21ff419ab3760ed0fc8a46feca6b7c15a7dd5ba11218168a41fcd3fc625f048c0
7
+ data.tar.gz: fc6e72b814928a0cf7b76a2586f495094932e0d0115361540bba8c172e1f2f09e647e6e1cc318d3646849325dc834ac55fc6e91a337091fa34ec2ffaacf937b4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.10.0]
2
+
3
+ * Add an option to print the stack traces of interrupted tests [#13](https://github.com/tendersearls/tldr/pull/13) by [@henrahmagix](https://github.com/henrahmagix)
4
+
1
5
  ## [0.9.5]
2
6
 
3
7
  * Fix warning when defining `setup`/`teardown` on TLDR class itself [#7](https://github.com/tendersearls/tldr/issues/7)
data/README.md CHANGED
@@ -122,6 +122,8 @@ Usage: tldr [options] some_tests/**/*.rb some/path.rb:13 ...
122
122
  --no-dotfile Disable loading .tldr.yml dotfile
123
123
  --no-emoji Disable emoji in the output
124
124
  -v, --verbose Print stack traces for errors
125
+ --print-interrupted-test-backtraces
126
+ Print stack traces for interrupted tests
125
127
  --[no-]warnings Print Ruby warnings (Default: true)
126
128
  --watch Run your tests continuously on file save (requires 'fswatch' to be installed)
127
129
  --yes-i-know Suppress TLDR report when suite runs over 1.8s
@@ -78,6 +78,10 @@ class TLDR
78
78
  options[:verbose] = verbose
79
79
  end
80
80
 
81
+ opts.on CONFLAGS[:print_interrupted_test_backtraces], "Print stack traces for interrupted tests" do |print_interrupted_test_backtraces|
82
+ options[:print_interrupted_test_backtraces] = print_interrupted_test_backtraces
83
+ end
84
+
81
85
  opts.on CONFLAGS[:warnings], "Print Ruby warnings (Default: true)" do |warnings|
82
86
  options[:warnings] = warnings
83
87
  end
@@ -241,7 +241,7 @@ class TLDR
241
241
  begin
242
242
  yield
243
243
  rescue NoMatchingPatternError => e
244
- assert false, Assertions.msg(message) { "Expected pattern match: #{e.message}" }
244
+ assert false, Assertions.msg(message) { "Expected pattern to match, but NoMatchingPatternError was raised: #{e.message}" }
245
245
  end
246
246
  end
247
247
 
@@ -250,7 +250,7 @@ class TLDR
250
250
 
251
251
  begin
252
252
  yield
253
- refute true, Assertions.msg(message) { "Expected pattern not to match, but NoMatchingPatternError was raised" }
253
+ refute true, Assertions.msg(message) { "Expected pattern not to match, but NoMatchingPatternError was not raised" }
254
254
  rescue NoMatchingPatternError
255
255
  end
256
256
  end
@@ -47,7 +47,7 @@ class TLDR
47
47
  "#{@icons.run} Completed #{test_results.size} of #{planned_tests.size} tests (#{((test_results.size.to_f / planned_tests.size) * 100).round}%) before running out of time.",
48
48
  (<<~WIP.chomp if wip_tests.any?),
49
49
  #{@icons.wip} #{plural(wip_tests.size, "test was", "tests were")} cancelled in progress:
50
- #{wip_tests.map { |wip_test| " #{time_diff(wip_test.start_time, stop_time)}ms - #{describe(wip_test.test)}" }.join("\n")}
50
+ #{wip_tests.map { |wip_test| " #{time_diff(wip_test.start_time, stop_time)}ms - #{describe(wip_test.test)}#{print_wip_backtrace(wip_test, indent: " ") if @config.print_interrupted_test_backtraces}" }.join("\n")}
51
51
  WIP
52
52
  (<<~SLOW.chomp if test_results.any?),
53
53
  #{@icons.slow} Your #{[10, test_results.size].min} slowest completed tests:
@@ -137,6 +137,12 @@ class TLDR
137
137
  "#{test.test_class}##{test.method_name} [#{location.locator}]"
138
138
  end
139
139
 
140
+ def print_wip_backtrace wip_test, indent: ""
141
+ return unless wip_test.backtrace_at_exit
142
+
143
+ "\n#{indent}Backtrace at the point of cancellation:\n#{indent}#{wip_test.backtrace_at_exit.join("\n#{indent}")}"
144
+ end
145
+
140
146
  def plural count, singular, plural = "#{singular}s"
141
147
  "#{count} #{(count == 1) ? singular : plural}"
142
148
  end
data/lib/tldr/runner.rb CHANGED
@@ -20,6 +20,7 @@ class TLDR
20
20
  next if ENV["CI"] && !$stderr.tty?
21
21
  next if @run_aborted.true?
22
22
  @run_aborted.make_true
23
+ @wip.each(&:capture_backtrace_at_exit)
23
24
  reporter.after_tldr(plan.tests, @wip.dup, @results.dup)
24
25
  exit!(3)
25
26
  end
@@ -51,7 +52,7 @@ class TLDR
51
52
  def run_test test, config, plan, reporter
52
53
  e = nil
53
54
  start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
54
- wip_test = WIPTest.new(test, start_time)
55
+ wip_test = WIPTest.new(test, start_time, Thread.current)
55
56
  @wip << wip_test
56
57
  runtime = time_it(start_time) do
57
58
  instance = test.test_class.new
@@ -3,6 +3,7 @@ class TLDR
3
3
  seed: "--seed",
4
4
  no_helper: "--no-helper",
5
5
  verbose: "--verbose",
6
+ print_interrupted_test_backtraces: "--print-interrupted-test-backtraces",
6
7
  reporter: "--reporter",
7
8
  helper_paths: "--helper",
8
9
  load_paths: "--load-path",
@@ -26,7 +27,7 @@ class TLDR
26
27
  PATH_FLAGS = [:paths, :helper_paths, :load_paths, :prepend_paths, :exclude_paths].freeze
27
28
  MOST_RECENTLY_MODIFIED_TAG = "MOST_RECENTLY_MODIFIED".freeze
28
29
  CONFIG_ATTRIBUTES = [
29
- :paths, :seed, :no_helper, :verbose, :reporter,
30
+ :paths, :seed, :no_helper, :verbose, :print_interrupted_test_backtraces, :reporter,
30
31
  :helper_paths, :load_paths, :parallel, :names, :fail_fast, :no_emoji,
31
32
  :prepend_paths, :no_prepend, :exclude_paths, :exclude_names, :base_path,
32
33
  :no_dotfile, :warnings, :watch, :yes_i_know, :i_am_being_watched,
@@ -60,6 +61,7 @@ class TLDR
60
61
  seed: rand(10_000),
61
62
  no_helper: false,
62
63
  verbose: false,
64
+ print_interrupted_test_backtraces: false,
63
65
  reporter: Reporters::Default,
64
66
  parallel: true,
65
67
  names: [],
@@ -109,7 +111,7 @@ class TLDR
109
111
  end
110
112
 
111
113
  # Booleans
112
- [:no_helper, :verbose, :fail_fast, :no_emoji, :no_prepend, :warnings, :yes_i_know, :i_am_being_watched].each do |key|
114
+ [:no_helper, :verbose, :print_interrupted_test_backtraces, :fail_fast, :no_emoji, :no_prepend, :warnings, :yes_i_know, :i_am_being_watched].each do |key|
113
115
  merged_args[key] = defaults[key] if merged_args[key].nil?
114
116
  end
115
117
 
@@ -201,7 +203,7 @@ class TLDR
201
203
  next warnings ? "--warnings" : "--no-warnings"
202
204
  end
203
205
 
204
- if defaults[key] == self[key]
206
+ if defaults[key] == self[key] && (key != :seed || !seed_set_intentionally)
205
207
  next
206
208
  elsif self[key].is_a?(Array)
207
209
  self[key].map { |value| [flag, stringify(key, value)] }
@@ -1,3 +1,9 @@
1
1
  class TLDR
2
- WIPTest = Struct.new(:test, :start_time)
2
+ WIPTest = Struct.new(:test, :start_time, :thread) do
3
+ attr_reader :backtrace_at_exit
4
+
5
+ def capture_backtrace_at_exit
6
+ @backtrace_at_exit = thread&.backtrace
7
+ end
8
+ end
3
9
  end
data/lib/tldr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class TLDR
2
- VERSION = "0.9.5"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tldr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-10-15 00:00:00.000000000 Z
12
+ date: 2024-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: super_diff
@@ -89,13 +89,13 @@ files:
89
89
  - lib/tldr/watcher.rb
90
90
  - script/setup
91
91
  - script/test
92
- homepage: https://github.com/tenderlove/tldr
92
+ homepage: https://github.com/tendersearls/tldr
93
93
  licenses:
94
94
  - MIT
95
95
  metadata:
96
- homepage_uri: https://github.com/tenderlove/tldr
97
- source_code_uri: https://github.com/tenderlove/tldr
98
- changelog_uri: https://github.com/tenderlove/tldr/blob/main/CHANGELOG.md
96
+ homepage_uri: https://github.com/tendersearls/tldr
97
+ source_code_uri: https://github.com/tendersearls/tldr
98
+ changelog_uri: https://github.com/tendersearls/tldr/blob/main/CHANGELOG.md
99
99
  post_install_message:
100
100
  rdoc_options: []
101
101
  require_paths:
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.4.6
114
+ rubygems_version: 3.4.21
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: TLDR will run your tests, but only for 1.8 seconds.