tldr 0.6.2 → 0.8.0
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 +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +24 -1
- data/exe/tldt +5 -0
- data/lib/tldr/argv_parser.rb +5 -1
- data/lib/tldr/assertions/minitest_compatibility.rb +17 -0
- data/lib/tldr/assertions.rb +3 -3
- data/lib/tldr/reporters/default.rb +26 -20
- data/lib/tldr/value/config.rb +5 -3
- data/lib/tldr/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81e3d6734a718c5abbf80cfb088369d5a6bb89b81fc261020d97e34cbd6903bb
|
4
|
+
data.tar.gz: 1c4d0b5a53a948d868556b027f6fd6cdb4b9a96e67b459f0b2bf73e05a251d2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df9de67f0609adc2c5e0d2fc44a3bec44dd8a25a4ed0d128b8f1beaad6f45343dc9e5644e8d3b94b5bbe4db919f3becdf2e9a468a6eda0978669018135993d1f
|
7
|
+
data.tar.gz: 00e813b4947ef3d9e267e3ea4248def3254829b4b910719ad4cdd258cf809d751d7c5a539d527a708f9ff3471fe45fe24fc342d132f15948a56d7d5a56b38c7e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [0.8.0]
|
2
|
+
|
3
|
+
* Add a `--yes-i-know` flag that will suppress the large warning when your test
|
4
|
+
suite runs over the 1.8s limit
|
5
|
+
|
6
|
+
## [0.7.0]
|
7
|
+
|
8
|
+
* Add a `tldt` alias for folks who have another executable named `tldr` on their
|
9
|
+
paths
|
10
|
+
* BREAKING: Reverse decision in 0.1.1 to capture_io on every TLDR subclass;
|
11
|
+
moving back to the MinitestCompatibility mixin
|
12
|
+
* Fix `assert_in_delta` defaultarg to retain Minitest compatibility
|
13
|
+
* Add `mu_pp` to the MinitestCompatibility mixin
|
14
|
+
|
1
15
|
## [0.6.2]
|
2
16
|
|
3
17
|
* Since TLDR runs fine on 3.1, reduce the gem requirement
|
data/README.md
CHANGED
@@ -123,7 +123,8 @@ Usage: tldr [options] some_tests/**/*.rb some/path.rb:13 ...
|
|
123
123
|
--no-emoji Disable emoji in the output
|
124
124
|
-v, --verbose Print stack traces for errors
|
125
125
|
--[no-]warnings Print Ruby warnings (Default: true)
|
126
|
-
--
|
126
|
+
--yes-i-know Suppress TLDR report when suite runs over 1.8s
|
127
|
+
--comment COMMENT No-op; used for multi-line execution instructions
|
127
128
|
```
|
128
129
|
|
129
130
|
After being parsed, all the CLI options are converted into a
|
@@ -319,6 +320,14 @@ TLDR will run all your tests in CI without the time bomb going off. If
|
|
319
320
|
`tldr` is run in a non-interactive shell and a `CI` environment variable is set
|
320
321
|
(as it is on virtually every CI service), then the bomb will be defused.
|
321
322
|
|
323
|
+
### What if I already have another `tldr` executable on my path?
|
324
|
+
|
325
|
+
There's a [command-line utility named tldr](https://tldr.sh) that might conflict
|
326
|
+
with this gem's binary in your PATH. If that's the case you could change your
|
327
|
+
path, invoke `bundle exec tldr`, run [with Rake](#running-tldr-with-rake), or
|
328
|
+
use the `tldt` ("too long; didn't test") executable alias that ships with this
|
329
|
+
gem.
|
330
|
+
|
322
331
|
### Is there a plugin system?
|
323
332
|
|
324
333
|
There is not.
|
@@ -328,12 +337,26 @@ with the `--reporter` command line option. It can be set to any fully-qualified
|
|
328
337
|
class name that extends from
|
329
338
|
[TLDR::Reporters::Base](/lib/tldr/reporters/base.rb).
|
330
339
|
|
340
|
+
### I know my tests are over 1.8s, how do I suppress the huge output?
|
341
|
+
|
342
|
+
Plenty of test suites are over 1.8s and having TLDR repeatedly print out the
|
343
|
+
huge summary at the end of each test run can be distracting and make it harder
|
344
|
+
to spot test failures. If you know your test suite is too slow, you can simply
|
345
|
+
add the `--yes-i-know` flag
|
346
|
+
|
331
347
|
### What about mocking?
|
332
348
|
|
333
349
|
TLDR is laser-focused on running tests, so it doesn't provide a built-in mocking
|
334
350
|
facility. Might we interest you in a refreshing
|
335
351
|
[mocktail](https://github.com/testdouble/mocktail), instead?
|
336
352
|
|
353
|
+
### Contributing to TLDR
|
354
|
+
|
355
|
+
If you want to submit PRs on this repo, please know that the code style is
|
356
|
+
[Kirkland-style Ruby](https://mastodon.social/@searls/111137666157318482), where
|
357
|
+
method definitions have parentheses omitted but parentheses are generally
|
358
|
+
expected for method invocations.
|
359
|
+
|
337
360
|
## Acknowledgements
|
338
361
|
|
339
362
|
Thanks to [George Sheppard](https://github.com/fuzzmonkey) for freeing up the
|
data/exe/tldt
ADDED
data/lib/tldr/argv_parser.rb
CHANGED
@@ -82,7 +82,11 @@ class TLDR
|
|
82
82
|
options[:warnings] = warnings
|
83
83
|
end
|
84
84
|
|
85
|
-
opts.on
|
85
|
+
opts.on CONFLAGS[:yes_i_know], "Suppress TLDR report when suite runs over 1.8s" do
|
86
|
+
options[:yes_i_know] = true
|
87
|
+
end
|
88
|
+
|
89
|
+
opts.on "--comment COMMENT", String, "No-op; used for multi-line execution instructions" do
|
86
90
|
# See "--comment" in lib/tldr/reporters/default.rb for an example of how this is used internally
|
87
91
|
end
|
88
92
|
end.parse!(args)
|
@@ -33,6 +33,23 @@ class TLDR
|
|
33
33
|
|
34
34
|
assert receiver.__send__(method, *args), message
|
35
35
|
end
|
36
|
+
|
37
|
+
def capture_io(&blk)
|
38
|
+
Assertions.capture_io(&blk)
|
39
|
+
end
|
40
|
+
|
41
|
+
def mu_pp obj
|
42
|
+
s = obj.inspect.encode(Encoding.default_external)
|
43
|
+
|
44
|
+
if String === obj && (obj.encoding != Encoding.default_external ||
|
45
|
+
!obj.valid_encoding?)
|
46
|
+
enc = "# encoding: #{obj.encoding}"
|
47
|
+
val = "# valid: #{obj.valid_encoding?}"
|
48
|
+
"#{enc}\n#{val}\n#{s}"
|
49
|
+
else
|
50
|
+
s
|
51
|
+
end
|
52
|
+
end
|
36
53
|
end
|
37
54
|
end
|
38
55
|
end
|
data/lib/tldr/assertions.rb
CHANGED
@@ -28,7 +28,7 @@ class TLDR
|
|
28
28
|
SuperDiff::EqualityMatchers::Main.call(expected:, actual:)
|
29
29
|
end
|
30
30
|
|
31
|
-
def capture_io
|
31
|
+
def self.capture_io
|
32
32
|
captured_stdout, captured_stderr = StringIO.new, StringIO.new
|
33
33
|
|
34
34
|
original_stdout, original_stderr = $stdout, $stderr
|
@@ -85,7 +85,7 @@ class TLDR
|
|
85
85
|
refute expected == actual, message
|
86
86
|
end
|
87
87
|
|
88
|
-
def assert_in_delta expected, actual, delta, message = nil
|
88
|
+
def assert_in_delta expected, actual, delta = 0.001, message = nil
|
89
89
|
difference = (expected - actual).abs
|
90
90
|
message = Assertions.msg(message) {
|
91
91
|
"Expected |#{expected} - #{actual}| (#{difference}) to be within #{delta}"
|
@@ -204,7 +204,7 @@ class TLDR
|
|
204
204
|
def assert_output expected_stdout, expected_stderr, message = nil, &block
|
205
205
|
assert_block "assert_output requires a block to capture output" unless block
|
206
206
|
|
207
|
-
actual_stdout, actual_stderr = capture_io(&block)
|
207
|
+
actual_stdout, actual_stderr = Assertions.capture_io(&block)
|
208
208
|
|
209
209
|
if Regexp === expected_stderr
|
210
210
|
assert_match expected_stderr, actual_stderr, "In stderr"
|
@@ -31,29 +31,31 @@ class TLDR
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def time_diff start, stop = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
|
35
|
-
((stop - start) / 1000.0).round
|
36
|
-
end
|
37
|
-
|
38
34
|
def after_tldr planned_tests, wip_tests, test_results
|
39
35
|
stop_time = Process.clock_gettime Process::CLOCK_MONOTONIC, :microsecond
|
40
36
|
|
41
37
|
@out.print @icons.tldr
|
42
38
|
@err.print "\n\n"
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
39
|
+
|
40
|
+
if @config.yes_i_know
|
41
|
+
@err.print "🚨 TLDR! Display summary by omitting --yes-i-know"
|
42
|
+
else
|
43
|
+
wrap_in_horizontal_rule do
|
44
|
+
@err.print [
|
45
|
+
"too long; didn't run!",
|
46
|
+
"#{@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.",
|
47
|
+
(<<~WIP.chomp if wip_tests.any?),
|
48
|
+
#{@icons.wip} #{plural wip_tests.size, "test was", "tests were"} cancelled in progress:
|
49
|
+
#{wip_tests.map { |wip_test| " #{time_diff(wip_test.start_time, stop_time)}ms - #{describe(wip_test.test)}" }.join("\n")}
|
50
|
+
WIP
|
51
|
+
(<<~SLOW.chomp if test_results.any?),
|
52
|
+
#{@icons.slow} Your #{[10, test_results.size].min} slowest completed tests:
|
53
|
+
#{test_results.sort_by(&:runtime).last(10).reverse.map { |result| " #{result.runtime}ms - #{describe(result.test)}" }.join("\n")}
|
54
|
+
SLOW
|
55
|
+
describe_tests_that_didnt_finish(planned_tests, test_results),
|
56
|
+
"🙈 Suppress this summary with --yes-i-know"
|
57
|
+
].compact.join("\n\n")
|
58
|
+
end
|
57
59
|
end
|
58
60
|
|
59
61
|
after_suite test_results
|
@@ -102,6 +104,10 @@ class TLDR
|
|
102
104
|
|
103
105
|
private
|
104
106
|
|
107
|
+
def time_diff start, stop = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
|
108
|
+
((stop - start) / 1000.0).round
|
109
|
+
end
|
110
|
+
|
105
111
|
def summarize_failures results
|
106
112
|
failures = results.select { |result| result.failing? }
|
107
113
|
return failures if failures.empty?
|
@@ -138,7 +144,7 @@ class TLDR
|
|
138
144
|
rule = @icons.alarm + "=" * 20 + " ABORTED RUN " + "=" * 20 + @icons.alarm
|
139
145
|
@err.print "#{rule}\n\n"
|
140
146
|
yield
|
141
|
-
@err.print "\n\n#{rule}
|
147
|
+
@err.print "\n\n#{rule}"
|
142
148
|
end
|
143
149
|
|
144
150
|
def describe_tests_that_didnt_finish planned_tests, test_results
|
@@ -150,7 +156,7 @@ class TLDR
|
|
150
156
|
failed_locators = consolidate failed, exclude: unrun_locators
|
151
157
|
suggested_locators = unrun_locators + [
|
152
158
|
("--comment \"Also include #{plural failed.size, "test"} that failed:\"" if failed_locators.any?)
|
153
|
-
] + failed_locators
|
159
|
+
].compact + failed_locators
|
154
160
|
<<~MSG
|
155
161
|
#{@icons.rock_on} Run the #{plural unrun.size, "test"} that didn't finish:
|
156
162
|
#{tldr_command} #{@config.to_full_args exclude: [:paths]} #{suggested_locators.join(" \\\n ")}
|
data/lib/tldr/value/config.rb
CHANGED
@@ -17,6 +17,7 @@ class TLDR
|
|
17
17
|
base_path: "--base-path",
|
18
18
|
no_dotfile: "--no-dotfile",
|
19
19
|
warnings: "--[no-]warnings",
|
20
|
+
yes_i_know: "--yes-i-know",
|
20
21
|
paths: nil
|
21
22
|
}.freeze
|
22
23
|
|
@@ -26,7 +27,7 @@ class TLDR
|
|
26
27
|
:paths, :seed, :no_helper, :verbose, :reporter,
|
27
28
|
:helper_paths, :load_paths, :parallel, :names, :fail_fast, :no_emoji,
|
28
29
|
:prepend_paths, :no_prepend, :exclude_paths, :exclude_names, :base_path,
|
29
|
-
:no_dotfile, :warnings,
|
30
|
+
:no_dotfile, :warnings, :yes_i_know,
|
30
31
|
# Internal properties
|
31
32
|
:config_intended_for_merge_only, :seed_set_intentionally, :cli_defaults
|
32
33
|
].freeze
|
@@ -64,7 +65,8 @@ class TLDR
|
|
64
65
|
exclude_paths: [],
|
65
66
|
exclude_names: [],
|
66
67
|
base_path: nil,
|
67
|
-
warnings: true
|
68
|
+
warnings: true,
|
69
|
+
yes_i_know: false
|
68
70
|
}
|
69
71
|
|
70
72
|
if cli_defaults
|
@@ -101,7 +103,7 @@ class TLDR
|
|
101
103
|
end
|
102
104
|
|
103
105
|
# Booleans
|
104
|
-
[:no_helper, :verbose, :fail_fast, :no_emoji, :no_prepend, :warnings].each do |key|
|
106
|
+
[:no_helper, :verbose, :fail_fast, :no_emoji, :no_prepend, :warnings, :yes_i_know].each do |key|
|
105
107
|
merged_args[key] = defaults[key] if merged_args[key].nil?
|
106
108
|
end
|
107
109
|
|
data/lib/tldr/version.rb
CHANGED
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.
|
4
|
+
version: 0.8.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-
|
12
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: super_diff
|
@@ -45,6 +45,7 @@ email:
|
|
45
45
|
- tenderlove@ruby-lang.org
|
46
46
|
executables:
|
47
47
|
- tldr
|
48
|
+
- tldt
|
48
49
|
extensions: []
|
49
50
|
extra_rdoc_files: []
|
50
51
|
files:
|
@@ -54,6 +55,7 @@ files:
|
|
54
55
|
- README.md
|
55
56
|
- Rakefile
|
56
57
|
- exe/tldr
|
58
|
+
- exe/tldt
|
57
59
|
- lib/tldr.rb
|
58
60
|
- lib/tldr/argv_parser.rb
|
59
61
|
- lib/tldr/assertions.rb
|