test_launcher 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +126 -33
- data/lib/test_launcher/cli.rb +25 -11
- data/lib/test_launcher/cli/input_parser.rb +29 -14
- data/lib/test_launcher/cli/options.rb +19 -0
- data/lib/test_launcher/cli/request.rb +6 -0
- data/lib/test_launcher/queries.rb +16 -2
- data/lib/test_launcher/shell/history_runner.rb +41 -0
- data/lib/test_launcher/version.rb +1 -1
- data/test/test_helpers/integration_helper.rb +1 -1
- data/test/test_launcher/cli/input_parser_test.rb +33 -26
- data/test/test_launcher/ex_unit_integration_test.rb +24 -3
- data/test/test_launcher/minitest_integration_test.rb +28 -4
- data/test/test_launcher/queries/generic_query_test.rb +2 -2
- data/test/test_launcher/rspec_integration_test.rb +25 -3
- data/tmp/.gitkeep +0 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f1ee0a4fbf3c9e6973fd82d15b3cbe1c0751153
|
4
|
+
data.tar.gz: b35970bb6e285cd651b83f7441af0138a5f3cc8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3019301764f5ab3dc68b3dde5af0641c6457660f4bda05d828476a76b3297d75cbb3de01fafbcedd6c392e6d76fc67eec0c2b1fa8b0816736c646bb230776ab0
|
7
|
+
data.tar.gz: 2c842f83bbb877e31b6271093aa31ee86522989852e3e5ca909bc7a7a9a1898091d1d3fbc2dbe6ce03553c8239fb6e750b96c8ab26a15212054f72d11d40714a
|
data/README.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
Test Launcher takes a search query and tries to figure out what test you want to run. It makes running tests on the command line easy! Super bonus!
|
4
4
|
|
5
|
+
For example:
|
6
|
+
|
7
|
+
```
|
8
|
+
test_launcher test_name
|
9
|
+
|
10
|
+
#=> Found 1 example in 1 file
|
11
|
+
#=> ruby -I test test/models/blog_post_test.rb --name=test_name
|
12
|
+
```
|
13
|
+
|
5
14
|
You might use Test Launcher for two reasons:
|
6
15
|
|
7
16
|
1. You run tests from the command line a lot.
|
@@ -9,7 +18,19 @@ You might use Test Launcher for two reasons:
|
|
9
18
|
|
10
19
|
It was built for Minitest, but it also has basic support for RSpec and ExUnit.
|
11
20
|
|
12
|
-
|
21
|
+
---
|
22
|
+
|
23
|
+
### Table of Contents
|
24
|
+
1. [Installation](#installation)
|
25
|
+
1. [Examples](#examples)
|
26
|
+
1. [Usage and Options](#usage-and-options)
|
27
|
+
1. [Search Prioty](#search-priority)
|
28
|
+
1. [Running all changed tests](#running-all-changed-tests)
|
29
|
+
1. [Aliases](#quit-typing-so-much)
|
30
|
+
1. [RubyMine Support](#rubymine-support)
|
31
|
+
1. [Visual Studio Code Support](#visual-studio-code-support)
|
32
|
+
1. [Atom Support](#atom-support)
|
33
|
+
1. [What's going on in there?](#whats-going-on-in-there)
|
13
34
|
|
14
35
|
# Installation
|
15
36
|
|
@@ -21,7 +42,7 @@ gem install test_launcher
|
|
21
42
|
|
22
43
|
Under the hood, it uses git to determine your project root. If you're on an app that's not using git, let me know and I can remove that dependency.
|
23
44
|
|
24
|
-
|
45
|
+
# Examples
|
25
46
|
|
26
47
|
Let's suppose you want to run the test `test_name` in your `blog_post_test.rb`.
|
27
48
|
|
@@ -138,30 +159,47 @@ test_launcher springified_test
|
|
138
159
|
|
139
160
|
Test Launcher will not use spring if the `DISABLE_SPRING=1` environment variable is set.
|
140
161
|
|
141
|
-
|
162
|
+
# Usage and Options
|
163
|
+
|
164
|
+
```
|
165
|
+
Common Usage: `test_launcher "search string" [--all]`
|
166
|
+
|
167
|
+
VERSION: 2.2.0
|
168
|
+
|
169
|
+
-a, --all Run all matching tests. Defaults to false.
|
170
|
+
-h, --help Prints this help
|
171
|
+
-v, --version Display the version info
|
172
|
+
-f, --framework framework The testing framework being used. Valid options: ['minitest', 'rspec', 'ex_unit', 'guess']. Defaults to 'guess'
|
173
|
+
-n, --name name Name of testcase/example to run. This will pass through to the selected framework without verifying that the example actually exists. This option really only exists to work with tooling that will automatically run your tests. You shouldn't have much need for this.
|
174
|
+
--example example alias of name
|
175
|
+
-r, --rerun Rerun the previous test. This flag cannot be set when entering search terms
|
176
|
+
--disable-spring Disable spring. You can also set the env var: DISABLE_SPRING=1
|
177
|
+
```
|
178
|
+
|
179
|
+
# Search Priority
|
142
180
|
|
143
181
|
Test Launcher searches for tests based on your input.
|
144
182
|
|
145
183
|
Suppose you type `test_launcher thing`. It will run tests using this priority preference:
|
146
184
|
|
147
185
|
1. A single test file
|
148
|
-
|
186
|
+
- matches on `thing_test.rb`
|
149
187
|
|
150
188
|
1. A single, specific test method name or partial name
|
151
|
-
|
189
|
+
- `def test_the_thing`
|
152
190
|
|
153
191
|
1. Multiple test method names in the same file
|
154
|
-
|
192
|
+
- `def test_the_thing` and `def test_the_other_thing`
|
155
193
|
|
156
194
|
1. Any test file based on a generic search
|
157
|
-
|
195
|
+
- runs `stuff_test.rb` because it found the word `thing` inside of it
|
158
196
|
|
159
197
|
If your query looks like it's specifying a line number (e.g. `file_test.rb:17`), that search will be preferred.
|
160
198
|
|
161
199
|
Any time it matches multiple files, it will default to running the most recently edited file. You can append `--all` if you want to run all matching tests, even if they are in different engines/gems!
|
162
200
|
|
163
201
|
|
164
|
-
|
202
|
+
# Running all changed tests
|
165
203
|
|
166
204
|
This will find all uncommitted `*_test.rb` files and pass them to test_launcher to be run. Use this before you commit so you don't accidentally commit a test you've broken.
|
167
205
|
|
@@ -193,7 +231,7 @@ tdiff origin/master
|
|
193
231
|
|
194
232
|
Super fun!
|
195
233
|
|
196
|
-
|
234
|
+
# Quit typing so much!
|
197
235
|
|
198
236
|
This gem installs one executable called `test_launcher`.
|
199
237
|
|
@@ -205,14 +243,43 @@ For me, that's way too much to type, so I recommend adding an alias to your `.ba
|
|
205
243
|
|
206
244
|
```
|
207
245
|
alias t='test_launcher'
|
208
|
-
|
209
|
-
# If you are using RVM, use this: (see below for more details)
|
210
|
-
alias t='NOEXEC_DISABLE=1 test_launcher'
|
211
246
|
```
|
212
247
|
|
213
248
|
Now you can just type `t` instead of `test_launcher`. Much nicer!
|
214
249
|
|
215
250
|
|
251
|
+
## Optimizing with RVM
|
252
|
+
|
253
|
+
By default, RVM installs a hook to remove the need to run `bundle exec`. When you run a gem command, it will search your bundle to see if that command is included in your bundle. If it is, it will run that version of the command. If it's not in your bundle, then it will fall back to the global gem. You can read more about it on [rubygems-bundler](https://github.com/rvm/rubygems-bundler).
|
254
|
+
|
255
|
+
Test Launcher is not installed in your bundle. This means that the time that Bundler spends resolving your Gemfile to check if there's a test\_launcher executable in your bundle is wasted. For most projects, the amount of time this takes is probably unnoticeable.
|
256
|
+
|
257
|
+
On projects with lots of dependencies, this wasted time can be significant.
|
258
|
+
|
259
|
+
For example, in a large project, we get a nice improvement:
|
260
|
+
|
261
|
+
```
|
262
|
+
$: time test_launcher something_that_no_test_says
|
263
|
+
#=> Could not find any tests.
|
264
|
+
|
265
|
+
#=> real 0m2.214s
|
266
|
+
#=> user 0m1.407s
|
267
|
+
#=> sys 0m1.062s
|
268
|
+
|
269
|
+
$: time NOEXEC_DISABLE=1 test_launcher something_that_no_test_says
|
270
|
+
#=> Could not find any tests.
|
271
|
+
|
272
|
+
#=> real 0m1.412s
|
273
|
+
#=> user 0m0.745s
|
274
|
+
#=> sys 0m0.945s
|
275
|
+
```
|
276
|
+
|
277
|
+
I suggest that if you are using RVM, you may as well make this your alias:
|
278
|
+
|
279
|
+
```
|
280
|
+
alias t='NOEXEC_DISABLE=1 test_launcher'
|
281
|
+
```
|
282
|
+
|
216
283
|
# RubyMine Support
|
217
284
|
|
218
285
|
When working with inline gems/engines, RubyMine has a hard time figuring out what `test` folders to push into the load path for Minitest. RubyMine also does not understand that in a project with inline engines, some of them may use Spring and some may not. When working with inline gems/engines/apps in RubyMine, you end up having to 'Edit Configurations...' many times a day. This is a bummer.
|
@@ -243,36 +310,62 @@ Replace it with:
|
|
243
310
|
|
244
311
|
Using Test Launcher to hijack your RubyMine run configuration should allow you to debug any test as well without issue.
|
245
312
|
|
246
|
-
#
|
247
|
-
|
248
|
-
By default, RVM installs a hook to remove the need to run `bundle exec`. When you run a gem command, it will search your bundle to see if that command is included in your bundle. If it is, it will run that version of the command. If it's not in your bundle, then it will fall back to the global gem. You can read more about it on [rubygems-bundler](https://github.com/rvm/rubygems-bundler).
|
249
|
-
|
250
|
-
Test Launcher is not installed in your bundle. This means that the time that Bundler spends resolving your Gemfile to check if there's a test\_launcher executable in your bundle is wasted. For most projects, the amount of time this takes is probably unnoticeable.
|
313
|
+
# Visual Studio Code Support
|
251
314
|
|
252
|
-
|
315
|
+
To run tests from the editor, we need to define some tasks. I like to have three tasks defined: run the test that contains the cursor, run the whole test file, and rerun the last test.
|
253
316
|
|
254
|
-
|
317
|
+
You can add these to your `.vscode/tasks.json` file:
|
255
318
|
|
256
319
|
```
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
320
|
+
{
|
321
|
+
"version": "0.1.0",
|
322
|
+
"tasks": [
|
323
|
+
{
|
324
|
+
"taskName": "run-test-line",
|
325
|
+
"command": "test_launcher",
|
326
|
+
"args": ["${file}:${lineNumber}"]
|
327
|
+
},
|
328
|
+
{
|
329
|
+
"taskName": "run-test-file",
|
330
|
+
"command": "test_launcher",
|
331
|
+
"args": ["${file}"]
|
332
|
+
},
|
333
|
+
{
|
334
|
+
"taskName": "rerun-last-test",
|
335
|
+
"command": "test_launcher",
|
336
|
+
"args": ["--rerun"]
|
337
|
+
}
|
338
|
+
]
|
339
|
+
}
|
340
|
+
```
|
266
341
|
|
267
|
-
|
268
|
-
|
269
|
-
|
342
|
+
Next, we need some key-combos to trigger each task. Add this to your `.vscode/keybindings.json` and tweak the key-combos to your liking:
|
343
|
+
```
|
344
|
+
...
|
345
|
+
{
|
346
|
+
"key": "shift+cmd+r",
|
347
|
+
"command": "workbench.action.tasks.runTask",
|
348
|
+
"args": "run-test-line"
|
349
|
+
},
|
350
|
+
{
|
351
|
+
"key": "alt+cmd+r",
|
352
|
+
"command": "workbench.action.tasks.runTask",
|
353
|
+
"args": "run-test-file"
|
354
|
+
},
|
355
|
+
{
|
356
|
+
"key": "cmd+r",
|
357
|
+
"command": "workbench.action.tasks.runTask",
|
358
|
+
"args": "rerun-last-test"
|
359
|
+
}
|
360
|
+
...
|
270
361
|
```
|
271
362
|
|
272
|
-
|
363
|
+
# Atom Support
|
364
|
+
|
365
|
+
The [ruby-test](https://github.com/moxley/atom-ruby-test) extension works well for testing ruby apps, so there's only a need to use test\_launcher if you work on a project with inline engines/gems. If that's the case, you can set it to use test\_launcher in the settings like so:
|
273
366
|
|
274
367
|
```
|
275
|
-
|
368
|
+
test_launcher {relative_path} --name={regex}
|
276
369
|
```
|
277
370
|
|
278
371
|
# What's going on in there?
|
data/lib/test_launcher/cli.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
require "test_launcher/shell/
|
1
|
+
require "test_launcher/shell/history_runner"
|
2
2
|
require "test_launcher/search"
|
3
3
|
require "test_launcher/cli/input_parser"
|
4
4
|
require "test_launcher/queries"
|
5
|
+
require "test_launcher/cli/request"
|
5
6
|
|
6
7
|
module TestLauncher
|
7
8
|
module CLI
|
8
|
-
|
9
|
-
class MultiRequestQuery < Struct.new(:requests)
|
10
|
-
|
9
|
+
class MultiFrameworkQuery < Struct.new(:cli_options)
|
11
10
|
def command
|
12
11
|
command = nil
|
13
12
|
command_finders.each do |command_finder|
|
@@ -18,19 +17,34 @@ module TestLauncher
|
|
18
17
|
end
|
19
18
|
|
20
19
|
def command_finders
|
21
|
-
|
20
|
+
cli_options.frameworks.map do |framework|
|
21
|
+
Queries::CommandFinder.new(request_for(framework))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def request_for(framework)
|
26
|
+
Request.new(
|
27
|
+
framework: framework,
|
28
|
+
search_string: cli_options.search_string,
|
29
|
+
rerun: cli_options.rerun,
|
30
|
+
run_all: cli_options.run_all,
|
31
|
+
disable_spring: cli_options.disable_spring,
|
32
|
+
example_name: cli_options.example_name,
|
33
|
+
shell: cli_options.shell,
|
34
|
+
searcher: cli_options.searcher,
|
35
|
+
)
|
22
36
|
end
|
23
37
|
end
|
24
38
|
|
25
|
-
def self.launch(argv, env, shell: Shell::
|
26
|
-
|
39
|
+
def self.launch(argv, env, shell: Shell::HistoryRunner.new, searcher: Search.searcher(shell))
|
40
|
+
options = CLI::InputParser.new(
|
27
41
|
argv,
|
28
42
|
env
|
29
|
-
).
|
30
|
-
|
31
|
-
command = MultiRequestQuery.new(requests).command
|
43
|
+
).parsed_options(shell: shell, searcher: searcher)
|
32
44
|
|
33
|
-
if
|
45
|
+
if options.rerun
|
46
|
+
shell.reexec
|
47
|
+
elsif command = MultiFrameworkQuery.new(options).command
|
34
48
|
shell.exec command
|
35
49
|
else
|
36
50
|
shell.warn "No tests found."
|
@@ -5,7 +5,7 @@ require "test_launcher/version"
|
|
5
5
|
require "test_launcher/frameworks/rspec"
|
6
6
|
require "test_launcher/frameworks/minitest"
|
7
7
|
require "test_launcher/frameworks/ex_unit"
|
8
|
-
require "test_launcher/cli/
|
8
|
+
require "test_launcher/cli/options"
|
9
9
|
|
10
10
|
module TestLauncher
|
11
11
|
module CLI
|
@@ -35,8 +35,16 @@ VERSION: #{TestLauncher::VERSION}
|
|
35
35
|
exit
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
if @search_string.size == 0
|
38
|
+
def parsed_options(shell:, searcher:)
|
39
|
+
if @search_string.size == 0 && !@options[:rerun]
|
40
|
+
puts "Enter a search term"
|
41
|
+
puts "----"
|
42
|
+
puts option_parser
|
43
|
+
exit
|
44
|
+
elsif @search_string.size > 0 && @options[:rerun]
|
45
|
+
puts "Cannot specify search terms and use --rerun flag"
|
46
|
+
puts "----"
|
47
|
+
|
40
48
|
puts option_parser
|
41
49
|
exit
|
42
50
|
end
|
@@ -52,17 +60,16 @@ VERSION: #{TestLauncher::VERSION}
|
|
52
60
|
[Frameworks::Minitest, Frameworks::RSpec, Frameworks::ExUnit]
|
53
61
|
end
|
54
62
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
63
|
+
Options.new(
|
64
|
+
search_string: @search_string.join(" "),
|
65
|
+
run_all: !!@options[:run_all],
|
66
|
+
rerun: !!@options[:rerun],
|
67
|
+
disable_spring: @options[:disable_spring] || !!@env["DISABLE_SPRING"],
|
68
|
+
example_name: @options[:name],
|
69
|
+
frameworks: frameworks,
|
70
|
+
shell: shell,
|
71
|
+
searcher: searcher
|
72
|
+
)
|
66
73
|
end
|
67
74
|
|
68
75
|
def options
|
@@ -100,6 +107,14 @@ VERSION: #{TestLauncher::VERSION}
|
|
100
107
|
opts.on("--example example", "alias of name") do |example|
|
101
108
|
options[:name] = example
|
102
109
|
end
|
110
|
+
|
111
|
+
opts.on("-r", "--rerun", "Rerun the previous test. This flag cannot be set when entering search terms") do
|
112
|
+
options[:rerun] = true
|
113
|
+
end
|
114
|
+
|
115
|
+
opts.on("--disable-spring", "Disable spring. You can also set the env var: DISABLE_SPRING=1") do
|
116
|
+
options[:disable_spring] = true
|
117
|
+
end
|
103
118
|
end
|
104
119
|
end
|
105
120
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module TestLauncher
|
2
|
+
module CLI
|
3
|
+
class Options < Struct.new(
|
4
|
+
:search_string,
|
5
|
+
:frameworks,
|
6
|
+
:rerun,
|
7
|
+
:run_all,
|
8
|
+
:disable_spring,
|
9
|
+
:example_name,
|
10
|
+
:shell,
|
11
|
+
:searcher
|
12
|
+
)
|
13
|
+
def initialize(**args)
|
14
|
+
raise ArgumentError.new("These keys are allowed and required: #{members}") unless args.keys.sort == members.sort
|
15
|
+
args.each { |k, v| self[k] = v }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -4,6 +4,7 @@ module TestLauncher
|
|
4
4
|
def initialize(
|
5
5
|
search_string:,
|
6
6
|
framework:,
|
7
|
+
rerun: false,
|
7
8
|
run_all: false,
|
8
9
|
disable_spring: false,
|
9
10
|
example_name: nil,
|
@@ -12,6 +13,7 @@ module TestLauncher
|
|
12
13
|
)
|
13
14
|
@search_string = search_string
|
14
15
|
@framework = framework
|
16
|
+
@rerun = rerun
|
15
17
|
@run_all = run_all
|
16
18
|
@disable_spring = disable_spring
|
17
19
|
@example_name = example_name
|
@@ -27,6 +29,10 @@ module TestLauncher
|
|
27
29
|
@run_all
|
28
30
|
end
|
29
31
|
|
32
|
+
def rerun?
|
33
|
+
@rerun
|
34
|
+
end
|
35
|
+
|
30
36
|
def disable_spring?
|
31
37
|
@disable_spring
|
32
38
|
end
|
@@ -41,6 +41,10 @@ module TestLauncher
|
|
41
41
|
commandify(LineNumberQuery)
|
42
42
|
end
|
43
43
|
|
44
|
+
def rerun
|
45
|
+
commandify(RerunQuery)
|
46
|
+
end
|
47
|
+
|
44
48
|
def request
|
45
49
|
@request
|
46
50
|
end
|
@@ -83,7 +87,7 @@ module TestLauncher
|
|
83
87
|
end
|
84
88
|
|
85
89
|
def one_file?
|
86
|
-
|
90
|
+
file_count == 1
|
87
91
|
end
|
88
92
|
|
89
93
|
def file_count
|
@@ -137,6 +141,14 @@ module TestLauncher
|
|
137
141
|
end
|
138
142
|
end
|
139
143
|
|
144
|
+
class RerunQuery < BaseQuery
|
145
|
+
def command
|
146
|
+
if File.exists?("/tmp/test_launcher__last_run")
|
147
|
+
File.read("/tmp/test_launcher__last_run").chomp
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
140
152
|
class MultiPathQuery < BaseQuery
|
141
153
|
def command
|
142
154
|
return unless request.search_string.include?(" ")
|
@@ -398,7 +410,9 @@ module TestLauncher
|
|
398
410
|
|
399
411
|
class GenericQuery < BaseQuery
|
400
412
|
def command
|
401
|
-
if request.
|
413
|
+
if request.rerun?
|
414
|
+
command_finder.rerun
|
415
|
+
elsif request.example_name
|
402
416
|
command_finder.specified_name
|
403
417
|
else
|
404
418
|
command_finder.full_search
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "delegate"
|
2
|
+
require "test_launcher/shell/runner"
|
3
|
+
|
4
|
+
module TestLauncher
|
5
|
+
module Shell
|
6
|
+
class HistoryRunner < SimpleDelegator
|
7
|
+
# delegates to @shell
|
8
|
+
|
9
|
+
def initialize(shell: Shell::Runner.new, history_path: "/tmp/test_launcher__history")
|
10
|
+
@shell = shell
|
11
|
+
@history_path = history_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def exec(cmd)
|
15
|
+
record(cmd)
|
16
|
+
@shell.exec(cmd)
|
17
|
+
end
|
18
|
+
|
19
|
+
def reexec
|
20
|
+
if recall
|
21
|
+
@shell.exec(recall)
|
22
|
+
else
|
23
|
+
warn "Cannot rerun: history file not found or is empty"
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def record(cmd)
|
29
|
+
File.write(@history_path, cmd)
|
30
|
+
end
|
31
|
+
|
32
|
+
def recall
|
33
|
+
@recall ||= File.file?(@history_path) && File.read(@history_path).chomp
|
34
|
+
end
|
35
|
+
|
36
|
+
def __getobj__
|
37
|
+
@shell
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -3,6 +3,7 @@ require "test_launcher/shell/runner"
|
|
3
3
|
|
4
4
|
require "test_launcher/cli"
|
5
5
|
require "test_helpers/mocks"
|
6
|
+
require "test_launcher/shell/history_runner"
|
6
7
|
|
7
8
|
module TestLauncher
|
8
9
|
module IntegrationHelper
|
@@ -25,7 +26,6 @@ module TestLauncher
|
|
25
26
|
|
26
27
|
private
|
27
28
|
|
28
|
-
|
29
29
|
def shell_mock
|
30
30
|
@shell_mock ||= IntegrationShell.new
|
31
31
|
end
|
@@ -6,66 +6,73 @@ module TestLauncher
|
|
6
6
|
class InputParserTest < TestCase
|
7
7
|
|
8
8
|
def test_request__defaults
|
9
|
-
|
9
|
+
options = parse("a_string", {})
|
10
10
|
|
11
|
-
assert_equal "a_string",
|
12
|
-
assert_equal false,
|
13
|
-
assert_equal false,
|
14
|
-
assert_equal nil,
|
11
|
+
assert_equal "a_string", options.search_string
|
12
|
+
assert_equal false, options.run_all
|
13
|
+
assert_equal false, options.disable_spring
|
14
|
+
assert_equal nil, options.example_name
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_request__all
|
18
|
-
|
18
|
+
options = parse("a_string --all", {})
|
19
19
|
|
20
|
-
assert_equal "a_string",
|
21
|
-
assert_equal true,
|
20
|
+
assert_equal "a_string", options.search_string
|
21
|
+
assert_equal true, options.run_all
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_request__rerun
|
25
|
+
options = parse("--rerun", {})
|
26
|
+
|
27
|
+
assert_equal true, options.rerun
|
28
|
+
end
|
29
|
+
|
30
|
+
|
24
31
|
def test_request__disable_spring
|
25
|
-
|
32
|
+
options = parse("a_string", {"DISABLE_SPRING" => "1"})
|
26
33
|
|
27
|
-
assert_equal "a_string",
|
28
|
-
assert_equal true,
|
34
|
+
assert_equal "a_string", options.search_string
|
35
|
+
assert_equal true, options.disable_spring
|
29
36
|
end
|
30
37
|
|
31
38
|
def test_request__example_name
|
32
|
-
|
39
|
+
options = parse("path/to/file_test.rb --name example_name", {})
|
33
40
|
|
34
|
-
assert_equal "path/to/file_test.rb",
|
35
|
-
assert_equal "example_name",
|
41
|
+
assert_equal "path/to/file_test.rb", options.search_string
|
42
|
+
assert_equal "example_name", options.example_name
|
36
43
|
end
|
37
44
|
|
38
45
|
def test_request__example_name__regex
|
39
|
-
|
46
|
+
options = parse("path/to/file_test.rb --name /example_name/", {})
|
40
47
|
|
41
|
-
assert_equal "path/to/file_test.rb",
|
42
|
-
assert_equal "/example_name/",
|
48
|
+
assert_equal "path/to/file_test.rb", options.search_string
|
49
|
+
assert_equal "/example_name/", options.example_name
|
43
50
|
end
|
44
51
|
|
45
52
|
def test_request__example_name__with_equal_sign
|
46
|
-
|
53
|
+
options = parse("path/to/file_test.rb --name=/example_name/", {})
|
47
54
|
|
48
|
-
assert_equal "path/to/file_test.rb",
|
49
|
-
assert_equal "/example_name/",
|
55
|
+
assert_equal "path/to/file_test.rb", options.search_string
|
56
|
+
assert_equal "/example_name/", options.example_name
|
50
57
|
end
|
51
58
|
|
52
59
|
def test_request__example_name__short_option
|
53
|
-
|
60
|
+
options = parse("path/to/file_test.rb -n /example_name/", {})
|
54
61
|
|
55
|
-
assert_equal "path/to/file_test.rb",
|
56
|
-
assert_equal "/example_name/",
|
62
|
+
assert_equal "path/to/file_test.rb", options.search_string
|
63
|
+
assert_equal "/example_name/", options.example_name
|
57
64
|
end
|
58
65
|
|
59
66
|
def test_joins_spaces
|
60
|
-
|
67
|
+
options = parse("query with spaces", {})
|
61
68
|
|
62
|
-
assert_equal "query with spaces",
|
69
|
+
assert_equal "query with spaces", options.search_string
|
63
70
|
end
|
64
71
|
|
65
72
|
private
|
66
73
|
|
67
74
|
def parse(input, env)
|
68
|
-
InputParser.new(input.split(" "), env).
|
75
|
+
InputParser.new(input.split(" "), env).parsed_options(shell: dummy_shell, searcher: nil)
|
69
76
|
end
|
70
77
|
end
|
71
78
|
end
|
@@ -5,10 +5,10 @@ module TestLauncher
|
|
5
5
|
class ExUnitIntegrationTest < TestCase
|
6
6
|
include IntegrationHelper
|
7
7
|
|
8
|
-
def launch(query, env: {}, searcher:)
|
8
|
+
def launch(query, env: {}, searcher:, shell: shell_mock)
|
9
9
|
query += " --framework ex_unit "
|
10
|
-
|
11
|
-
CLI.launch(query.split(" "), env, shell:
|
10
|
+
shell.reset
|
11
|
+
CLI.launch(query.split(" "), env, shell: shell, searcher: searcher)
|
12
12
|
end
|
13
13
|
|
14
14
|
def test__by_example__single_method
|
@@ -388,5 +388,26 @@ module TestLauncher
|
|
388
388
|
launch("file_1_test.exs:1", searcher: searcher)
|
389
389
|
assert_equal "cd /src/inline/project && mix test /src/inline/project/test/file_1_test.exs:1", shell_mock.recall_exec
|
390
390
|
end
|
391
|
+
|
392
|
+
def test__rerun
|
393
|
+
searcher = MemorySearcher.new do |searcher|
|
394
|
+
searcher.mock_file do |f|
|
395
|
+
f.path "/src/test/file_1_test.exs"
|
396
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
397
|
+
end
|
398
|
+
searcher.mock_file do |f|
|
399
|
+
f.path "/src/test/file_2_test.exs"
|
400
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
history_shell = Shell::HistoryRunner.new(shell: shell_mock, history_path: File.expand_path(File.join(__dir__, '../../tmp/test_history.log')))
|
405
|
+
|
406
|
+
launch("file_1_test.exs", searcher: searcher, shell: history_shell)
|
407
|
+
assert_equal "cd /src && mix test /src/test/file_1_test.exs", history_shell.recall_exec
|
408
|
+
|
409
|
+
launch("--rerun", searcher: searcher, shell: history_shell)
|
410
|
+
assert_equal "cd /src && mix test /src/test/file_1_test.exs", history_shell.recall_exec
|
411
|
+
end
|
391
412
|
end
|
392
413
|
end
|
@@ -5,10 +5,10 @@ module TestLauncher
|
|
5
5
|
class MinitestIntegrationTest < TestCase
|
6
6
|
include IntegrationHelper
|
7
7
|
|
8
|
-
def launch(query, env: {}, searcher:)
|
8
|
+
def launch(query, env: {}, searcher:, shell: shell_mock)
|
9
9
|
query += " --framework minitest "
|
10
|
-
|
11
|
-
CLI.launch(query.split(" "), env, shell:
|
10
|
+
shell.reset
|
11
|
+
CLI.launch(query.split(" "), env, shell: shell, searcher: searcher)
|
12
12
|
end
|
13
13
|
|
14
14
|
def test__by_example__single_method
|
@@ -269,12 +269,14 @@ module TestLauncher
|
|
269
269
|
end
|
270
270
|
end
|
271
271
|
|
272
|
-
|
273
272
|
launch("class_1_test.rb", env: {}, searcher: searcher)
|
274
273
|
assert_equal "cd /src && bundle exec spring testunit /src/test/class_1_test.rb", shell_mock.recall_exec
|
275
274
|
|
276
275
|
launch("class_1_test.rb", env: {"DISABLE_SPRING" => "1"}, searcher: searcher)
|
277
276
|
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/class_1_test.rb", shell_mock.recall_exec
|
277
|
+
|
278
|
+
launch("class_1_test.rb --disable-spring", searcher: searcher)
|
279
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/class_1_test.rb", shell_mock.recall_exec
|
278
280
|
end
|
279
281
|
|
280
282
|
def test__by_regex__one_match
|
@@ -625,5 +627,27 @@ module TestLauncher
|
|
625
627
|
launch("file_1_test.rb:1", searcher: searcher)
|
626
628
|
assert shell_mock.recall(:warn).first.first.to_s.match(/Open an issue/)
|
627
629
|
end
|
630
|
+
|
631
|
+
def test__rerun
|
632
|
+
searcher = MemorySearcher.new do |searcher|
|
633
|
+
searcher.mock_file do |f|
|
634
|
+
f.path "/src/test/file_1_test.rb"
|
635
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
636
|
+
end
|
637
|
+
|
638
|
+
searcher.mock_file do |f|
|
639
|
+
f.path "/src/test/file_2_test.rb"
|
640
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
641
|
+
end
|
642
|
+
end
|
643
|
+
|
644
|
+
history_shell = Shell::HistoryRunner.new(shell: shell_mock, history_path: File.expand_path(File.join(__dir__, '../../tmp/test_history.log')))
|
645
|
+
|
646
|
+
launch("file_1_test.rb", searcher: searcher, shell: history_shell)
|
647
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", history_shell.recall_exec
|
648
|
+
|
649
|
+
launch("--rerun", searcher: searcher, shell: history_shell )
|
650
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", history_shell.recall_exec
|
651
|
+
end
|
628
652
|
end
|
629
653
|
end
|
@@ -10,13 +10,13 @@ module TestLauncher
|
|
10
10
|
def test__specified_name
|
11
11
|
command_finder = Mock.new(Queries::CommandFinder, specified_name: :specified_name)
|
12
12
|
|
13
|
-
assert_equal :specified_name, GenericQuery.new(MockRequest.new(example_name: "name_present"), command_finder).command
|
13
|
+
assert_equal :specified_name, GenericQuery.new(MockRequest.new(example_name: "name_present", rerun?: false), command_finder).command
|
14
14
|
end
|
15
15
|
|
16
16
|
def test__example_name
|
17
17
|
command_finder = Mock.new(Queries::CommandFinder, full_search: :full_search)
|
18
18
|
|
19
|
-
assert_equal :full_search, GenericQuery.new(MockRequest.new(example_name: nil), command_finder).command
|
19
|
+
assert_equal :full_search, GenericQuery.new(MockRequest.new(example_name: nil, rerun?: false), command_finder).command
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -5,10 +5,10 @@ module TestLauncher
|
|
5
5
|
class RspecIntegrationTest < TestCase
|
6
6
|
include IntegrationHelper
|
7
7
|
|
8
|
-
def launch(query, env: {}, searcher:)
|
8
|
+
def launch(query, env: {}, searcher:, shell: shell_mock)
|
9
9
|
query += " --framework rspec"
|
10
|
-
|
11
|
-
CLI.launch(query.split(" "), env, shell:
|
10
|
+
shell.reset
|
11
|
+
CLI.launch(query.split(" "), env, shell: shell, searcher: searcher)
|
12
12
|
end
|
13
13
|
|
14
14
|
def test__by_example__single_example
|
@@ -548,5 +548,27 @@ module TestLauncher
|
|
548
548
|
launch("file_1_spec.rb:1", searcher: searcher)
|
549
549
|
assert_equal "cd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb:1", shell_mock.recall_exec
|
550
550
|
end
|
551
|
+
|
552
|
+
def test__rerun
|
553
|
+
searcher = MemorySearcher.new do |searcher|
|
554
|
+
searcher.mock_file do |f|
|
555
|
+
f.path "/src/spec/file_1_spec.rb"
|
556
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
557
|
+
end
|
558
|
+
|
559
|
+
searcher.mock_file do |f|
|
560
|
+
f.path "/src/spec/file_2_spec.rb"
|
561
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
history_shell = Shell::HistoryRunner.new(shell: shell_mock, history_path: File.expand_path(File.join(__dir__, '../../tmp/test_history.log')))
|
566
|
+
|
567
|
+
launch("file_1_spec.rb", searcher: searcher, shell: history_shell)
|
568
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", history_shell.recall_exec
|
569
|
+
|
570
|
+
launch("--rerun", searcher: searcher, shell: history_shell)
|
571
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", history_shell.recall_exec
|
572
|
+
end
|
551
573
|
end
|
552
574
|
end
|
data/tmp/.gitkeep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_launcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Kinnecom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/test_launcher/base_error.rb
|
57
57
|
- lib/test_launcher/cli.rb
|
58
58
|
- lib/test_launcher/cli/input_parser.rb
|
59
|
+
- lib/test_launcher/cli/options.rb
|
59
60
|
- lib/test_launcher/cli/request.rb
|
60
61
|
- lib/test_launcher/frameworks/base.rb
|
61
62
|
- lib/test_launcher/frameworks/ex_unit.rb
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- lib/test_launcher/search/ag.rb
|
71
72
|
- lib/test_launcher/search/git.rb
|
72
73
|
- lib/test_launcher/shell/color.rb
|
74
|
+
- lib/test_launcher/shell/history_runner.rb
|
73
75
|
- lib/test_launcher/shell/runner.rb
|
74
76
|
- lib/test_launcher/version.rb
|
75
77
|
- test/install
|
@@ -98,6 +100,7 @@ files:
|
|
98
100
|
- test/test_launcher/search/ag_test.rb
|
99
101
|
- test/test_launcher/search/git_test.rb
|
100
102
|
- test_launcher.gemspec
|
103
|
+
- tmp/.gitkeep
|
101
104
|
homepage: http://github.com/petekinnecom/test_launcher
|
102
105
|
licenses:
|
103
106
|
- MIT
|
@@ -148,4 +151,3 @@ test_files:
|
|
148
151
|
- test/test_launcher/rubymine_test.rb
|
149
152
|
- test/test_launcher/search/ag_test.rb
|
150
153
|
- test/test_launcher/search/git_test.rb
|
151
|
-
has_rdoc:
|