test_launcher 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/bin/test_launcher +2 -5
- data/lib/test_launcher/cli/input_parser.rb +37 -12
- data/lib/test_launcher/cli/query.rb +30 -0
- data/lib/test_launcher/cli/request.rb +61 -0
- data/lib/test_launcher/cli.rb +44 -0
- data/lib/test_launcher/frameworks/base.rb +26 -7
- data/lib/test_launcher/frameworks/elixir.rb +84 -0
- data/lib/test_launcher/frameworks/implementation/test_case.rb +4 -7
- data/lib/test_launcher/frameworks/minitest.rb +80 -23
- data/lib/test_launcher/frameworks/rspec.rb +38 -13
- data/lib/test_launcher/queries.rb +346 -0
- data/lib/test_launcher/rubymine/launcher.rb +1 -12
- data/lib/test_launcher/rubymine/request.rb +15 -0
- data/lib/test_launcher/rubymine.rb +20 -13
- data/lib/test_launcher/search/ag.rb +96 -0
- data/lib/test_launcher/search/git.rb +6 -2
- data/lib/test_launcher/search.rb +18 -0
- data/lib/test_launcher/shell/runner.rb +2 -1
- data/lib/test_launcher/version.rb +1 -1
- data/lib/test_launcher.rb +0 -26
- data/test/test_helper.rb +2 -1
- data/test/test_helpers/integration_helper.rb +40 -0
- data/test/test_helpers/mock.rb +59 -0
- data/test/test_helpers/mock_searcher.rb +1 -0
- data/test/test_helpers/mocks/searcher_mock.rb +82 -0
- data/test/test_helpers/mocks.rb +76 -0
- data/test/test_launcher/cli/input_parser_test.rb +72 -0
- data/test/test_launcher/frameworks/minitest/runner_test.rb +72 -0
- data/test/test_launcher/frameworks/minitest/searcher_test.rb +109 -0
- data/test/test_launcher/frameworks/rspec/runner_test.rb +76 -0
- data/test/test_launcher/frameworks/rspec/searcher_test.rb +54 -0
- data/test/test_launcher/minitest_integration_test.rb +31 -40
- data/test/test_launcher/queries/example_name_query_test.rb +217 -0
- data/test/test_launcher/queries/full_regex_query_test.rb +153 -0
- data/test/test_launcher/queries/generic_query_test.rb +23 -0
- data/test/test_launcher/queries/line_number_query_test.rb +107 -0
- data/test/test_launcher/queries/multi_term_query_test.rb +138 -0
- data/test/test_launcher/queries/path_query_test.rb +192 -0
- data/test/test_launcher/queries/search_query_test.rb +54 -0
- data/test/test_launcher/queries/single_term_query_test.rb +36 -0
- data/test/test_launcher/queries/specified_name_query_test.rb +112 -0
- data/test/test_launcher/rspec_integration_test.rb +27 -41
- data/test/test_launcher/search/git_test.rb +2 -0
- metadata +49 -10
- data/lib/test_launcher/frameworks/implementation/collection.rb +0 -36
- data/lib/test_launcher/frameworks/implementation/consolidator.rb +0 -83
- data/lib/test_launcher/frameworks/implementation/locator.rb +0 -118
- data/lib/test_launcher/frameworks.rb +0 -20
- data/lib/test_launcher/request.rb +0 -36
- data/test/test_launcher/frameworks/implementation/locator_test.rb +0 -166
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.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Kinnecom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -54,24 +54,33 @@ files:
|
|
54
54
|
- bin/test_launcher
|
55
55
|
- lib/test_launcher.rb
|
56
56
|
- lib/test_launcher/base_error.rb
|
57
|
+
- lib/test_launcher/cli.rb
|
57
58
|
- lib/test_launcher/cli/input_parser.rb
|
58
|
-
- lib/test_launcher/
|
59
|
+
- lib/test_launcher/cli/query.rb
|
60
|
+
- lib/test_launcher/cli/request.rb
|
59
61
|
- lib/test_launcher/frameworks/base.rb
|
60
|
-
- lib/test_launcher/frameworks/
|
61
|
-
- lib/test_launcher/frameworks/implementation/consolidator.rb
|
62
|
-
- lib/test_launcher/frameworks/implementation/locator.rb
|
62
|
+
- lib/test_launcher/frameworks/elixir.rb
|
63
63
|
- lib/test_launcher/frameworks/implementation/test_case.rb
|
64
64
|
- lib/test_launcher/frameworks/minitest.rb
|
65
65
|
- lib/test_launcher/frameworks/rspec.rb
|
66
|
-
- lib/test_launcher/
|
66
|
+
- lib/test_launcher/queries.rb
|
67
67
|
- lib/test_launcher/rubymine.rb
|
68
68
|
- lib/test_launcher/rubymine/launcher.rb
|
69
|
+
- lib/test_launcher/rubymine/request.rb
|
70
|
+
- lib/test_launcher/search.rb
|
71
|
+
- lib/test_launcher/search/ag.rb
|
69
72
|
- lib/test_launcher/search/git.rb
|
70
73
|
- lib/test_launcher/shell/color.rb
|
71
74
|
- lib/test_launcher/shell/runner.rb
|
72
75
|
- lib/test_launcher/version.rb
|
73
76
|
- test/install
|
74
77
|
- test/test_helper.rb
|
78
|
+
- test/test_helpers/integration_helper.rb
|
79
|
+
- test/test_helpers/mock.rb
|
80
|
+
- test/test_helpers/mock_searcher.rb
|
81
|
+
- test/test_helpers/mocks.rb
|
82
|
+
- test/test_helpers/mocks/searcher_mock.rb
|
83
|
+
- test/test_launcher/cli/input_parser_test.rb
|
75
84
|
- test/test_launcher/fixtures/minitest/Gemfile
|
76
85
|
- test/test_launcher/fixtures/minitest/test/class_1_test.rb
|
77
86
|
- test/test_launcher/fixtures/minitest/test/class_2_test.rb
|
@@ -83,9 +92,21 @@ files:
|
|
83
92
|
- test/test_launcher/fixtures/rspec/spec/class_2_spec.rb
|
84
93
|
- test/test_launcher/fixtures/rspec/spec/different_root/Gemfile
|
85
94
|
- test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb
|
86
|
-
- test/test_launcher/frameworks/implementation/locator_test.rb
|
87
95
|
- test/test_launcher/frameworks/implementation/test_case_test.rb
|
96
|
+
- test/test_launcher/frameworks/minitest/runner_test.rb
|
97
|
+
- test/test_launcher/frameworks/minitest/searcher_test.rb
|
98
|
+
- test/test_launcher/frameworks/rspec/runner_test.rb
|
99
|
+
- test/test_launcher/frameworks/rspec/searcher_test.rb
|
88
100
|
- test/test_launcher/minitest_integration_test.rb
|
101
|
+
- test/test_launcher/queries/example_name_query_test.rb
|
102
|
+
- test/test_launcher/queries/full_regex_query_test.rb
|
103
|
+
- test/test_launcher/queries/generic_query_test.rb
|
104
|
+
- test/test_launcher/queries/line_number_query_test.rb
|
105
|
+
- test/test_launcher/queries/multi_term_query_test.rb
|
106
|
+
- test/test_launcher/queries/path_query_test.rb
|
107
|
+
- test/test_launcher/queries/search_query_test.rb
|
108
|
+
- test/test_launcher/queries/single_term_query_test.rb
|
109
|
+
- test/test_launcher/queries/specified_name_query_test.rb
|
89
110
|
- test/test_launcher/rspec_integration_test.rb
|
90
111
|
- test/test_launcher/rubymine_test.rb
|
91
112
|
- test/test_launcher/search/git_test.rb
|
@@ -110,13 +131,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
131
|
version: '0'
|
111
132
|
requirements: []
|
112
133
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.5.2
|
114
135
|
signing_key:
|
115
136
|
specification_version: 4
|
116
137
|
summary: Easily run tests
|
117
138
|
test_files:
|
118
139
|
- test/install
|
119
140
|
- test/test_helper.rb
|
141
|
+
- test/test_helpers/integration_helper.rb
|
142
|
+
- test/test_helpers/mock.rb
|
143
|
+
- test/test_helpers/mock_searcher.rb
|
144
|
+
- test/test_helpers/mocks.rb
|
145
|
+
- test/test_helpers/mocks/searcher_mock.rb
|
146
|
+
- test/test_launcher/cli/input_parser_test.rb
|
120
147
|
- test/test_launcher/fixtures/minitest/Gemfile
|
121
148
|
- test/test_launcher/fixtures/minitest/test/class_1_test.rb
|
122
149
|
- test/test_launcher/fixtures/minitest/test/class_2_test.rb
|
@@ -128,9 +155,21 @@ test_files:
|
|
128
155
|
- test/test_launcher/fixtures/rspec/spec/class_2_spec.rb
|
129
156
|
- test/test_launcher/fixtures/rspec/spec/different_root/Gemfile
|
130
157
|
- test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb
|
131
|
-
- test/test_launcher/frameworks/implementation/locator_test.rb
|
132
158
|
- test/test_launcher/frameworks/implementation/test_case_test.rb
|
159
|
+
- test/test_launcher/frameworks/minitest/runner_test.rb
|
160
|
+
- test/test_launcher/frameworks/minitest/searcher_test.rb
|
161
|
+
- test/test_launcher/frameworks/rspec/runner_test.rb
|
162
|
+
- test/test_launcher/frameworks/rspec/searcher_test.rb
|
133
163
|
- test/test_launcher/minitest_integration_test.rb
|
164
|
+
- test/test_launcher/queries/example_name_query_test.rb
|
165
|
+
- test/test_launcher/queries/full_regex_query_test.rb
|
166
|
+
- test/test_launcher/queries/generic_query_test.rb
|
167
|
+
- test/test_launcher/queries/line_number_query_test.rb
|
168
|
+
- test/test_launcher/queries/multi_term_query_test.rb
|
169
|
+
- test/test_launcher/queries/path_query_test.rb
|
170
|
+
- test/test_launcher/queries/search_query_test.rb
|
171
|
+
- test/test_launcher/queries/single_term_query_test.rb
|
172
|
+
- test/test_launcher/queries/specified_name_query_test.rb
|
134
173
|
- test/test_launcher/rspec_integration_test.rb
|
135
174
|
- test/test_launcher/rubymine_test.rb
|
136
175
|
- test/test_launcher/search/git_test.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "delegate"
|
2
|
-
|
3
|
-
module TestLauncher
|
4
|
-
module Frameworks
|
5
|
-
module Implementation
|
6
|
-
class Collection < SimpleDelegator
|
7
|
-
alias :results :__getobj__
|
8
|
-
|
9
|
-
def initialize(results:, run_all:)
|
10
|
-
super(results)
|
11
|
-
@run_all = run_all
|
12
|
-
end
|
13
|
-
|
14
|
-
def file_count
|
15
|
-
results.group_by(&:file).size
|
16
|
-
end
|
17
|
-
|
18
|
-
def one_example?
|
19
|
-
examples_found? && results.size == 1
|
20
|
-
end
|
21
|
-
|
22
|
-
def examples_found?
|
23
|
-
results.any?(&:is_example?)
|
24
|
-
end
|
25
|
-
|
26
|
-
def last_edited
|
27
|
-
results.sort_by(&:mtime).last
|
28
|
-
end
|
29
|
-
|
30
|
-
def run_all?
|
31
|
-
@run_all
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
module TestLauncher
|
2
|
-
module Frameworks
|
3
|
-
module Implementation
|
4
|
-
class Consolidator < Struct.new(:search_results, :shell, :runner)
|
5
|
-
|
6
|
-
def self.consolidate(*args)
|
7
|
-
new(*args).consolidate
|
8
|
-
end
|
9
|
-
|
10
|
-
def consolidate
|
11
|
-
if search_results.empty?
|
12
|
-
nil
|
13
|
-
elsif one_example?
|
14
|
-
shell.notify "Found #{methods_count_phrase} in #{file_count_phrase}."
|
15
|
-
runner.single_example(search_results.first)
|
16
|
-
elsif examples_found? && same_file?
|
17
|
-
shell.notify "Multiple test methods match in 1 file."
|
18
|
-
runner.single_example(search_results.first)
|
19
|
-
elsif examples_found? && run_last_edited?
|
20
|
-
shell.notify "Found #{methods_count_phrase} in #{file_count_phrase}."
|
21
|
-
shell.notify "Running most recently edited. Run with '--all' to run all the tests."
|
22
|
-
runner.single_example(last_edited)
|
23
|
-
elsif files_found? && same_file?
|
24
|
-
shell.notify "Found #{file_count_phrase}."
|
25
|
-
runner.single_file(search_results.first)
|
26
|
-
elsif files_found? && run_last_edited?
|
27
|
-
shell.notify "Found #{file_count_phrase}."
|
28
|
-
shell.notify "Running most recently edited. Run with '--all' to run all the tests."
|
29
|
-
runner.single_file(last_edited)
|
30
|
-
else
|
31
|
-
shell.notify "Found #{file_count_phrase}."
|
32
|
-
runner.multiple_files(search_results.uniq {|sr| sr.file})
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def same_file?
|
37
|
-
file_count == 1
|
38
|
-
end
|
39
|
-
|
40
|
-
def one_example?
|
41
|
-
search_results.one_example?
|
42
|
-
end
|
43
|
-
|
44
|
-
def examples_found?
|
45
|
-
search_results.examples_found?
|
46
|
-
end
|
47
|
-
|
48
|
-
def files_found?
|
49
|
-
! examples_found?
|
50
|
-
end
|
51
|
-
|
52
|
-
def run_last_edited?
|
53
|
-
! search_results.run_all?
|
54
|
-
end
|
55
|
-
|
56
|
-
def last_edited
|
57
|
-
search_results.last_edited
|
58
|
-
end
|
59
|
-
|
60
|
-
def file_count
|
61
|
-
search_results.file_count
|
62
|
-
end
|
63
|
-
|
64
|
-
def methods_count_phrase
|
65
|
-
pluralize(search_results.size, "test method")
|
66
|
-
end
|
67
|
-
|
68
|
-
def file_count_phrase
|
69
|
-
pluralize(file_count, "file")
|
70
|
-
end
|
71
|
-
|
72
|
-
def pluralize(count, singular)
|
73
|
-
phrase = "#{count} #{singular}"
|
74
|
-
if count == 1
|
75
|
-
phrase
|
76
|
-
else
|
77
|
-
"#{phrase}s"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require "test_launcher/base_error"
|
2
|
-
require "test_launcher/frameworks/implementation/test_case"
|
3
|
-
require "test_launcher/frameworks/implementation/collection"
|
4
|
-
|
5
|
-
module TestLauncher
|
6
|
-
module Frameworks
|
7
|
-
module Implementation
|
8
|
-
UnsupportedSearchError = Class.new(BaseError)
|
9
|
-
|
10
|
-
class Locator < Struct.new(:request, :searcher)
|
11
|
-
private :request, :searcher
|
12
|
-
|
13
|
-
def prioritized_results
|
14
|
-
return files_found_by_path unless files_found_by_path.empty?
|
15
|
-
|
16
|
-
return examples_found_by_name unless examples_found_by_name.empty?
|
17
|
-
|
18
|
-
return files_found_by_file_name_regex unless files_found_by_file_name_regex.empty?
|
19
|
-
|
20
|
-
return files_found_by_full_regex unless files_found_by_full_regex.empty?
|
21
|
-
|
22
|
-
[]
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def files_found_by_path
|
28
|
-
# TODO: this needs some love
|
29
|
-
|
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
|
47
|
-
end
|
48
|
-
|
49
|
-
def examples_found_by_name
|
50
|
-
@examples_found_by_name ||= Collection.new(
|
51
|
-
results: full_regex_search(regex_pattern).map {|r| build_result(file: r[:file], query: request.query)},
|
52
|
-
run_all: request.run_all?
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
|
-
def files_found_by_file_name_regex
|
57
|
-
@files_found_by_file_name_regex ||= begin
|
58
|
-
potential_file_paths = request.query.split(" ")
|
59
|
-
split_query_results = potential_file_paths.map {|fp| searcher.find_files(fp).select {|f| f.match(file_name_regex) } }
|
60
|
-
|
61
|
-
return [] if split_query_results.any?(&:empty?)
|
62
|
-
|
63
|
-
Collection.new(
|
64
|
-
results: split_query_results.flatten.map {|f| build_result(file: f) },
|
65
|
-
run_all: true,
|
66
|
-
)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def files_found_by_full_regex
|
71
|
-
# we ignore the matched line since we don't know what to do with it
|
72
|
-
@files_found_by_full_regex ||= Collection.new(
|
73
|
-
results: full_regex_search(request.query).map {|r| build_result(file: r[:file]) },
|
74
|
-
run_all: request.run_all?
|
75
|
-
)
|
76
|
-
end
|
77
|
-
|
78
|
-
def full_regex_search(regex)
|
79
|
-
searcher.grep(regex, file_pattern: file_name_pattern)
|
80
|
-
end
|
81
|
-
|
82
|
-
def build_result(file:, query: nil)
|
83
|
-
test_case_class.from_search(file: file, query: query, request: request)
|
84
|
-
end
|
85
|
-
|
86
|
-
def file_name_regex
|
87
|
-
raise NotImplementedError
|
88
|
-
end
|
89
|
-
|
90
|
-
def file_name_pattern
|
91
|
-
raise NotImplementedError
|
92
|
-
end
|
93
|
-
|
94
|
-
def regex_pattern
|
95
|
-
raise NotImplementedError
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_case_class
|
99
|
-
raise NotImplementedError
|
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
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require "test_launcher/frameworks/implementation/consolidator"
|
2
|
-
|
3
|
-
|
4
|
-
module TestLauncher
|
5
|
-
module Frameworks
|
6
|
-
def self.locate(request:, shell:, searcher:)
|
7
|
-
request.frameworks.each do |framework|
|
8
|
-
search_results = framework::Locator.new(request, searcher).prioritized_results
|
9
|
-
runner = framework::Runner.new
|
10
|
-
|
11
|
-
command = Implementation::Consolidator.consolidate(search_results, shell, runner)
|
12
|
-
|
13
|
-
return command if command
|
14
|
-
end
|
15
|
-
|
16
|
-
nil
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
@@ -1,36 +0,0 @@
|
|
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,166 +0,0 @@
|
|
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
|