test_launcher 2.20.0 → 2.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/test_launcher/frameworks/minitest.rb +7 -2
- data/lib/test_launcher/search/git.rb +2 -1
- data/lib/test_launcher/version.rb +1 -1
- data/test_launcher.gemspec +1 -1
- metadata +3 -60
- data/.gitignore +0 -16
- data/Gemfile +0 -8
- data/README.md +0 -419
- data/Rakefile +0 -9
- data/test/install +0 -3
- data/test/test_helper.rb +0 -65
- data/test/test_helpers/integration_helper.rb +0 -33
- data/test/test_helpers/mock.rb +0 -59
- data/test/test_helpers/mock_searcher.rb +0 -1
- data/test/test_helpers/mocks.rb +0 -77
- data/test/test_helpers/mocks/searcher_mock.rb +0 -84
- data/test/test_launcher/cli/input_parser_test.rb +0 -79
- data/test/test_launcher/ex_unit_integration_test.rb +0 -413
- data/test/test_launcher/frameworks/implementation/test_case_test.rb +0 -73
- data/test/test_launcher/frameworks/minitest/runner_test.rb +0 -76
- data/test/test_launcher/frameworks/minitest/searcher_test.rb +0 -109
- data/test/test_launcher/frameworks/rspec/runner_test.rb +0 -83
- data/test/test_launcher/frameworks/rspec/searcher_test.rb +0 -54
- data/test/test_launcher/generic_integration_test.rb +0 -62
- data/test/test_launcher/minitest_integration_test.rb +0 -683
- data/test/test_launcher/queries/example_name_query_test.rb +0 -221
- data/test/test_launcher/queries/full_regex_query_test.rb +0 -153
- data/test/test_launcher/queries/generic_query_test.rb +0 -23
- data/test/test_launcher/queries/line_number_query_test.rb +0 -107
- data/test/test_launcher/queries/multi_path_query_test.rb +0 -126
- data/test/test_launcher/queries/path_query_test.rb +0 -192
- data/test/test_launcher/rspec_integration_test.rb +0 -574
- data/test/test_launcher/rubymine_test.rb +0 -65
- data/test/test_launcher/search/ag_test.rb +0 -42
- data/test/test_launcher/search/git_test.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06b235fa2c06c8c943187511a5e9d59ffe5ce01f
|
4
|
+
data.tar.gz: 34105a1658d9d0152ac73bbc64d643aec0b73b6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e07fa6bb4ccc1933b27ccd24ef1d814b8cbfc7f89eb707d0ef75f5c29bfc794bcc1d3ba0f9d82a09068679c01f0ad027d91c2858a5a635b56cf2c2a55db6470
|
7
|
+
data.tar.gz: fb39961d66baaba90e75ff23c73c14f35d0716f3c7e642bfdbec65811460301eae9a33b2bda6f78025b13107a26da482f29cb8a351538a02c2d09a4b4b3b916c
|
@@ -47,7 +47,7 @@ module TestLauncher
|
|
47
47
|
if best_result
|
48
48
|
[{
|
49
49
|
file: best_result[:file],
|
50
|
-
example_name: best_result[:line].match(/(test_[\w\?]+)/)[
|
50
|
+
example_name: best_result[:line].match(/(def\s+(?<name>test_[\w\?]+)|test\s+['"](?<name>.*)['"]\s+do)/)[:name],
|
51
51
|
line_number: best_result[:line_number]
|
52
52
|
}]
|
53
53
|
else
|
@@ -72,7 +72,7 @@ module TestLauncher
|
|
72
72
|
if query.match(/^test_/)
|
73
73
|
"^\s*def\s+(#{query}).*"
|
74
74
|
else
|
75
|
-
"^\s*def\s+test_.*(#{query
|
75
|
+
"^\s*(def\s+test_|test\s+['\"]).*(#{query}).*"
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -164,6 +164,11 @@ Open an issue on https://github.com/petekinnecom/test_launcher if this is someth
|
|
164
164
|
File.exist?(File.join(app_root, f))
|
165
165
|
}
|
166
166
|
end
|
167
|
+
|
168
|
+
def example
|
169
|
+
@memoized_example if defined?(@memoized_example)
|
170
|
+
@memoized_example = @example&.gsub(" ", "_")
|
171
|
+
end
|
167
172
|
end
|
168
173
|
end
|
169
174
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "test_launcher/base_error"
|
2
|
+
require "shellwords"
|
2
3
|
|
3
4
|
module TestLauncher
|
4
5
|
module Search
|
@@ -17,7 +18,7 @@ module TestLauncher
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def grep(regex, file_pattern)
|
20
|
-
shell.run("git grep --line-number --untracked --extended-regexp
|
21
|
+
shell.run("git grep --line-number --untracked --extended-regexp #{Shellwords.escape(regex)} -- '#{file_pattern}'")
|
21
22
|
end
|
22
23
|
|
23
24
|
def root_path
|
data/test_launcher.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "http://github.com/petekinnecom/test_launcher"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files =
|
16
|
+
spec.files = Dir["lib/**/*.rb"] + ["test_launcher.gemspec", "bin/test_launcher", "LICENSE.txt"]
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
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.21.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: 2018-11-
|
11
|
+
date: 2018-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,11 +46,7 @@ executables:
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- ".gitignore"
|
50
|
-
- Gemfile
|
51
49
|
- LICENSE.txt
|
52
|
-
- README.md
|
53
|
-
- Rakefile
|
54
50
|
- bin/test_launcher
|
55
51
|
- lib/test_launcher.rb
|
56
52
|
- lib/test_launcher/base_error.rb
|
@@ -76,34 +72,7 @@ files:
|
|
76
72
|
- lib/test_launcher/shell/history_runner.rb
|
77
73
|
- lib/test_launcher/shell/runner.rb
|
78
74
|
- lib/test_launcher/version.rb
|
79
|
-
- test/install
|
80
|
-
- test/test_helper.rb
|
81
|
-
- test/test_helpers/integration_helper.rb
|
82
|
-
- test/test_helpers/mock.rb
|
83
|
-
- test/test_helpers/mock_searcher.rb
|
84
|
-
- test/test_helpers/mocks.rb
|
85
|
-
- test/test_helpers/mocks/searcher_mock.rb
|
86
|
-
- test/test_launcher/cli/input_parser_test.rb
|
87
|
-
- test/test_launcher/ex_unit_integration_test.rb
|
88
|
-
- test/test_launcher/frameworks/implementation/test_case_test.rb
|
89
|
-
- test/test_launcher/frameworks/minitest/runner_test.rb
|
90
|
-
- test/test_launcher/frameworks/minitest/searcher_test.rb
|
91
|
-
- test/test_launcher/frameworks/rspec/runner_test.rb
|
92
|
-
- test/test_launcher/frameworks/rspec/searcher_test.rb
|
93
|
-
- test/test_launcher/generic_integration_test.rb
|
94
|
-
- test/test_launcher/minitest_integration_test.rb
|
95
|
-
- test/test_launcher/queries/example_name_query_test.rb
|
96
|
-
- test/test_launcher/queries/full_regex_query_test.rb
|
97
|
-
- test/test_launcher/queries/generic_query_test.rb
|
98
|
-
- test/test_launcher/queries/line_number_query_test.rb
|
99
|
-
- test/test_launcher/queries/multi_path_query_test.rb
|
100
|
-
- test/test_launcher/queries/path_query_test.rb
|
101
|
-
- test/test_launcher/rspec_integration_test.rb
|
102
|
-
- test/test_launcher/rubymine_test.rb
|
103
|
-
- test/test_launcher/search/ag_test.rb
|
104
|
-
- test/test_launcher/search/git_test.rb
|
105
75
|
- test_launcher.gemspec
|
106
|
-
- tmp/.gitkeep
|
107
76
|
homepage: http://github.com/petekinnecom/test_launcher
|
108
77
|
licenses:
|
109
78
|
- MIT
|
@@ -128,30 +97,4 @@ rubygems_version: 2.5.2
|
|
128
97
|
signing_key:
|
129
98
|
specification_version: 4
|
130
99
|
summary: Easily run tests
|
131
|
-
test_files:
|
132
|
-
- test/install
|
133
|
-
- test/test_helper.rb
|
134
|
-
- test/test_helpers/integration_helper.rb
|
135
|
-
- test/test_helpers/mock.rb
|
136
|
-
- test/test_helpers/mock_searcher.rb
|
137
|
-
- test/test_helpers/mocks.rb
|
138
|
-
- test/test_helpers/mocks/searcher_mock.rb
|
139
|
-
- test/test_launcher/cli/input_parser_test.rb
|
140
|
-
- test/test_launcher/ex_unit_integration_test.rb
|
141
|
-
- test/test_launcher/frameworks/implementation/test_case_test.rb
|
142
|
-
- test/test_launcher/frameworks/minitest/runner_test.rb
|
143
|
-
- test/test_launcher/frameworks/minitest/searcher_test.rb
|
144
|
-
- test/test_launcher/frameworks/rspec/runner_test.rb
|
145
|
-
- test/test_launcher/frameworks/rspec/searcher_test.rb
|
146
|
-
- test/test_launcher/generic_integration_test.rb
|
147
|
-
- test/test_launcher/minitest_integration_test.rb
|
148
|
-
- test/test_launcher/queries/example_name_query_test.rb
|
149
|
-
- test/test_launcher/queries/full_regex_query_test.rb
|
150
|
-
- test/test_launcher/queries/generic_query_test.rb
|
151
|
-
- test/test_launcher/queries/line_number_query_test.rb
|
152
|
-
- test/test_launcher/queries/multi_path_query_test.rb
|
153
|
-
- test/test_launcher/queries/path_query_test.rb
|
154
|
-
- test/test_launcher/rspec_integration_test.rb
|
155
|
-
- test/test_launcher/rubymine_test.rb
|
156
|
-
- test/test_launcher/search/ag_test.rb
|
157
|
-
- test/test_launcher/search/git_test.rb
|
100
|
+
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,419 +0,0 @@
|
|
1
|
-
# Test Launcher -->
|
2
|
-
|
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
|
-
|
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
|
-
|
14
|
-
You might use Test Launcher for two reasons:
|
15
|
-
|
16
|
-
1. You run tests from the command line a lot.
|
17
|
-
2. You work in a ruby app that contains inline gems/engines with their own test suites.
|
18
|
-
|
19
|
-
It was built for Minitest, but it also has basic support for RSpec and ExUnit.
|
20
|
-
|
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. [Tweaking the Command](#tweaking-the-command)
|
30
|
-
1. [Aliases](#quit-typing-so-much)
|
31
|
-
1. [RubyMine Support](#rubymine-support)
|
32
|
-
1. [Visual Studio Code Support](#visual-studio-code-support)
|
33
|
-
1. [Atom Support](#atom-support)
|
34
|
-
1. [Docker Support](#docker-support)
|
35
|
-
1. [What's going on in there?](#whats-going-on-in-there)
|
36
|
-
|
37
|
-
# Installation
|
38
|
-
|
39
|
-
To install:
|
40
|
-
|
41
|
-
```
|
42
|
-
gem install test_launcher
|
43
|
-
```
|
44
|
-
|
45
|
-
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.
|
46
|
-
|
47
|
-
# Examples
|
48
|
-
|
49
|
-
Let's suppose you want to run the test `test_name` in your `blog_post_test.rb`.
|
50
|
-
|
51
|
-
Without Test Launcher, you might type this:
|
52
|
-
|
53
|
-
```
|
54
|
-
ruby -I test test/models/blog_post_test.rb --name=test_blog_name_thing
|
55
|
-
```
|
56
|
-
|
57
|
-
But with Test Launcher, you can just type this:
|
58
|
-
|
59
|
-
```
|
60
|
-
test_launcher test_blog_name_thing
|
61
|
-
|
62
|
-
#=> Found 1 example in 1 file
|
63
|
-
#=> ruby -I test test/models/blog_post_test.rb --name=test_blog_name_thing
|
64
|
-
```
|
65
|
-
|
66
|
-
What if you want to run a whole file? Just go for it!
|
67
|
-
|
68
|
-
```
|
69
|
-
test_launcher blog_post_test
|
70
|
-
|
71
|
-
#=> ruby -I test test/models/blog_post_test.rb
|
72
|
-
```
|
73
|
-
|
74
|
-
Maybe you'd like to run a whole folder?
|
75
|
-
|
76
|
-
```
|
77
|
-
test_launcher test/models --all
|
78
|
-
|
79
|
-
#=> ruby -I test -e 'ARGV.each {|f| require(f)}' test/models/blog_post_test.rb test/models/comment_test.rb
|
80
|
-
```
|
81
|
-
|
82
|
-
You can run specific test methods by line:
|
83
|
-
```
|
84
|
-
test_launcher blog_post_test.rb:13
|
85
|
-
|
86
|
-
#=> Found 1 example in 1 file
|
87
|
-
#=> ruby -I test test/models/blog_post_test.rb --name=test_blog_name_thing
|
88
|
-
```
|
89
|
-
|
90
|
-
What if you just have the class name for the test?
|
91
|
-
|
92
|
-
```
|
93
|
-
test_launcher BlogPostTest
|
94
|
-
|
95
|
-
#=> ruby -I test test/models/blog_post_test.rb
|
96
|
-
```
|
97
|
-
|
98
|
-
But what if you aren't specific enough?
|
99
|
-
|
100
|
-
```
|
101
|
-
test_launcher test_blog_na
|
102
|
-
|
103
|
-
#=> Found 10 test methods in 3 files.
|
104
|
-
#=> Running most recently edited. Run with '--all' to run all the tests.
|
105
|
-
#=> ruby -I test test/models/blog_post_test.rb --name=test_blog_name_thing
|
106
|
-
```
|
107
|
-
|
108
|
-
What if you are very specific?
|
109
|
-
```
|
110
|
-
test_launcher /Users/username/code/my_repo/test/models/blog_post_test.rb
|
111
|
-
|
112
|
-
#=> ruby -I test test/models/blog_post_test.rb
|
113
|
-
```
|
114
|
-
|
115
|
-
Suppose you have multiple files you'd like to run:
|
116
|
-
```
|
117
|
-
test_launcher blog_post_test.rb comment_test.rb
|
118
|
-
|
119
|
-
#=> ruby -I test -e 'ARGV.each {|f| require(f)}' test/models/blog_post_test.rb test/models/comment_test.rb
|
120
|
-
```
|
121
|
-
Or maybe you've got multiple test methods you want to run:
|
122
|
-
|
123
|
-
```
|
124
|
-
test_launcher test_name_1 test_name_2
|
125
|
-
|
126
|
-
#=> ruby -I test -e "ARGV.push('--name=/test_name_1|test_name_2/')" -r /src/test/file_1_test.rb -r /src/test/file_2_test.rb
|
127
|
-
```
|
128
|
-
|
129
|
-
Or maybe you'd like to run all test methods that match a regular expression:
|
130
|
-
|
131
|
-
```
|
132
|
-
test_launcher 'hello_\w*|goodbye_\w+' --all
|
133
|
-
|
134
|
-
#=> Found 2 methods in 2 files.
|
135
|
-
#=> bundle exec ruby -I test -e "ARGV.push('--name=/hello_\w*|goodbye_\w+/')" -r /src/test/file_1_test.rb -r /src/test/file_2_test.rb
|
136
|
-
```
|
137
|
-
|
138
|
-
### Inline Gems
|
139
|
-
|
140
|
-
If you work in an application that has inlined gems/engines, you've probably already experienced pain around running tests. IDEs and editor plugins have a hard time understanding how to run tests for inlined gems when you have opened the project from a parent folder. By looking for Gemfiles and gemspecs, Test Launcher can run your tests in the correct context. If you are using RubyMine in a project with inline gems, see the __RubyMine__ section below.
|
141
|
-
|
142
|
-
For example, if `thing_test.rb` is within your inline_gem, you can run:
|
143
|
-
|
144
|
-
```
|
145
|
-
test_launcher thing_test
|
146
|
-
|
147
|
-
#=> cd /path/to/inline_gem && ruby -I test test/thing_test.rb
|
148
|
-
```
|
149
|
-
|
150
|
-
You don't have to run Test Launcher from the root of your project either. It will figure things out, even when using the `--all` flag!
|
151
|
-
|
152
|
-
### Spring preloader
|
153
|
-
|
154
|
-
Test Launcher will check for the spring/testunit binstubs. If they are found in the app/gem/engine it will use spring:
|
155
|
-
|
156
|
-
```
|
157
|
-
test_launcher springified_test
|
158
|
-
|
159
|
-
#=> cd /path/to/app && spring testunit test/springified_test.rb
|
160
|
-
```
|
161
|
-
|
162
|
-
Test Launcher will not use spring if the `DISABLE_SPRING=1` environment variable is set.
|
163
|
-
|
164
|
-
# Usage and Options
|
165
|
-
|
166
|
-
```
|
167
|
-
Find tests and run them by trying to match an individual test or the name of a test file(s).
|
168
|
-
|
169
|
-
See full README: https://github.com/petekinnecom/test_launcher
|
170
|
-
|
171
|
-
Usage: `test_launcher "search string" [--all]`
|
172
|
-
|
173
|
-
VERSION: 2.10.0
|
174
|
-
|
175
|
-
-a, --all Run all matching tests. Defaults to false.
|
176
|
-
-h, --help Prints this help
|
177
|
-
-v, --version Display the version info
|
178
|
-
-f, --framework framework The testing framework being used. Valid options: ['minitest', 'rspec', 'ex_unit', 'guess']. Defaults to 'guess'
|
179
|
-
-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.
|
180
|
-
--example example alias of name
|
181
|
-
-r, --rerun Rerun the previous test. This flag cannot be set when entering search terms
|
182
|
-
--disable-spring Disable spring. You can also set the env var: DISABLE_SPRING=1
|
183
|
-
--spring Force spring commands to be used (useful when test_launcher is unable to detect that spring is used)
|
184
|
-
```
|
185
|
-
|
186
|
-
# Search Priority
|
187
|
-
|
188
|
-
Test Launcher searches for tests based on your input.
|
189
|
-
|
190
|
-
Suppose you type `test_launcher thing`. It will run tests using this priority preference:
|
191
|
-
|
192
|
-
1. A single test file
|
193
|
-
- matches on `thing_test.rb`
|
194
|
-
|
195
|
-
1. A single, specific test method name or partial name
|
196
|
-
- `def test_the_thing`
|
197
|
-
|
198
|
-
1. Multiple test method names in the same file
|
199
|
-
- `def test_the_thing` and `def test_the_other_thing`
|
200
|
-
|
201
|
-
1. Any test file based on a generic search
|
202
|
-
- runs `stuff_test.rb` because it found the word `thing` inside of it
|
203
|
-
|
204
|
-
1. Finally, if the query matches against a non-test file, it will simply run that file
|
205
|
-
- runs `ruby thing.rb` because it found `thing.rb`
|
206
|
-
|
207
|
-
If your query looks like it's specifying a line number (e.g. `file_test.rb:17`), that search will be preferred.
|
208
|
-
|
209
|
-
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!
|
210
|
-
|
211
|
-
|
212
|
-
# Running all changed tests
|
213
|
-
|
214
|
-
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.
|
215
|
-
|
216
|
-
```
|
217
|
-
git diff --name-only --diff-filter=ACMTUXB | grep _test.rb | xargs test_launcher
|
218
|
-
```
|
219
|
-
|
220
|
-
If you've already committed your changes, but want to double check before you push, diff your changes with origin/master:
|
221
|
-
|
222
|
-
```
|
223
|
-
git diff --name-only --diff-filter=ACMTUXB origin/master | grep _test.rb | xargs test_launcher
|
224
|
-
```
|
225
|
-
|
226
|
-
Add this to your `~/.bash_profile` and enjoy!
|
227
|
-
```
|
228
|
-
function tdiff()
|
229
|
-
{
|
230
|
-
git diff --name-only --diff-filter=ACMTUXB $@ | grep _test.rb | xargs test_launcher
|
231
|
-
}
|
232
|
-
|
233
|
-
# Now you can:
|
234
|
-
|
235
|
-
tdiff
|
236
|
-
|
237
|
-
# or
|
238
|
-
|
239
|
-
tdiff origin/master
|
240
|
-
```
|
241
|
-
|
242
|
-
Super fun!
|
243
|
-
|
244
|
-
# Tweaking the Command
|
245
|
-
|
246
|
-
The CLI class will yield the command in a block just before it's run, allowing you to adjust the command. The value of the block will be executed by test_launcher. Here is an example script:
|
247
|
-
|
248
|
-
/bin/wrapped_test_launcher:
|
249
|
-
|
250
|
-
~~~ruby
|
251
|
-
require "test_launcher/cli"
|
252
|
-
|
253
|
-
TestLauncher::CLI.launch(ARGV, ENV) do |command|
|
254
|
-
"the new command"
|
255
|
-
end
|
256
|
-
~~~
|
257
|
-
|
258
|
-
If you don't want the command to be executed, you can return `nil` from the block. This is an ugly hack, but ... well it works ...
|
259
|
-
|
260
|
-
~~~ruby
|
261
|
-
require "test_launcher/cli"
|
262
|
-
|
263
|
-
TestLauncher::CLI.launch(ARGV, ENV) do |command|
|
264
|
-
@the_command = command
|
265
|
-
nil
|
266
|
-
end
|
267
|
-
|
268
|
-
puts "here is the command that would have been run: #{@the_command}"
|
269
|
-
~~~
|
270
|
-
|
271
|
-
|
272
|
-
# Quit typing so much!
|
273
|
-
|
274
|
-
This gem installs one executable called `test_launcher`.
|
275
|
-
|
276
|
-
```
|
277
|
-
test_launcher test_name_to_find
|
278
|
-
```
|
279
|
-
|
280
|
-
For me, that's way too much to type, so I recommend adding an alias to your `.bash_profile` like so:
|
281
|
-
|
282
|
-
```
|
283
|
-
alias t='test_launcher'
|
284
|
-
```
|
285
|
-
|
286
|
-
Now you can just type `t` instead of `test_launcher`. Much nicer!
|
287
|
-
|
288
|
-
|
289
|
-
## Optimizing with RVM
|
290
|
-
|
291
|
-
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).
|
292
|
-
|
293
|
-
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.
|
294
|
-
|
295
|
-
On projects with lots of dependencies, this wasted time can be significant.
|
296
|
-
|
297
|
-
For example, in a large project, we get a nice improvement:
|
298
|
-
|
299
|
-
```
|
300
|
-
$: time test_launcher something_that_no_test_says
|
301
|
-
#=> Could not find any tests.
|
302
|
-
|
303
|
-
#=> real 0m2.214s
|
304
|
-
#=> user 0m1.407s
|
305
|
-
#=> sys 0m1.062s
|
306
|
-
|
307
|
-
$: time NOEXEC_DISABLE=1 test_launcher something_that_no_test_says
|
308
|
-
#=> Could not find any tests.
|
309
|
-
|
310
|
-
#=> real 0m1.412s
|
311
|
-
#=> user 0m0.745s
|
312
|
-
#=> sys 0m0.945s
|
313
|
-
```
|
314
|
-
|
315
|
-
I suggest that if you are using RVM, you may as well make this your alias:
|
316
|
-
|
317
|
-
```
|
318
|
-
alias t='NOEXEC_DISABLE=1 test_launcher'
|
319
|
-
```
|
320
|
-
|
321
|
-
# RubyMine Support
|
322
|
-
|
323
|
-
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.
|
324
|
-
|
325
|
-
Test Launcher can be used from RubyMine to help alleviate these problems. Requiring the `test_launcher/rubymine` file in your run configurations will allow Test Launcher to fix RubyMine's test running to do what you want.
|
326
|
-
|
327
|
-
To use the RubyMine support:
|
328
|
-
|
329
|
-
1. Open your project
|
330
|
-
1. Click on Run -> 'Edit Configurations...'
|
331
|
-
1. If you have any run configurations listed under 'Test::Unit/Shoulda/Minitest', use the minus button to remove them.
|
332
|
-
1. Open the 'Defaults' and click on 'Test::Unit/Shoulda/Minitest'
|
333
|
-
1. Under 'Ruby Arguments' change:
|
334
|
-
|
335
|
-
```
|
336
|
-
-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)`
|
337
|
-
```
|
338
|
-
|
339
|
-
Replace it with:
|
340
|
-
|
341
|
-
```
|
342
|
-
-r test_launcher/rubymine
|
343
|
-
```
|
344
|
-
|
345
|
-
1. Run a test. Test Launcher should report that it is hijacking the test and it will output the command that it has decided to use.
|
346
|
-
|
347
|
-
|
348
|
-
### Debugging Support
|
349
|
-
|
350
|
-
Using Test Launcher to hijack your RubyMine run configuration should allow you to debug any test as well without issue.
|
351
|
-
|
352
|
-
|
353
|
-
### Spring and Rubymine
|
354
|
-
|
355
|
-
If you don't want to use spring to run your tests, but test_launcher tries to use it anyways, follow these steps:
|
356
|
-
|
357
|
-
1. Open your project
|
358
|
-
1. Click on Run -> 'Edit Configurations...'
|
359
|
-
1. If you have any run configurations listed under 'Test::Unit/Shoulda/Minitest', use the minus button to remove them.
|
360
|
-
1. Open the 'Defaults' and click on 'Test::Unit/Shoulda/Minitest'
|
361
|
-
1. Under 'Environment Variables' add as a variable with the name `DISABLE_SPRING` and the value `1`
|
362
|
-
|
363
|
-
# Visual Studio Code Support
|
364
|
-
|
365
|
-
Install the [Terminal Command Keys](https://marketplace.visualstudio.com/items?itemName=petekinnecom.terminal-command-keys) extension (you can search for `petekinnecom.terminal-command-keys` in vscode's extension search box). This allows us to assign keybindings to specific terminal commands. Then we can add TestLauncher keybindings to our `keybindings.json`. Here is an example configuration:
|
366
|
-
|
367
|
-
```
|
368
|
-
{
|
369
|
-
"key": "shift+cmd+r",
|
370
|
-
"command": "terminalCommandKeys.run",
|
371
|
-
"args": {
|
372
|
-
"cmd": "test_launcher ${file}:${line}",
|
373
|
-
}
|
374
|
-
},
|
375
|
-
{
|
376
|
-
"key": "alt+cmd+r",
|
377
|
-
"command": "terminalCommandKeys.run",
|
378
|
-
"args": {
|
379
|
-
"cmd": "test_launcher ${file}",
|
380
|
-
}
|
381
|
-
},
|
382
|
-
{
|
383
|
-
"key": "cmd+r",
|
384
|
-
"command": "terminalCommandKeys.run",
|
385
|
-
"args": {
|
386
|
-
"cmd": "test_launcher --rerun",
|
387
|
-
}
|
388
|
-
}
|
389
|
-
```
|
390
|
-
|
391
|
-
# Atom Support
|
392
|
-
|
393
|
-
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:
|
394
|
-
|
395
|
-
```
|
396
|
-
test_launcher {relative_path} --name={regex}
|
397
|
-
```
|
398
|
-
|
399
|
-
# Docker Support
|
400
|
-
|
401
|
-
We can write our own script to run tests in a docker container. Perhaps you're using `docker-compose` for testing. This means you need to pass the command on to the container to be run.
|
402
|
-
|
403
|
-
Because the path to the project and test file will be different inside of the container, we need to adjust the paths used in the executed command. Here is an example script:
|
404
|
-
|
405
|
-
~~~ruby
|
406
|
-
require 'test_launcher/cli'
|
407
|
-
|
408
|
-
TestLauncher::CLI.launch(ARGV, ENV) do |command|
|
409
|
-
app_root = File.expand_path(File.join(__dir__, '..'))
|
410
|
-
docker_command = command.gsub(app_root, "/app")
|
411
|
-
"docker-compose exec dev bash -c '#{docker_command}'"
|
412
|
-
end
|
413
|
-
~~~
|
414
|
-
|
415
|
-
# What's going on in there?
|
416
|
-
|
417
|
-
Test Launcher began life as a bash script patching together `ag`, `awk`, `grep`, and all sorts of insanity. After looking up how to do an if/else in bash for the millionth time, I decided to rewrite it in Ruby.
|
418
|
-
|
419
|
-
Test Launcher was developed using "BDD" (Bug Driven Development). Because I use it so heavily, I'd pop over and hack something precisely at the moment I needed it (often breaking all sorts of other things). I've since added some tests, but I reserve the right to break anything at anytime if only for old times' sake.
|