test_launcher 2.5.0 → 2.6.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 +46 -0
- data/lib/test_launcher/cli.rb +8 -1
- data/lib/test_launcher/version.rb +1 -1
- data/test/test_launcher/generic_integration_test.rb +20 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bda7c36dc1384d7ac0c711d1701ba3ebc99f368e
|
4
|
+
data.tar.gz: c249a9c96e0a4d7fa452dba1c871d2d79de99f28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a21dd0a1139c7f457613a806458159552d7a79fe1251cd0aa128d9f2bfd4c613ea8d2dbb20104746059adb8dfde494c328a9f67bd318ac0540eb38f846d0b06
|
7
|
+
data.tar.gz: 345dc294fcffb85f065d633d407cd02f47e1f6883c770b23ce614ab5ca52fe2e81071a4585e0d7f02a77741f60a57bebacce33dcebdc331f3a992250204c3602
|
data/README.md
CHANGED
@@ -26,10 +26,12 @@ It was built for Minitest, but it also has basic support for RSpec and ExUnit.
|
|
26
26
|
1. [Usage and Options](#usage-and-options)
|
27
27
|
1. [Search Prioty](#search-priority)
|
28
28
|
1. [Running all changed tests](#running-all-changed-tests)
|
29
|
+
1. [Tweaking the Command](#tweaking-the-command)
|
29
30
|
1. [Aliases](#quit-typing-so-much)
|
30
31
|
1. [RubyMine Support](#rubymine-support)
|
31
32
|
1. [Visual Studio Code Support](#visual-studio-code-support)
|
32
33
|
1. [Atom Support](#atom-support)
|
34
|
+
1. [Docker Support](#docker-support)
|
33
35
|
1. [What's going on in there?](#whats-going-on-in-there)
|
34
36
|
|
35
37
|
# Installation
|
@@ -234,6 +236,34 @@ tdiff origin/master
|
|
234
236
|
|
235
237
|
Super fun!
|
236
238
|
|
239
|
+
# Tweaking the Command
|
240
|
+
|
241
|
+
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:
|
242
|
+
|
243
|
+
/bin/wrapped_test_launcher:
|
244
|
+
|
245
|
+
~~~ruby
|
246
|
+
require "test_launcher/cli"
|
247
|
+
|
248
|
+
TestLauncher::CLI.launch(ARGV, ENV) do |command|
|
249
|
+
"the new command"
|
250
|
+
end
|
251
|
+
~~~
|
252
|
+
|
253
|
+
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 ...
|
254
|
+
|
255
|
+
~~~ruby
|
256
|
+
require "test_launcher/cli"
|
257
|
+
|
258
|
+
TestLauncher::CLI.launch(ARGV, ENV) do |command|
|
259
|
+
@the_command = command
|
260
|
+
nil
|
261
|
+
end
|
262
|
+
|
263
|
+
puts "here is the command that would have been run: #{@the_command}"
|
264
|
+
~~~
|
265
|
+
|
266
|
+
|
237
267
|
# Quit typing so much!
|
238
268
|
|
239
269
|
This gem installs one executable called `test_launcher`.
|
@@ -371,6 +401,22 @@ The [ruby-test](https://github.com/moxley/atom-ruby-test) extension works well f
|
|
371
401
|
test_launcher {relative_path} --name={regex}
|
372
402
|
```
|
373
403
|
|
404
|
+
# Docker Support
|
405
|
+
|
406
|
+
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.
|
407
|
+
|
408
|
+
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:
|
409
|
+
|
410
|
+
~~~ruby
|
411
|
+
require 'test_launcher/cli'
|
412
|
+
|
413
|
+
TestLauncher::CLI.launch(ARGV, ENV) do |command|
|
414
|
+
app_root = File.expand_path(File.join(__dir__, '..'))
|
415
|
+
docker_command = command.gsub(app_root, "/app")
|
416
|
+
"docker-compose exec dev bash -c '#{docker_command}'"
|
417
|
+
end
|
418
|
+
~~~
|
419
|
+
|
374
420
|
# What's going on in there?
|
375
421
|
|
376
422
|
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.
|
data/lib/test_launcher/cli.rb
CHANGED
@@ -42,10 +42,17 @@ module TestLauncher
|
|
42
42
|
env
|
43
43
|
).parsed_options(shell: shell, searcher: searcher)
|
44
44
|
|
45
|
+
# TODO: Well, this isn't pretty anymore...
|
46
|
+
|
45
47
|
if options.rerun
|
46
48
|
shell.reexec
|
47
49
|
elsif command = MultiFrameworkQuery.new(options).command
|
48
|
-
|
50
|
+
command = yield(command) if block_given?
|
51
|
+
if command
|
52
|
+
shell.exec(command)
|
53
|
+
else
|
54
|
+
command
|
55
|
+
end
|
49
56
|
else
|
50
57
|
shell.warn "No tests found."
|
51
58
|
end
|
@@ -5,10 +5,10 @@ module TestLauncher
|
|
5
5
|
class GenericIntegrationTest < TestCase
|
6
6
|
include IntegrationHelper
|
7
7
|
|
8
|
-
def launch(query, env: {}, searcher:, shell: shell_mock)
|
8
|
+
def launch(query, env: {}, searcher:, shell: shell_mock, &block)
|
9
9
|
query += " --framework generic "
|
10
10
|
shell.reset
|
11
|
-
CLI.launch(query.split(" "), env, shell: shell, searcher: searcher)
|
11
|
+
CLI.launch(query.split(" "), env, shell: shell, searcher: searcher, &block)
|
12
12
|
end
|
13
13
|
|
14
14
|
def test__by_filename
|
@@ -40,5 +40,23 @@ module TestLauncher
|
|
40
40
|
launch("/src/test/file_1.rb:1", searcher: searcher)
|
41
41
|
assert_equal nil, shell_mock.recall_exec
|
42
42
|
end
|
43
|
+
|
44
|
+
def test__cli_yields_block
|
45
|
+
# TODO: don't test this here
|
46
|
+
searcher = MemorySearcher.new do |searcher|
|
47
|
+
searcher.mock_file do |f|
|
48
|
+
f.path "/src/test/file_1.rb"
|
49
|
+
f.contents "runme"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
@yielded = false
|
53
|
+
launch("/src/test/file_1.rb", searcher: searcher) do |command|
|
54
|
+
@yielded = true
|
55
|
+
assert_equal "ruby /src/test/file_1.rb", command
|
56
|
+
"new_command"
|
57
|
+
end
|
58
|
+
assert @yielded
|
59
|
+
assert_equal "new_command", shell_mock.recall_exec
|
60
|
+
end
|
43
61
|
end
|
44
62
|
end
|
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.6.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-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|