test_launcher 1.4.0 → 1.5.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 +15 -6
- data/bin/test_launcher +2 -6
- data/lib/test_launcher/base_error.rb +4 -0
- data/lib/test_launcher/cli/input_parser.rb +10 -3
- data/lib/test_launcher/frameworks/base.rb +1 -1
- data/lib/test_launcher/frameworks/implementation/locator.rb +43 -14
- data/lib/test_launcher/frameworks/implementation/test_case.rb +16 -26
- data/lib/test_launcher/frameworks/minitest.rb +14 -1
- data/lib/test_launcher/frameworks/rspec.rb +1 -1
- data/lib/test_launcher/frameworks.rb +3 -21
- data/lib/test_launcher/request.rb +36 -0
- data/lib/test_launcher/rubymine/launcher.rb +27 -4
- data/lib/test_launcher/rubymine.rb +9 -1
- data/lib/test_launcher/search/git.rb +38 -13
- data/lib/test_launcher/version.rb +1 -1
- data/lib/test_launcher.rb +8 -7
- data/test/test_launcher/fixtures/minitest/Gemfile +0 -0
- data/test/test_launcher/fixtures/minitest/test/different_root/Gemfile +0 -0
- data/test/test_launcher/fixtures/rspec/Gemfile +0 -0
- data/test/test_launcher/fixtures/rspec/spec/different_root/Gemfile +0 -0
- data/test/test_launcher/frameworks/implementation/locator_test.rb +166 -0
- data/test/test_launcher/frameworks/implementation/test_case_test.rb +63 -0
- data/test/test_launcher/minitest_integration_test.rb +24 -12
- data/test/test_launcher/rspec_integration_test.rb +23 -12
- data/test/test_launcher/rubymine_test.rb +4 -2
- data/test/test_launcher/search/git_test.rb +26 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9fcdbdd5ed1a8eb6fc871ec897647a78fdfb3b1
|
4
|
+
data.tar.gz: 2d87fa49f026322a2786e31a34ab5a73aac6e9e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a01f5d870505778646f8b267a61874b67be0c37edd6d567fff1a9ba542f3ef71ab4249c24fc8c93768df2b27fb25a0bfcc90150051b880c2967e364a86392163
|
7
|
+
data.tar.gz: 221391e05a08f49b8b15f05466c2cfae573cbbfa552471e8f8b3ff7acfa5326356f6f1ad9dae0757765997c461d7365a7cd9c4f965f01d4e426e309895ec787c
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
#Test Launcher -->
|
2
2
|
|
3
|
-
Test Launcher takes some input and tries to figure out what test you want to run. It makes running tests on the command line much easier. Test Launcher
|
3
|
+
Test Launcher takes some input and tries to figure out what test you want to run. It makes running tests on the command line much easier. Test Launcher always outputs the command that it has decided to run so that you can verify that it is running the test you want it to run.
|
4
|
+
|
5
|
+
Test Launcher works with Minitest. RSpec support is in its infancy. You should try it and let me know!
|
4
6
|
|
5
7
|
### Usage
|
6
8
|
|
7
|
-
Let's suppose you want to run the test `test_name` in your `blog_post_test.rb`.
|
9
|
+
Let's suppose you want to run the test `test_name` in your `blog_post_test.rb`.
|
8
10
|
|
9
11
|
Without Test Launcher, you might type this:
|
10
12
|
|
@@ -86,11 +88,18 @@ Test Launcher will not use spring if the `DISABLE_SPRING=1` environment variable
|
|
86
88
|
|
87
89
|
### Running all tests you've changed:
|
88
90
|
|
89
|
-
This will find all `*_test.rb` files
|
91
|
+
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.
|
92
|
+
|
93
|
+
```
|
94
|
+
git diff --name-only --diff-filter=ACMTUXB | grep _test.rb | xargs test_launcher
|
95
|
+
```
|
96
|
+
|
97
|
+
If you've already committed your changes, but want to double check before you push, diff your changes with origin/master:
|
90
98
|
|
91
99
|
```
|
92
|
-
git
|
100
|
+
git diff --name-only --diff-filter=ACMTUXB origin/master | grep _test.rb | xargs test_launcher
|
93
101
|
```
|
102
|
+
(see https://git-scm.com/docs/git-diff)
|
94
103
|
|
95
104
|
#Installation
|
96
105
|
|
@@ -100,7 +109,7 @@ To install:
|
|
100
109
|
gem install test_launcher
|
101
110
|
```
|
102
111
|
|
103
|
-
Under the hood it uses git to search for files and to grep, so it will only work in git repositories.
|
112
|
+
Under the hood it uses git to search for files and to grep, so it will only work in git repositories.
|
104
113
|
|
105
114
|
|
106
115
|
#Setup
|
@@ -178,7 +187,7 @@ By default, RVM installs a hook to remove the need to run `bundle exec`. When y
|
|
178
187
|
|
179
188
|
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.
|
180
189
|
|
181
|
-
On projects with lots of dependencies, this wasted time can be significant.
|
190
|
+
On projects with lots of dependencies, this wasted time can be significant.
|
182
191
|
|
183
192
|
For example, in a large project, we get a nice improvement:
|
184
193
|
|
data/bin/test_launcher
CHANGED
@@ -3,10 +3,6 @@
|
|
3
3
|
require "test_launcher/cli/input_parser"
|
4
4
|
require "test_launcher"
|
5
5
|
|
6
|
-
|
6
|
+
cli = TestLauncher::CLI::InputParser.new(ARGV)
|
7
7
|
|
8
|
-
TestLauncher.launch(
|
9
|
-
input.query,
|
10
|
-
run_all: input.options[:run_all],
|
11
|
-
framework: input.options[:framework]
|
12
|
-
)
|
8
|
+
TestLauncher.launch(cli.request)
|
@@ -1,6 +1,8 @@
|
|
1
|
-
require "test_launcher/version"
|
2
1
|
require "optparse"
|
3
2
|
|
3
|
+
require "test_launcher/version"
|
4
|
+
require "test_launcher/request"
|
5
|
+
|
4
6
|
module TestLauncher
|
5
7
|
module CLI
|
6
8
|
class InputParser
|
@@ -28,13 +30,18 @@ VERSION: #{TestLauncher::VERSION}
|
|
28
30
|
exit
|
29
31
|
end
|
30
32
|
|
31
|
-
def
|
33
|
+
def request
|
32
34
|
if @query.size == 0
|
33
35
|
puts option_parser
|
34
36
|
exit
|
35
37
|
end
|
36
38
|
|
37
|
-
|
39
|
+
Request.new(
|
40
|
+
query: @query.join(" "),
|
41
|
+
run_all: @options[:run_all],
|
42
|
+
disable_spring: ENV["DISABLE_SPRING"],
|
43
|
+
framework: @options[:framework]
|
44
|
+
)
|
38
45
|
end
|
39
46
|
|
40
47
|
def options
|
@@ -1,18 +1,21 @@
|
|
1
|
+
require "test_launcher/base_error"
|
1
2
|
require "test_launcher/frameworks/implementation/test_case"
|
2
3
|
require "test_launcher/frameworks/implementation/collection"
|
3
4
|
|
4
5
|
module TestLauncher
|
5
6
|
module Frameworks
|
6
7
|
module Implementation
|
8
|
+
UnsupportedSearchError = Class.new(BaseError)
|
9
|
+
|
7
10
|
class Locator < Struct.new(:request, :searcher)
|
8
11
|
private :request, :searcher
|
9
12
|
|
10
13
|
def prioritized_results
|
11
|
-
return
|
14
|
+
return files_found_by_path unless files_found_by_path.empty?
|
12
15
|
|
13
16
|
return examples_found_by_name unless examples_found_by_name.empty?
|
14
17
|
|
15
|
-
return
|
18
|
+
return files_found_by_file_name_regex unless files_found_by_file_name_regex.empty?
|
16
19
|
|
17
20
|
return files_found_by_full_regex unless files_found_by_full_regex.empty?
|
18
21
|
|
@@ -21,25 +24,37 @@ module TestLauncher
|
|
21
24
|
|
22
25
|
private
|
23
26
|
|
24
|
-
def
|
25
|
-
|
26
|
-
return [] unless potential_file_paths.all? {|fp| File.exist?(fp)}
|
27
|
+
def files_found_by_path
|
28
|
+
# TODO: this needs some love
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
@files_found_by_path ||= begin
|
31
|
+
potential_file_paths = request.query.split(" ")
|
32
|
+
if potential_file_paths.all? {|fp| fp.match(file_name_regex)}
|
33
|
+
|
34
|
+
found_files = potential_file_paths.map {|fp| searcher.find_files(fp) }
|
35
|
+
if found_files.any?(&:empty?)
|
36
|
+
raise UnsupportedSearchError, file_term_failure_message
|
37
|
+
end
|
38
|
+
|
39
|
+
Collection.new(
|
40
|
+
results: found_files.flatten.map {|fp| build_result(file: fp)},
|
41
|
+
run_all: request.run_all? || potential_file_paths.size > 1
|
42
|
+
)
|
43
|
+
else
|
44
|
+
[]
|
45
|
+
end
|
46
|
+
end
|
32
47
|
end
|
33
48
|
|
34
49
|
def examples_found_by_name
|
35
50
|
@examples_found_by_name ||= Collection.new(
|
36
51
|
results: full_regex_search(regex_pattern).map {|r| build_result(file: r[:file], query: request.query)},
|
37
|
-
run_all: request.run_all
|
52
|
+
run_all: request.run_all?
|
38
53
|
)
|
39
54
|
end
|
40
55
|
|
41
|
-
def
|
42
|
-
@
|
56
|
+
def files_found_by_file_name_regex
|
57
|
+
@files_found_by_file_name_regex ||= begin
|
43
58
|
potential_file_paths = request.query.split(" ")
|
44
59
|
split_query_results = potential_file_paths.map {|fp| searcher.find_files(fp).select {|f| f.match(file_name_regex) } }
|
45
60
|
|
@@ -56,7 +71,7 @@ module TestLauncher
|
|
56
71
|
# we ignore the matched line since we don't know what to do with it
|
57
72
|
@files_found_by_full_regex ||= Collection.new(
|
58
73
|
results: full_regex_search(request.query).map {|r| build_result(file: r[:file]) },
|
59
|
-
run_all: request.run_all
|
74
|
+
run_all: request.run_all?
|
60
75
|
)
|
61
76
|
end
|
62
77
|
|
@@ -65,7 +80,7 @@ module TestLauncher
|
|
65
80
|
end
|
66
81
|
|
67
82
|
def build_result(file:, query: nil)
|
68
|
-
test_case_class.from_search(file: file, query: query)
|
83
|
+
test_case_class.from_search(file: file, query: query, request: request)
|
69
84
|
end
|
70
85
|
|
71
86
|
def file_name_regex
|
@@ -83,6 +98,20 @@ module TestLauncher
|
|
83
98
|
def test_case_class
|
84
99
|
raise NotImplementedError
|
85
100
|
end
|
101
|
+
|
102
|
+
def file_term_failure_message
|
103
|
+
<<-MSG
|
104
|
+
At least one of your search terms was identified as a file.
|
105
|
+
|
106
|
+
At least one of your *other* search terms was identified to not be a file.
|
107
|
+
|
108
|
+
This is a case that is not currently supported.
|
109
|
+
|
110
|
+
It is possible that one of the test files you wish to run is not currently known to git (e.g. it is ignored or unstaged)
|
111
|
+
|
112
|
+
If that's not the case, let me know what you're trying to do by filing an issue at http://github.com/petekinnecom/test_launcher/issues
|
113
|
+
MSG
|
114
|
+
end
|
86
115
|
end
|
87
116
|
end
|
88
117
|
end
|
@@ -4,15 +4,16 @@ module TestLauncher
|
|
4
4
|
module Frameworks
|
5
5
|
module Implementation
|
6
6
|
class TestCase
|
7
|
-
attr_reader :file, :example
|
7
|
+
attr_reader :file, :example, :request
|
8
8
|
|
9
|
-
def self.from_search(file:, query:
|
10
|
-
new(file: file, example: query)
|
9
|
+
def self.from_search(file:, query:, request:)
|
10
|
+
new(file: file, example: query, request: request)
|
11
11
|
end
|
12
12
|
|
13
|
-
def initialize(file:, example: nil)
|
13
|
+
def initialize(file:, example: nil, request:)
|
14
14
|
@file = file
|
15
15
|
@example = example
|
16
|
+
@request = request
|
16
17
|
end
|
17
18
|
|
18
19
|
def is_example?
|
@@ -24,43 +25,32 @@ module TestLauncher
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def app_root
|
27
|
-
|
28
|
-
|
29
|
-
exploded_path.each_with_index do |folder_name, i|
|
30
|
-
next unless folder_name == test_root_folder_name
|
28
|
+
if exploded_path.select { |dir| dir == test_root_dir_name }.size > 1
|
29
|
+
candidates = exploded_path
|
31
30
|
|
32
|
-
|
33
|
-
if
|
34
|
-
|
31
|
+
while !candidates.empty?
|
32
|
+
if candidates.last == test_root_dir_name
|
33
|
+
root_path = File.join("/", candidates[0..-2])
|
34
|
+
return root_path if Dir.entries(root_path).any? {|e| e.match /Gemfile|gemspec/}
|
35
35
|
end
|
36
|
+
|
37
|
+
candidates.pop
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
|
-
|
40
|
-
path = exploded_path[0...exploded_path.rindex(test_root_folder_name)]
|
41
|
+
path = exploded_path[0...exploded_path.index(test_root_dir_name)]
|
41
42
|
File.join("/", path)
|
42
43
|
end
|
43
44
|
|
44
45
|
def test_root
|
45
|
-
File.join(app_root,
|
46
|
-
end
|
47
|
-
|
48
|
-
def spring_enabled?
|
49
|
-
return false if ENV['DISABLE_SPRING']
|
50
|
-
|
51
|
-
[
|
52
|
-
"bin/spring",
|
53
|
-
"bin/testunit"
|
54
|
-
].any? {|f|
|
55
|
-
File.exist?(File.join(app_root, f))
|
56
|
-
}
|
46
|
+
File.join(app_root, test_root_dir_name)
|
57
47
|
end
|
58
48
|
|
59
49
|
def runner
|
60
50
|
raise NotImplementedError
|
61
51
|
end
|
62
52
|
|
63
|
-
def
|
53
|
+
def test_root_dir_name
|
64
54
|
raise NotImplementedError
|
65
55
|
end
|
66
56
|
|
@@ -58,9 +58,22 @@ module TestLauncher
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def test_root_dir_name
|
62
62
|
"test"
|
63
63
|
end
|
64
|
+
|
65
|
+
def spring_enabled?
|
66
|
+
# TODO: move ENV reference to options hash
|
67
|
+
return false if request.disable_spring?
|
68
|
+
|
69
|
+
[
|
70
|
+
"bin/spring",
|
71
|
+
"bin/testunit"
|
72
|
+
].any? {|f|
|
73
|
+
File.exist?(File.join(app_root, f))
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
64
77
|
end
|
65
78
|
end
|
66
79
|
end
|
@@ -1,19 +1,10 @@
|
|
1
|
-
require "test_launcher/frameworks/
|
2
|
-
require "test_launcher/frameworks/minitest"
|
3
|
-
require "test_launcher/frameworks/rspec"
|
1
|
+
require "test_launcher/frameworks/implementation/consolidator"
|
4
2
|
|
5
|
-
class Request < Struct.new(:query, :run_all)
|
6
|
-
end
|
7
3
|
|
8
4
|
module TestLauncher
|
9
5
|
module Frameworks
|
10
|
-
def self.locate(
|
11
|
-
|
12
|
-
request = Request.new(input, run_all)
|
13
|
-
|
14
|
-
frameworks = guess_frameworks(framework_name)
|
15
|
-
|
16
|
-
frameworks.each do |framework|
|
6
|
+
def self.locate(request:, shell:, searcher:)
|
7
|
+
request.frameworks.each do |framework|
|
17
8
|
search_results = framework::Locator.new(request, searcher).prioritized_results
|
18
9
|
runner = framework::Runner.new
|
19
10
|
|
@@ -25,14 +16,5 @@ module TestLauncher
|
|
25
16
|
nil
|
26
17
|
end
|
27
18
|
|
28
|
-
def self.guess_frameworks(framework_name)
|
29
|
-
if framework_name == "rspec"
|
30
|
-
[RSpec]
|
31
|
-
elsif framework_name == "minitest"
|
32
|
-
[Minitest]
|
33
|
-
else
|
34
|
-
[Minitest, RSpec].select(&:active?)
|
35
|
-
end
|
36
|
-
end
|
37
19
|
end
|
38
20
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "test_launcher/frameworks/minitest"
|
2
|
+
require "test_launcher/frameworks/rspec"
|
3
|
+
|
4
|
+
module TestLauncher
|
5
|
+
class Request
|
6
|
+
def initialize(query:, framework: "guess", run_all: false, disable_spring: false)
|
7
|
+
@query = query
|
8
|
+
@framework = framework
|
9
|
+
@run_all = run_all
|
10
|
+
@disable_spring = disable_spring
|
11
|
+
end
|
12
|
+
|
13
|
+
def query
|
14
|
+
@query
|
15
|
+
end
|
16
|
+
|
17
|
+
def run_all?
|
18
|
+
@run_all
|
19
|
+
end
|
20
|
+
|
21
|
+
def disable_spring?
|
22
|
+
@disable_spring
|
23
|
+
end
|
24
|
+
|
25
|
+
def frameworks
|
26
|
+
if @framework == "rspec"
|
27
|
+
[Frameworks::RSpec]
|
28
|
+
elsif @framework == "minitest"
|
29
|
+
[Frameworks::Minitest]
|
30
|
+
else
|
31
|
+
[Frameworks::Minitest, Frameworks::RSpec].select(&:active?)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -1,12 +1,24 @@
|
|
1
|
+
require "test_launcher/request"
|
1
2
|
require "test_launcher/frameworks/minitest"
|
2
3
|
require "test_launcher/shell/runner"
|
3
4
|
|
4
5
|
module TestLauncher
|
5
6
|
module Rubymine
|
7
|
+
class MinimalRequest
|
8
|
+
def initialize(disable_spring:)
|
9
|
+
@disable_spring = disable_spring
|
10
|
+
end
|
11
|
+
|
12
|
+
def disable_spring?
|
13
|
+
@disable_spring
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
6
17
|
class Launcher
|
7
|
-
def initialize(args:, shell:)
|
18
|
+
def initialize(args:, shell:, request:)
|
8
19
|
@args = args
|
9
20
|
@shell = shell
|
21
|
+
@request = request
|
10
22
|
end
|
11
23
|
|
12
24
|
def launch
|
@@ -36,10 +48,17 @@ module TestLauncher
|
|
36
48
|
|
37
49
|
def test_case
|
38
50
|
@test_case ||=
|
39
|
-
if args[-1].match(
|
40
|
-
Frameworks::Minitest::TestCase.new(
|
51
|
+
if args[-1].match("--name=")
|
52
|
+
Frameworks::Minitest::TestCase.new(
|
53
|
+
file: args[-2],
|
54
|
+
example: args[-1][/--name=(.*)/, 1],
|
55
|
+
request: request
|
56
|
+
)
|
41
57
|
else
|
42
|
-
Frameworks::Minitest::TestCase.new(
|
58
|
+
Frameworks::Minitest::TestCase.new(
|
59
|
+
file: args[-1],
|
60
|
+
request: request
|
61
|
+
)
|
43
62
|
end
|
44
63
|
end
|
45
64
|
|
@@ -50,6 +69,10 @@ module TestLauncher
|
|
50
69
|
def shell
|
51
70
|
@shell
|
52
71
|
end
|
72
|
+
|
73
|
+
def request
|
74
|
+
@request
|
75
|
+
end
|
53
76
|
end
|
54
77
|
end
|
55
78
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "test_launcher/rubymine/launcher"
|
2
2
|
require "test_launcher/shell/runner"
|
3
|
+
require "test_launcher/request"
|
3
4
|
|
4
5
|
# To allow us to simply specify our run configuration as:
|
5
6
|
#
|
@@ -19,8 +20,15 @@ require "test_launcher/shell/runner"
|
|
19
20
|
# So we throw them in the same bucket and let the launcher figure it
|
20
21
|
# out. It doesn't matter since we will `exec` a new command anyway.
|
21
22
|
|
23
|
+
dummy_request = TestLauncher::Request.new(
|
24
|
+
query: nil,
|
25
|
+
framework: nil,
|
26
|
+
run_all: false,
|
27
|
+
disable_spring: ENV["DISABLE_SPRING"]
|
28
|
+
)
|
22
29
|
|
23
30
|
TestLauncher::Rubymine::Launcher.new(
|
24
31
|
args: [$0].concat(ARGV),
|
25
|
-
shell: TestLauncher::Shell::Runner.new(log_path: "/dev/null")
|
32
|
+
shell: TestLauncher::Shell::Runner.new(log_path: "/dev/null"),
|
33
|
+
request: dummy_request
|
26
34
|
).launch
|
@@ -1,22 +1,48 @@
|
|
1
|
+
require "test_launcher/base_error"
|
2
|
+
|
1
3
|
module TestLauncher
|
2
|
-
module
|
4
|
+
module Search
|
3
5
|
class Git
|
6
|
+
NotInRepoError = Class.new(BaseError)
|
7
|
+
|
8
|
+
class Interface
|
9
|
+
attr_reader :shell
|
10
|
+
|
11
|
+
def initialize(shell)
|
12
|
+
@shell = shell
|
13
|
+
end
|
4
14
|
|
5
|
-
|
15
|
+
def ls_files(pattern)
|
16
|
+
shell.run("git ls-files '*#{pattern}*'")
|
17
|
+
end
|
18
|
+
|
19
|
+
def grep(regex, file_pattern)
|
20
|
+
shell.run("git grep --untracked --extended-regexp '#{regex}' -- '#{file_pattern}'")
|
21
|
+
end
|
6
22
|
|
23
|
+
def root_path
|
24
|
+
shell.run("git rev-parse --show-toplevel").first.tap do
|
25
|
+
if $? != 0
|
26
|
+
raise NotInRepoError, "test_launcher must be used in a git repository"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
7
30
|
end
|
8
31
|
|
9
|
-
|
10
|
-
|
11
|
-
|
32
|
+
attr_reader :interface
|
33
|
+
|
34
|
+
def initialize(shell, interface=Interface.new(shell))
|
35
|
+
@interface = interface
|
36
|
+
Dir.chdir(root_path) # MOVE ME!
|
12
37
|
end
|
13
38
|
|
14
39
|
def find_files(pattern)
|
15
|
-
|
40
|
+
relative_pattern = strip_system_path(pattern)
|
41
|
+
interface.ls_files(relative_pattern).map {|f| system_path(f)}
|
16
42
|
end
|
17
43
|
|
18
44
|
def grep(regex, file_pattern: '*')
|
19
|
-
results =
|
45
|
+
results = interface.grep(regex, file_pattern)
|
20
46
|
results.map do |result|
|
21
47
|
interpret_grep_result(result)
|
22
48
|
end
|
@@ -47,13 +73,12 @@ module TestLauncher
|
|
47
73
|
File.join(root_path, file)
|
48
74
|
end
|
49
75
|
|
76
|
+
def strip_system_path(file)
|
77
|
+
file.sub(/^#{root_path}\//, '')
|
78
|
+
end
|
79
|
+
|
50
80
|
def root_path
|
51
|
-
@root_path ||=
|
52
|
-
if $? != 0
|
53
|
-
shell.warn "test_launcher must be used in a git repository"
|
54
|
-
exit
|
55
|
-
end
|
56
|
-
end
|
81
|
+
@root_path ||= interface.root_path
|
57
82
|
end
|
58
83
|
|
59
84
|
def shell
|
data/lib/test_launcher.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
require "test_launcher/version"
|
2
2
|
|
3
|
+
require "test_launcher/base_error"
|
3
4
|
require "test_launcher/shell/runner"
|
4
5
|
require "test_launcher/search/git"
|
5
6
|
require "test_launcher/frameworks"
|
6
7
|
|
7
8
|
module TestLauncher
|
8
|
-
def self.launch(
|
9
|
-
shell = Shell::Runner.new(log_path:
|
10
|
-
searcher =
|
9
|
+
def self.launch(request)
|
10
|
+
shell = Shell::Runner.new(log_path: "/tmp/test_launcher.log")
|
11
|
+
searcher = Search::Git.new(shell)
|
11
12
|
|
12
13
|
command = Frameworks.locate(
|
13
|
-
|
14
|
+
request: request,
|
14
15
|
shell: shell,
|
15
|
-
searcher: searcher
|
16
|
-
input: input,
|
17
|
-
run_all: run_all
|
16
|
+
searcher: searcher
|
18
17
|
)
|
19
18
|
|
20
19
|
if command
|
@@ -22,5 +21,7 @@ module TestLauncher
|
|
22
21
|
else
|
23
22
|
shell.warn "No tests found."
|
24
23
|
end
|
24
|
+
rescue BaseError => e
|
25
|
+
shell.warn(e)
|
25
26
|
end
|
26
27
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "test_launcher/frameworks/implementation/test_case"
|
3
|
+
require "test_launcher/frameworks/implementation/locator"
|
4
|
+
|
5
|
+
module TestLauncher
|
6
|
+
module Frameworks
|
7
|
+
module Implementation
|
8
|
+
class LocatorTest < ::TestCase
|
9
|
+
class DummyTestCase < Implementation::TestCase
|
10
|
+
end
|
11
|
+
|
12
|
+
class DummyLocator < Implementation::Locator
|
13
|
+
def file_name_regex
|
14
|
+
/_test.rb/
|
15
|
+
end
|
16
|
+
|
17
|
+
def file_name_pattern
|
18
|
+
"*"
|
19
|
+
end
|
20
|
+
|
21
|
+
def regex_pattern
|
22
|
+
/.*/
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_case_class
|
26
|
+
DummyTestCase
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_prioritized_results__files_found_by_path__does_not_run_if_not_matching_regex__one_arg
|
31
|
+
searcher = mock {
|
32
|
+
stubs(:grep).returns([{file: "dummy_result"}])
|
33
|
+
expects(:find_files).never
|
34
|
+
}
|
35
|
+
|
36
|
+
request = stub(query: "file_not_matching_regex.js", run_all?: false)
|
37
|
+
|
38
|
+
locator = DummyLocator.new(request, searcher)
|
39
|
+
|
40
|
+
assert_equal 1, locator.prioritized_results.file_count
|
41
|
+
|
42
|
+
result = locator.prioritized_results.first
|
43
|
+
assert_equal "dummy_result", result.file
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_prioritized_results__files_found_by_path__does_not_run_if_not_matching_regex__all_args
|
47
|
+
searcher = mock {
|
48
|
+
stubs(:grep).returns([{file: "dummy_result"}])
|
49
|
+
expects(:find_files).never
|
50
|
+
}
|
51
|
+
|
52
|
+
request = stub(query: "matching_test.rb non_matching.js", run_all?: false)
|
53
|
+
|
54
|
+
locator = DummyLocator.new(request, searcher)
|
55
|
+
|
56
|
+
assert_equal 1, locator.prioritized_results.file_count
|
57
|
+
|
58
|
+
result = locator.prioritized_results.first
|
59
|
+
assert_equal "dummy_result", result.file
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_prioritized_results__files_found_by_path__uses_searcher_if_all_files_match_regex
|
63
|
+
searcher = mock {
|
64
|
+
expects(:find_files).with("matching_test.rb").returns(["/path/to/matching_test.rb"])
|
65
|
+
}
|
66
|
+
|
67
|
+
request = stub(query: "matching_test.rb ", run_all?: false)
|
68
|
+
|
69
|
+
locator = DummyLocator.new(request, searcher)
|
70
|
+
|
71
|
+
assert_equal 1, locator.prioritized_results.file_count
|
72
|
+
|
73
|
+
result = locator.prioritized_results.first
|
74
|
+
assert_equal "/path/to/matching_test.rb", result.file
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_prioritized_results__files_found_by_path__uses_searcher_if_all_files_match_regex__multiple_results
|
78
|
+
searcher = mock {
|
79
|
+
expects(:find_files).with("matching_test.rb").returns(["/path1/to/matching_test.rb", "/path2/to/matching_test.rb"])
|
80
|
+
}
|
81
|
+
|
82
|
+
request = stub(query: "matching_test.rb ", run_all?: false)
|
83
|
+
|
84
|
+
locator = DummyLocator.new(request, searcher)
|
85
|
+
|
86
|
+
assert_equal 2, locator.prioritized_results.file_count
|
87
|
+
|
88
|
+
assert_equal "/path1/to/matching_test.rb", locator.prioritized_results.first.file
|
89
|
+
assert_equal "/path2/to/matching_test.rb", locator.prioritized_results.last.file
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_prioritized_results__files_found_by_path__uses_searcher_if_all_files_match_regex__multiple_args
|
93
|
+
searcher = mock {
|
94
|
+
expects(:find_files).with("matching_1_test.rb").returns(["/path1/to/matching_1_test.rb", "/path2/to/matching_1_test.rb"])
|
95
|
+
expects(:find_files).with("matching_2_test.rb").returns(["/path1/to/matching_2_test.rb", "/path2/to/matching_2_test.rb"])
|
96
|
+
}
|
97
|
+
|
98
|
+
request = stub(query: "matching_1_test.rb matching_2_test.rb", run_all?: false)
|
99
|
+
|
100
|
+
locator = DummyLocator.new(request, searcher)
|
101
|
+
|
102
|
+
assert_equal 4, locator.prioritized_results.file_count
|
103
|
+
|
104
|
+
file_results = locator.prioritized_results.map(&:file)
|
105
|
+
|
106
|
+
assert file_results.include?("/path1/to/matching_1_test.rb")
|
107
|
+
assert file_results.include?("/path2/to/matching_1_test.rb")
|
108
|
+
assert file_results.include?("/path1/to/matching_2_test.rb")
|
109
|
+
assert file_results.include?("/path2/to/matching_2_test.rb")
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_prioritized_results__files_found_by_path__raises_unsupported_search_error
|
113
|
+
# if we find results for one path, but not for the other
|
114
|
+
# then we are confused as to what to do.
|
115
|
+
|
116
|
+
searcher = mock {
|
117
|
+
expects(:find_files).with("matching_1_test.rb").returns(["/path1/to/matching_1_test.rb", "/path2/to/matching_1_test.rb"])
|
118
|
+
expects(:find_files).with("matching_2_test.rb").returns([])
|
119
|
+
}
|
120
|
+
request = stub(query: "matching_1_test.rb matching_2_test.rb", run_all?: false)
|
121
|
+
|
122
|
+
locator = DummyLocator.new(request, searcher)
|
123
|
+
|
124
|
+
assert_raises Implementation::UnsupportedSearchError do
|
125
|
+
locator.prioritized_results
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_prioritized_results__files_found_by_path__runs_all_if_multiple_searches
|
130
|
+
searcher = mock {
|
131
|
+
expects(:find_files).with("matching_1_test.rb").returns(["/path1/to/matching_1_test.rb", "/path2/to/matching_1_test.rb"])
|
132
|
+
expects(:find_files).with("matching_2_test.rb").returns(["/path1/to/matching_2_test.rb", "/path2/to/matching_2_test.rb"])
|
133
|
+
}
|
134
|
+
request = stub(query: "matching_1_test.rb matching_2_test.rb", run_all?: false)
|
135
|
+
|
136
|
+
locator = DummyLocator.new(request, searcher)
|
137
|
+
|
138
|
+
assert locator.prioritized_results.run_all?
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_prioritized_results__files_found_by_path__does_not_run_all_if_single_search
|
142
|
+
searcher = mock {
|
143
|
+
expects(:find_files).with("matching_test.rb").returns(["/path1/to/matching_1_test.rb", "/path2/to/matching_1_test.rb"])
|
144
|
+
}
|
145
|
+
request = stub(query: "matching_test.rb", run_all?: false)
|
146
|
+
|
147
|
+
locator = DummyLocator.new(request, searcher)
|
148
|
+
|
149
|
+
assert ! locator.prioritized_results.run_all?
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_prioritized_results__files_found_by_path__does_not_run_all_if_single_search_unless_override
|
153
|
+
searcher = mock {
|
154
|
+
expects(:find_files).with("matching_test.rb").returns(["/path1/to/matching_1_test.rb", "/path2/to/matching_1_test.rb"])
|
155
|
+
}
|
156
|
+
|
157
|
+
request = stub(query: "matching_test.rb", run_all?: true)
|
158
|
+
|
159
|
+
locator = DummyLocator.new(request, searcher)
|
160
|
+
|
161
|
+
assert locator.prioritized_results.run_all?
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "test_launcher/frameworks/implementation/test_case"
|
3
|
+
|
4
|
+
|
5
|
+
module TestLauncher
|
6
|
+
module Frameworks
|
7
|
+
module Implementation
|
8
|
+
class TestCaseTest < ::TestCase
|
9
|
+
class DummyTestCase < Implementation::TestCase
|
10
|
+
def initialize(file:)
|
11
|
+
super(file: file, request: nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_root_dir_name
|
15
|
+
"test"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_app_root__one_test_dir
|
20
|
+
test_case = DummyTestCase.new(file: "/path/root/test/thing_test.rb")
|
21
|
+
|
22
|
+
assert_equal "/path/root", test_case.app_root
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_app_root__multiple_test_dirs__find_gemfile
|
26
|
+
test_case = DummyTestCase.new(file: "/path/root/test/inline_gem/test/thing_test.rb")
|
27
|
+
|
28
|
+
Dir.stubs(:entries).with("/path/root").returns([".", "..", "Gemfile", "other_stuff.rb"])
|
29
|
+
Dir.stubs(:entries).with("/path/root/test/inline_gem").returns([".", "..", "other_stuff.rb"])
|
30
|
+
|
31
|
+
assert_equal "/path/root", test_case.app_root
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_app_root__multiple_test_dirs__find_gemspec
|
35
|
+
test_case = DummyTestCase.new(file: "/path/root/test/inline_gem/test/thing_test.rb")
|
36
|
+
|
37
|
+
Dir.stubs(:entries).with("/path/root").returns([".", "..", "gem.gemspec", "other_stuff.rb"])
|
38
|
+
Dir.stubs(:entries).with("/path/root/test/inline_gem").returns([".", "..", "other_stuff.rb"])
|
39
|
+
|
40
|
+
assert_equal "/path/root", test_case.app_root
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_app_root__multiple_test_dirs__prefers_deeply_nested_dirs
|
44
|
+
test_case = DummyTestCase.new(file: "/path/root/test/inline_gem/test/thing_test.rb")
|
45
|
+
|
46
|
+
Dir.stubs(:entries).with("/path/root").returns(["Gemfile"])
|
47
|
+
Dir.stubs(:entries).with("/path/root/test/inline_gem").returns(["Gemfile"])
|
48
|
+
|
49
|
+
assert_equal "/path/root/test/inline_gem", test_case.app_root
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_app_root__multiple_test_dirs__finds_no_info__defaults_outward
|
53
|
+
test_case = DummyTestCase.new(file: "/path/root/test/inline_gem/test/thing_test.rb")
|
54
|
+
|
55
|
+
Dir.stubs(:entries).with("/path/root").returns([".", ".."])
|
56
|
+
Dir.stubs(:entries).with("/path/root/test/inline_gem").returns([".", ".."])
|
57
|
+
|
58
|
+
assert_equal "/path/root", test_case.app_root
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,65 +1,66 @@
|
|
1
1
|
require "test_helper"
|
2
|
+
require "test_launcher/request"
|
2
3
|
|
3
4
|
module TestLauncher
|
4
5
|
class MinitestIntegrationTest < TestCase
|
5
6
|
def test__single_method
|
6
|
-
|
7
|
+
launch("file_name_1__method_name_1")
|
7
8
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test #{system_path("test/test_launcher/fixtures/minitest/test/class_1_test.rb")} --name=/file_name_1__method_name_1/", Shell::Runner.recall_exec
|
8
9
|
end
|
9
10
|
|
10
11
|
def test__multiple_methods__same_file
|
11
|
-
|
12
|
+
launch("file_name_1")
|
12
13
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test #{system_path("test/test_launcher/fixtures/minitest/test/class_1_test.rb")} --name=/file_name_1/", Shell::Runner.recall_exec
|
13
14
|
end
|
14
15
|
|
15
16
|
def test__multiple_methods__different_files
|
16
|
-
|
17
|
+
launch("multiple_files__same_method")
|
17
18
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test #{system_path("test/test_launcher/fixtures/minitest/test/class_2_test.rb")} --name=/multiple_files__same_method/", Shell::Runner.recall_exec
|
18
19
|
end
|
19
20
|
|
20
21
|
def test__single_file
|
21
|
-
|
22
|
+
launch("class_1_test")
|
22
23
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' #{system_path("test/test_launcher/fixtures/minitest/test/class_1_test.rb")}", Shell::Runner.recall_exec
|
23
24
|
end
|
24
25
|
|
25
26
|
def test__uses_spring
|
26
|
-
|
27
|
+
launch("different_roo""t_test") # don't trigger the find in *this* file
|
27
28
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest/test/different_root")} && bundle exec spring testunit #{system_path("test/test_launcher/fixtures/minitest/test/different_root/test/different_root_test.rb")}", Shell::Runner.recall_exec
|
28
29
|
end
|
29
30
|
|
30
31
|
def test__multiple_files__found
|
31
|
-
|
32
|
+
launch("Root1""Dum""myTest""Class") # don't trigger the find in *this* file
|
32
33
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' #{system_path("test/test_launcher/fixtures/minitest/test/class_2_test.rb")}", Shell::Runner.recall_exec
|
33
34
|
end
|
34
35
|
|
35
36
|
def test__multiple_files__found__all
|
36
|
-
|
37
|
+
launch("Root1""DummyTest""Class", run_all: true) # don't trigger the find in *this* file
|
37
38
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' #{system_path("test/test_launcher/fixtures/minitest/test/class_1_test.rb")} #{system_path("test/test_launcher/fixtures/minitest/test/class_2_test.rb")}", Shell::Runner.recall_exec
|
38
39
|
end
|
39
40
|
|
40
41
|
def test__multiple_file_paths
|
41
|
-
|
42
|
+
launch("class_1_tes""t.rb class_2_test.rb") # don't trigger the find in *this* file
|
42
43
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' #{system_path("test/test_launcher/fixtures/minitest/test/class_1_test.rb")} #{system_path("test/test_launcher/fixtures/minitest/test/class_2_test.rb")}", Shell::Runner.recall_exec
|
43
44
|
end
|
44
45
|
|
45
46
|
def test__multiple_files__different_roots__all
|
46
|
-
|
47
|
+
launch("DummyTest""Class", run_all: true) # don't trigger the find in *this* file
|
47
48
|
expected = "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' #{system_path("test/test_launcher/fixtures/minitest/test/class_1_test.rb")} #{system_path("test/test_launcher/fixtures/minitest/test/class_2_test.rb")}; cd -;\n\ncd #{system_path("test/test_launcher/fixtures/minitest/test/different_root")} && bundle exec spring testunit #{system_path("test/test_launcher/fixtures/minitest/test/different_root/test/different_root_test.rb")}"
|
48
49
|
assert_equal expected, Shell::Runner.recall_exec
|
49
50
|
end
|
50
51
|
|
51
52
|
def test__regex
|
52
|
-
|
53
|
+
launch("Root1""DummyTest""Class1""Test") # don't trigger the find in *this* file
|
53
54
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' #{system_path("test/test_launcher/fixtures/minitest/test/class_1_test.rb")}", Shell::Runner.recall_exec
|
54
55
|
end
|
55
56
|
|
56
57
|
def test__regex__does_not_test_helper__methods
|
57
|
-
|
58
|
+
launch("helper_meth""od") # don't trigger the find in *this* file
|
58
59
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/minitest")} && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' #{system_path("test/test_launcher/fixtures/minitest/test/class_1_test.rb")}", Shell::Runner.recall_exec
|
59
60
|
end
|
60
61
|
|
61
62
|
def test__not_found
|
62
|
-
|
63
|
+
launch("not_found""thing")
|
63
64
|
assert_equal nil, Shell::Runner.recall_exec
|
64
65
|
end
|
65
66
|
|
@@ -68,5 +69,16 @@ module TestLauncher
|
|
68
69
|
def system_path(relative_dir)
|
69
70
|
File.join(Dir.pwd, relative_dir)
|
70
71
|
end
|
72
|
+
|
73
|
+
def launch(query, run_all: false)
|
74
|
+
request = Request.new(
|
75
|
+
query: query,
|
76
|
+
run_all: run_all,
|
77
|
+
framework: "minitest"
|
78
|
+
)
|
79
|
+
|
80
|
+
TestLauncher.launch(request)
|
81
|
+
end
|
82
|
+
|
71
83
|
end
|
72
84
|
end
|
@@ -1,65 +1,66 @@
|
|
1
1
|
require "test_helper"
|
2
|
+
require "test_launcher/request"
|
2
3
|
|
3
4
|
module TestLauncher
|
4
5
|
class RspecIntegrationTest < TestCase
|
5
6
|
def test__single_method
|
6
|
-
|
7
|
+
launch("file_name_1 example_name_""1")
|
7
8
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example file_name_1\\ example_name_1", Shell::Runner.recall_exec
|
8
9
|
end
|
9
10
|
|
10
11
|
def test__single_context
|
11
|
-
|
12
|
+
launch("file_name_1 con""text_1")
|
12
13
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example file_name_1\\ context_1", Shell::Runner.recall_exec
|
13
14
|
end
|
14
15
|
|
15
16
|
def test__single_describe
|
16
|
-
|
17
|
+
launch("Root1DummyTes""tClass1")
|
17
18
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example Root1DummyTes""tClass1", Shell::Runner.recall_exec
|
18
19
|
end
|
19
20
|
|
20
21
|
def test__multiple_methods__same_file
|
21
|
-
|
22
|
+
launch("file_name_1")
|
22
23
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example file_name_1", Shell::Runner.recall_exec
|
23
24
|
end
|
24
25
|
|
25
26
|
def test__multiple_methods__different_files
|
26
|
-
|
27
|
+
launch("multiple_files same_example")
|
27
28
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")} --example multiple_files\\ same_example", Shell::Runner.recall_exec
|
28
29
|
end
|
29
30
|
|
30
31
|
def test__single_file
|
31
|
-
|
32
|
+
launch("class_1_spec")
|
32
33
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")}", Shell::Runner.recall_exec
|
33
34
|
end
|
34
35
|
|
35
36
|
def test__multiple_files__found
|
36
|
-
|
37
|
+
launch("Root1") # don't trigger the find in *this* file
|
37
38
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")} --example Roo""t1", Shell::Runner.recall_exec
|
38
39
|
end
|
39
40
|
|
40
41
|
def test__multiple_files__found__all
|
41
|
-
|
42
|
+
launch("Root1""DummyTest""Class", run_all: true) # don't trigger the find in *this* file
|
42
43
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}", Shell::Runner.recall_exec
|
43
44
|
end
|
44
45
|
|
45
46
|
def test__multiple_file_paths
|
46
|
-
|
47
|
+
launch("class_1_spec.rb class_2_spec.rb") # don't trigger the find in *this* file
|
47
48
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}", Shell::Runner.recall_exec
|
48
49
|
end
|
49
50
|
|
50
51
|
def test__multiple_files__different_roots__all
|
51
|
-
|
52
|
+
launch("DummyTest""Class", run_all: true) # don't trigger the find in *this* file
|
52
53
|
expected = "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}; cd -;\n\ncd #{system_path("test/test_launcher/fixtures/rspec/spec/different_root")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb")}"
|
53
54
|
assert_equal expected, Shell::Runner.recall_exec
|
54
55
|
end
|
55
56
|
|
56
57
|
def test__regex
|
57
|
-
|
58
|
+
launch("a_test_that_u""ses") # don't trigger the find in *this* file
|
58
59
|
assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}", Shell::Runner.recall_exec
|
59
60
|
end
|
60
61
|
|
61
62
|
def test__not_found
|
62
|
-
|
63
|
+
launch("not_found""thing")
|
63
64
|
assert_equal nil, Shell::Runner.recall_exec
|
64
65
|
end
|
65
66
|
|
@@ -68,5 +69,15 @@ module TestLauncher
|
|
68
69
|
def system_path(relative_dir)
|
69
70
|
File.join(Dir.pwd, relative_dir)
|
70
71
|
end
|
72
|
+
|
73
|
+
def launch(query, run_all: false)
|
74
|
+
request = Request.new(
|
75
|
+
query: query,
|
76
|
+
run_all: run_all,
|
77
|
+
framework: "rspec"
|
78
|
+
)
|
79
|
+
|
80
|
+
TestLauncher.launch(request)
|
81
|
+
end
|
71
82
|
end
|
72
83
|
end
|
@@ -34,15 +34,17 @@ module TestLauncher
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def assert_executes(expected_command, args)
|
37
|
+
dummy_request = mock { stubs(:disable_spring?).returns(true) }
|
38
|
+
|
37
39
|
launcher = Rubymine::Launcher.new(
|
38
40
|
args: args.split(" "),
|
39
|
-
shell: dummy_shell
|
41
|
+
shell: dummy_shell,
|
42
|
+
request: dummy_request
|
40
43
|
)
|
41
44
|
|
42
45
|
launcher.launch
|
43
46
|
assert_equal 1, dummy_shell.recall(:exec).size
|
44
47
|
assert_equal [[expected_command]], dummy_shell.recall(:exec)
|
45
|
-
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "test_launcher/search/git"
|
3
|
+
|
4
|
+
module TestLauncher
|
5
|
+
module Search
|
6
|
+
class GitTest < TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
Dir.stubs(:chdir)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_files__strips_absolute_path_for_search_and_replaces_it
|
14
|
+
interface = mock {
|
15
|
+
expects(:root_path).returns("/path/to/repo")
|
16
|
+
expects(:ls_files).with("relative/file_test.rb").returns(["inline_gem/relative/file_test.rb"])
|
17
|
+
}
|
18
|
+
|
19
|
+
searcher = Git.new(nil, interface)
|
20
|
+
files = searcher.find_files("/path/to/repo/relative/file_test.rb")
|
21
|
+
|
22
|
+
assert_equal ["/path/to/repo/inline_gem/relative/file_test.rb"], files
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
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: 1.
|
4
|
+
version: 1.5.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: 2016-10-
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- Rakefile
|
54
54
|
- bin/test_launcher
|
55
55
|
- lib/test_launcher.rb
|
56
|
+
- lib/test_launcher/base_error.rb
|
56
57
|
- lib/test_launcher/cli/input_parser.rb
|
57
58
|
- lib/test_launcher/frameworks.rb
|
58
59
|
- lib/test_launcher/frameworks/base.rb
|
@@ -62,6 +63,7 @@ files:
|
|
62
63
|
- lib/test_launcher/frameworks/implementation/test_case.rb
|
63
64
|
- lib/test_launcher/frameworks/minitest.rb
|
64
65
|
- lib/test_launcher/frameworks/rspec.rb
|
66
|
+
- lib/test_launcher/request.rb
|
65
67
|
- lib/test_launcher/rubymine.rb
|
66
68
|
- lib/test_launcher/rubymine/launcher.rb
|
67
69
|
- lib/test_launcher/search/git.rb
|
@@ -70,16 +72,23 @@ files:
|
|
70
72
|
- lib/test_launcher/version.rb
|
71
73
|
- test/install
|
72
74
|
- test/test_helper.rb
|
75
|
+
- test/test_launcher/fixtures/minitest/Gemfile
|
73
76
|
- test/test_launcher/fixtures/minitest/test/class_1_test.rb
|
74
77
|
- test/test_launcher/fixtures/minitest/test/class_2_test.rb
|
78
|
+
- test/test_launcher/fixtures/minitest/test/different_root/Gemfile
|
75
79
|
- test/test_launcher/fixtures/minitest/test/different_root/bin/spring
|
76
80
|
- test/test_launcher/fixtures/minitest/test/different_root/test/different_root_test.rb
|
81
|
+
- test/test_launcher/fixtures/rspec/Gemfile
|
77
82
|
- test/test_launcher/fixtures/rspec/spec/class_1_spec.rb
|
78
83
|
- test/test_launcher/fixtures/rspec/spec/class_2_spec.rb
|
84
|
+
- test/test_launcher/fixtures/rspec/spec/different_root/Gemfile
|
79
85
|
- test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb
|
86
|
+
- test/test_launcher/frameworks/implementation/locator_test.rb
|
87
|
+
- test/test_launcher/frameworks/implementation/test_case_test.rb
|
80
88
|
- test/test_launcher/minitest_integration_test.rb
|
81
89
|
- test/test_launcher/rspec_integration_test.rb
|
82
90
|
- test/test_launcher/rubymine_test.rb
|
91
|
+
- test/test_launcher/search/git_test.rb
|
83
92
|
- test_launcher.gemspec
|
84
93
|
homepage: http://github.com/petekinnecom/test_launcher
|
85
94
|
licenses:
|
@@ -108,13 +117,20 @@ summary: Easily run tests
|
|
108
117
|
test_files:
|
109
118
|
- test/install
|
110
119
|
- test/test_helper.rb
|
120
|
+
- test/test_launcher/fixtures/minitest/Gemfile
|
111
121
|
- test/test_launcher/fixtures/minitest/test/class_1_test.rb
|
112
122
|
- test/test_launcher/fixtures/minitest/test/class_2_test.rb
|
123
|
+
- test/test_launcher/fixtures/minitest/test/different_root/Gemfile
|
113
124
|
- test/test_launcher/fixtures/minitest/test/different_root/bin/spring
|
114
125
|
- test/test_launcher/fixtures/minitest/test/different_root/test/different_root_test.rb
|
126
|
+
- test/test_launcher/fixtures/rspec/Gemfile
|
115
127
|
- test/test_launcher/fixtures/rspec/spec/class_1_spec.rb
|
116
128
|
- test/test_launcher/fixtures/rspec/spec/class_2_spec.rb
|
129
|
+
- test/test_launcher/fixtures/rspec/spec/different_root/Gemfile
|
117
130
|
- test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb
|
131
|
+
- test/test_launcher/frameworks/implementation/locator_test.rb
|
132
|
+
- test/test_launcher/frameworks/implementation/test_case_test.rb
|
118
133
|
- test/test_launcher/minitest_integration_test.rb
|
119
134
|
- test/test_launcher/rspec_integration_test.rb
|
120
135
|
- test/test_launcher/rubymine_test.rb
|
136
|
+
- test/test_launcher/search/git_test.rb
|