tldr 0.9.4 → 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: 661e0ea905baa7122eba59c8f5954a3228698a2972a3567447bca5d8e7478f7e
4
- data.tar.gz: 15ca7a5c88ee2406952f760bfbb58143b37a2ba929d34183722a4eb2cb05d7ac
3
+ metadata.gz: 99a624f1917fbfcd057cf445c09e01c41dbbe9666d9e30219dae66ca63d2ae96
4
+ data.tar.gz: 19aa8844384432251b27c3303d714535f688b48ee1b0813eb3adaf22fdc8c094
5
5
  SHA512:
6
- metadata.gz: 62b464ca2538db776cc6d8f3b664f465c230c1faff70196342ef48b04b98b5419bc4a43718cad80b159887c64f840816caaf79f8451baa8adea05f5424e2ab98
7
- data.tar.gz: 1c7b685b900c2b47de3750c6e5ae4706853d9d1b8758cd514373e56dcfca580a40e9ca0bc7c391a52286acee9d25a1147673d86bdf4b95d14ae67e808146c4a9
6
+ metadata.gz: 92077e5052669276a18135bcb14fc04d70ba84d7b6af4d6c74afb234fb4fbbe21ff419ab3760ed0fc8a46feca6b7c15a7dd5ba11218168a41fcd3fc625f048c0
7
+ data.tar.gz: fc6e72b814928a0cf7b76a2586f495094932e0d0115361540bba8c172e1f2f09e647e6e1cc318d3646849325dc834ac55fc6e91a337091fa34ec2ffaacf937b4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
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
+
5
+ ## [0.9.5]
6
+
7
+ * Fix warning when defining `setup`/`teardown` on TLDR class itself [#7](https://github.com/tendersearls/tldr/issues/7)
1
8
 
2
9
  ## [0.9.4]
3
10
 
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
data/lib/tldr/hooks.rb ADDED
@@ -0,0 +1,9 @@
1
+ class TLDR
2
+ module Hooks
3
+ def setup
4
+ end
5
+
6
+ def teardown
7
+ end
8
+ end
9
+ 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.4"
2
+ VERSION = "0.10.0"
3
3
  end
data/lib/tldr.rb CHANGED
@@ -6,6 +6,7 @@ require_relative "tldr/backtrace_filter"
6
6
  require_relative "tldr/class_util"
7
7
  require_relative "tldr/error"
8
8
  require_relative "tldr/executor"
9
+ require_relative "tldr/hooks"
9
10
  require_relative "tldr/parallel_controls"
10
11
  require_relative "tldr/path_util"
11
12
  require_relative "tldr/planner"
@@ -21,12 +22,7 @@ require_relative "tldr/watcher"
21
22
  class TLDR
22
23
  include Assertions
23
24
  include Skippable
24
-
25
- def setup
26
- end
27
-
28
- def teardown
29
- end
25
+ include Hooks
30
26
 
31
27
  module Run
32
28
  def self.cli argv
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.4
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-14 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
@@ -64,6 +64,7 @@ files:
64
64
  - lib/tldr/class_util.rb
65
65
  - lib/tldr/error.rb
66
66
  - lib/tldr/executor.rb
67
+ - lib/tldr/hooks.rb
67
68
  - lib/tldr/parallel_controls.rb
68
69
  - lib/tldr/path_util.rb
69
70
  - lib/tldr/planner.rb
@@ -88,13 +89,13 @@ files:
88
89
  - lib/tldr/watcher.rb
89
90
  - script/setup
90
91
  - script/test
91
- homepage: https://github.com/tenderlove/tldr
92
+ homepage: https://github.com/tendersearls/tldr
92
93
  licenses:
93
94
  - MIT
94
95
  metadata:
95
- homepage_uri: https://github.com/tenderlove/tldr
96
- source_code_uri: https://github.com/tenderlove/tldr
97
- 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
98
99
  post_install_message:
99
100
  rdoc_options: []
100
101
  require_paths:
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  - !ruby/object:Gem::Version
111
112
  version: '0'
112
113
  requirements: []
113
- rubygems_version: 3.4.6
114
+ rubygems_version: 3.4.21
114
115
  signing_key:
115
116
  specification_version: 4
116
117
  summary: TLDR will run your tests, but only for 1.8 seconds.