mighty_test 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +7 -1
- data/lib/mighty_test/cli.rb +1 -0
- data/lib/mighty_test/console.rb +10 -3
- data/lib/mighty_test/minitest_runner.rb +1 -0
- data/lib/mighty_test/option_parser.rb +7 -4
- data/lib/mighty_test/version.rb +1 -1
- data/lib/mighty_test/watcher.rb +34 -41
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13aec80fee8a9c48191f615d0f3124046e6143637ef464ca2571fa51742aabe1
|
4
|
+
data.tar.gz: efd82536b85f8844722b3d085b821c7d330a7b545e8c6d6de26f33178654a33b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bf9883b319e0d53da7660e16dd23fbf447cf205eec617bc840f37357e74347d5c96191af1a0e0a642a5ab3f962fad73bbd09b9cdb05abb4575846bddfed7dbb
|
7
|
+
data.tar.gz: a7612ddc47104cbcf0efc5b054013be87c94f3367be7fc82fcade4dfa9953950b515be2e0659602f4ed967025457d19f85acb2dd1af8fa3eac9401d947887f8b
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -211,12 +211,18 @@ bin/mt
|
|
211
211
|
bin/mt --no-rg
|
212
212
|
```
|
213
213
|
|
214
|
-
|
214
|
+
<img alt="Screenshot of bin/mt output" width="618" src="https://raw.githubusercontent.com/mattbrictson/mighty_test/main/screenshot.png">
|
215
215
|
|
216
216
|
This functionality is provided by the [minitest-rg](https://github.com/minitest/minitest-rg) plugin, which is included with mighty_test.
|
217
217
|
|
218
218
|
## 💬 More Options
|
219
219
|
|
220
|
+
Use `-w` to enable Ruby warnings when running tests:
|
221
|
+
|
222
|
+
```sh
|
223
|
+
bin/mt -w
|
224
|
+
```
|
225
|
+
|
220
226
|
Minitest options are passed through to Minitest.
|
221
227
|
|
222
228
|
```sh
|
data/lib/mighty_test/cli.rb
CHANGED
data/lib/mighty_test/console.rb
CHANGED
@@ -16,9 +16,10 @@ module MightyTest
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def wait_for_keypress
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
with_raw_input do
|
20
|
+
sleep if stdin.eof?
|
21
|
+
stdin.getc
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
25
|
def play_sound(name, wait: false)
|
@@ -54,5 +55,11 @@ module MightyTest
|
|
54
55
|
def tty?
|
55
56
|
$stdout.respond_to?(:tty?) && $stdout.tty?
|
56
57
|
end
|
58
|
+
|
59
|
+
def with_raw_input(&)
|
60
|
+
return yield unless stdin.respond_to?(:raw) && tty?
|
61
|
+
|
62
|
+
stdin.raw(intr: true, &)
|
63
|
+
end
|
57
64
|
end
|
58
65
|
end
|
@@ -4,10 +4,10 @@ module MightyTest
|
|
4
4
|
class OptionParser
|
5
5
|
def parse(argv)
|
6
6
|
argv, literal_args = split(argv, "--")
|
7
|
-
options = parse_options!(argv)
|
8
|
-
|
7
|
+
options, extra_args = parse_options!(argv)
|
8
|
+
extra_args += parse_minitest_flags!(argv) unless options[:help]
|
9
9
|
|
10
|
-
[argv + literal_args,
|
10
|
+
[argv + literal_args, extra_args, options]
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_s
|
@@ -22,12 +22,15 @@ module MightyTest
|
|
22
22
|
|
23
23
|
def parse_options!(argv)
|
24
24
|
options = {}
|
25
|
+
extra_args = []
|
25
26
|
options[:all] = true if argv.delete("--all")
|
26
27
|
options[:watch] = true if argv.delete("--watch")
|
27
28
|
options[:version] = true if argv.delete("--version")
|
28
29
|
options[:help] = true if argv.delete("--help") || argv.delete("-h")
|
29
30
|
parse_shard(argv, options)
|
30
|
-
|
31
|
+
extra_args << "-w" if argv.delete("-w")
|
32
|
+
|
33
|
+
[options, extra_args]
|
31
34
|
end
|
32
35
|
|
33
36
|
def parse_minitest_flags!(argv)
|
data/lib/mighty_test/version.rb
CHANGED
data/lib/mighty_test/watcher.rb
CHANGED
@@ -1,47 +1,58 @@
|
|
1
1
|
module MightyTest
|
2
|
-
class Watcher
|
2
|
+
class Watcher
|
3
|
+
class ListenerTriggered < StandardError
|
4
|
+
attr_reader :paths
|
5
|
+
|
6
|
+
def initialize(paths)
|
7
|
+
@paths = paths
|
8
|
+
super()
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
3
12
|
WATCHING_FOR_CHANGES = 'Watching for changes to source and test files. Press "h" for help or "q" to quit.'.freeze
|
4
13
|
|
5
14
|
def initialize(console: Console.new, extra_args: [], file_system: FileSystem.new, system_proc: method(:system))
|
6
|
-
@queue = Thread::Queue.new
|
7
15
|
@console = console
|
8
16
|
@extra_args = extra_args
|
9
17
|
@file_system = file_system
|
10
18
|
@system_proc = system_proc
|
11
19
|
end
|
12
20
|
|
13
|
-
def run(iterations: :indefinitely) # rubocop:disable Metrics/
|
14
|
-
|
15
|
-
|
16
|
-
puts WATCHING_FOR_CHANGES
|
21
|
+
def run(iterations: :indefinitely) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
22
|
+
started = false
|
23
|
+
@foreground_thread = Thread.current
|
17
24
|
|
18
25
|
loop_for(iterations) do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
26
|
+
start_file_system_listener && puts(WATCHING_FOR_CHANGES) unless started
|
27
|
+
started = true
|
28
|
+
|
29
|
+
case console.wait_for_keypress
|
30
|
+
when "\r", "\n"
|
23
31
|
run_all_tests
|
24
|
-
|
32
|
+
when "a"
|
25
33
|
run_all_tests(flags: ["--all"])
|
26
|
-
|
34
|
+
when "d"
|
27
35
|
run_matching_test_files_from_git_diff
|
28
|
-
|
36
|
+
when "h"
|
29
37
|
show_help
|
30
|
-
|
38
|
+
when "q"
|
39
|
+
file_system_listener.stop
|
31
40
|
break
|
32
|
-
else
|
33
|
-
nil
|
34
41
|
end
|
42
|
+
rescue ListenerTriggered => e
|
43
|
+
run_matching_test_files(e.paths)
|
44
|
+
file_system_listener.start if file_system_listener.paused?
|
45
|
+
rescue Interrupt
|
46
|
+
file_system_listener&.stop
|
47
|
+
raise
|
35
48
|
end
|
36
49
|
ensure
|
37
50
|
puts "\nExiting."
|
38
|
-
file_system_listener&.stop
|
39
|
-
keypress_listener&.kill
|
40
51
|
end
|
41
52
|
|
42
53
|
private
|
43
54
|
|
44
|
-
attr_reader :console, :extra_args, :file_system, :file_system_listener, :
|
55
|
+
attr_reader :console, :extra_args, :file_system, :file_system_listener, :system_proc, :foreground_thread
|
45
56
|
|
46
57
|
def show_help
|
47
58
|
console.clear
|
@@ -105,36 +116,18 @@ module MightyTest
|
|
105
116
|
file_system_listener.stop if file_system_listener && !file_system_listener.stopped?
|
106
117
|
|
107
118
|
@file_system_listener = file_system.listen do |modified, added, _removed|
|
119
|
+
paths = [*modified, *added].uniq
|
120
|
+
next if paths.empty?
|
121
|
+
|
108
122
|
# Pause listener so that subsequent changes are queued up while we are running the tests
|
109
123
|
file_system_listener.pause unless file_system_listener.stopped?
|
110
|
-
|
124
|
+
foreground_thread.raise ListenerTriggered.new(paths)
|
111
125
|
end
|
112
126
|
end
|
113
127
|
alias restart_file_system_listener start_file_system_listener
|
114
128
|
|
115
|
-
def start_keypress_listener
|
116
|
-
@keypress_listener = Thread.new do
|
117
|
-
loop do
|
118
|
-
key = console.wait_for_keypress
|
119
|
-
break if key.nil?
|
120
|
-
|
121
|
-
post_event(:keypress, key)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
@keypress_listener.abort_on_exception = true
|
125
|
-
end
|
126
|
-
|
127
129
|
def loop_for(iterations, &)
|
128
130
|
iterations == :indefinitely ? loop(&) : iterations.times(&)
|
129
131
|
end
|
130
|
-
|
131
|
-
def await_next_event
|
132
|
-
file_system_listener.start if file_system_listener.paused?
|
133
|
-
@queue.pop
|
134
|
-
end
|
135
|
-
|
136
|
-
def post_event(*event)
|
137
|
-
@queue << event
|
138
|
-
end
|
139
132
|
end
|
140
133
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mighty_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brictson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
|
-
rubygems_version: 3.5.
|
128
|
+
rubygems_version: 3.5.9
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: A modern Minitest runner for TDD, with watch mode and more
|