test_launcher 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/test_launcher/queries.rb +11 -25
- data/lib/test_launcher/search.rb +8 -8
- data/lib/test_launcher/search/ag.rb +1 -1
- data/lib/test_launcher/version.rb +1 -1
- data/test/test_launcher/search/ag_test.rb +42 -0
- metadata +5 -5
- data/lib/test_launcher/cli/query.rb +0 -30
- data/test/test_launcher/queries/search_query_test.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f991a1c539b38368a85a9f61ab2a0cb63043b715
|
4
|
+
data.tar.gz: '09fa671d444c7f6d25ace960d958d8e72aee2a53'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6216a818f743b22661e4318f14a27d0768db9de86aa6ea009a432c1734feb33adbc9895e345a856f9428bb4052a76b0843cba5dfa6b28a1600cca95b00f196b9
|
7
|
+
data.tar.gz: d427d0feec470480453ad91c55c24271e1573773d3ca7f32c87a43dc85ebd671b020bafd5d5a6299ba44d129ffecd5e3d731d363dc466b4f504b432f85150efe
|
@@ -29,10 +29,6 @@ module TestLauncher
|
|
29
29
|
commandify(FullRegexQuery)
|
30
30
|
end
|
31
31
|
|
32
|
-
def single_search_term
|
33
|
-
commandify(SingleTermQuery)
|
34
|
-
end
|
35
|
-
|
36
32
|
def full_search
|
37
33
|
commandify(SearchQuery)
|
38
34
|
end
|
@@ -143,6 +139,7 @@ module TestLauncher
|
|
143
139
|
|
144
140
|
class MultiPathQuery < BaseQuery
|
145
141
|
def command
|
142
|
+
return unless request.search_string.include?(" ")
|
146
143
|
return if test_cases.empty?
|
147
144
|
|
148
145
|
shell.notify("Found #{pluralize(file_count, "file")}.")
|
@@ -343,7 +340,8 @@ module TestLauncher
|
|
343
340
|
LINE_SPLIT_REGEX = /\A(?<file>.*):(?<line_number>\d+)\Z/
|
344
341
|
|
345
342
|
def command
|
346
|
-
return unless
|
343
|
+
return unless match
|
344
|
+
return unless test_cases.any?
|
347
345
|
|
348
346
|
if one_file?
|
349
347
|
shell.notify "Found #{pluralize(file_count, "file")}."
|
@@ -368,7 +366,6 @@ module TestLauncher
|
|
368
366
|
|
369
367
|
def search_results
|
370
368
|
@search_results ||= begin
|
371
|
-
match = request.search_string.match(LINE_SPLIT_REGEX)
|
372
369
|
if match
|
373
370
|
searcher.by_line(match[:file], match[:line_number].to_i)
|
374
371
|
else
|
@@ -376,33 +373,22 @@ module TestLauncher
|
|
376
373
|
end
|
377
374
|
end
|
378
375
|
end
|
376
|
+
|
377
|
+
def match
|
378
|
+
@match ||= request.search_string.match(LINE_SPLIT_REGEX)
|
379
|
+
end
|
379
380
|
end
|
380
381
|
|
381
|
-
class
|
382
|
+
class SearchQuery < BaseQuery
|
382
383
|
def command
|
383
384
|
[
|
385
|
+
:line_number,
|
384
386
|
:by_path,
|
387
|
+
:multi_path_query,
|
385
388
|
:example_name,
|
386
389
|
:multi_example_name,
|
387
390
|
:from_full_regex,
|
388
|
-
]
|
389
|
-
.each { |command_type|
|
390
|
-
command = command_finder.public_send(command_type)
|
391
|
-
return command if command
|
392
|
-
}
|
393
|
-
nil
|
394
|
-
end
|
395
|
-
end
|
396
|
-
|
397
|
-
class SearchQuery < BaseQuery
|
398
|
-
def command
|
399
|
-
{
|
400
|
-
multi_path_query: request.search_string.include?(" "),
|
401
|
-
line_number: request.search_string.include?(":"),
|
402
|
-
single_search_term: true
|
403
|
-
}.each {|command_type, valid|
|
404
|
-
next unless valid
|
405
|
-
|
391
|
+
].each {|command_type|
|
406
392
|
command = command_finder.public_send(command_type)
|
407
393
|
return command if command
|
408
394
|
}
|
data/lib/test_launcher/search.rb
CHANGED
@@ -4,15 +4,15 @@ require 'test_launcher/search/git'
|
|
4
4
|
module TestLauncher
|
5
5
|
module Search
|
6
6
|
def self.searcher(shell)
|
7
|
-
`which ag`
|
8
|
-
implementation =
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
# `which ag`
|
8
|
+
# implementation =
|
9
|
+
# if $?.success?
|
10
|
+
# Search::Ag
|
11
|
+
# else
|
12
|
+
# Search::Git
|
13
|
+
# end
|
14
14
|
|
15
|
-
|
15
|
+
Search::Git.new(shell)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "test_launcher/search/ag"
|
3
|
+
require "test_helpers/mocks"
|
4
|
+
|
5
|
+
module TestLauncher
|
6
|
+
module Search
|
7
|
+
class AgTest < TestCase
|
8
|
+
include DefaultMocks
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
Dir.stubs(:chdir)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_find_files__strips_absolute_path_for_search
|
16
|
+
interface = mock {
|
17
|
+
expects(:root_path).returns("/path/to/repo")
|
18
|
+
expects(:ls_files).with("relative/file_test.rb").returns(["inline_gem/relative/file_test.rb"])
|
19
|
+
}
|
20
|
+
|
21
|
+
searcher = Ag.new(nil, interface)
|
22
|
+
files = searcher.find_files("/path/to/repo/relative/file_test.rb")
|
23
|
+
|
24
|
+
assert_equal ["/path/to/repo/inline_gem/relative/file_test.rb"], files
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_grep__strips_absolute_path_of_file_pattern
|
28
|
+
interface = mock {
|
29
|
+
expects(:root_path).returns("/path/to/repo")
|
30
|
+
expects(:grep).with("regex", "relative/file_test.rb").returns([
|
31
|
+
"relative/file_test.rb:20: def test_regex"
|
32
|
+
])
|
33
|
+
}
|
34
|
+
|
35
|
+
searcher = Ag.new(nil, interface)
|
36
|
+
files = searcher.grep("regex", file_pattern: "/path/to/repo/relative/file_test.rb")
|
37
|
+
|
38
|
+
assert_equal [{file: "/path/to/repo/relative/file_test.rb", line_number: 20, line: "def test_regex"}], files
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
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.2.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-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,7 +56,6 @@ files:
|
|
56
56
|
- lib/test_launcher/base_error.rb
|
57
57
|
- lib/test_launcher/cli.rb
|
58
58
|
- lib/test_launcher/cli/input_parser.rb
|
59
|
-
- lib/test_launcher/cli/query.rb
|
60
59
|
- lib/test_launcher/cli/request.rb
|
61
60
|
- lib/test_launcher/frameworks/base.rb
|
62
61
|
- lib/test_launcher/frameworks/ex_unit.rb
|
@@ -94,9 +93,9 @@ files:
|
|
94
93
|
- test/test_launcher/queries/line_number_query_test.rb
|
95
94
|
- test/test_launcher/queries/multi_path_query_test.rb
|
96
95
|
- test/test_launcher/queries/path_query_test.rb
|
97
|
-
- test/test_launcher/queries/search_query_test.rb
|
98
96
|
- test/test_launcher/rspec_integration_test.rb
|
99
97
|
- test/test_launcher/rubymine_test.rb
|
98
|
+
- test/test_launcher/search/ag_test.rb
|
100
99
|
- test/test_launcher/search/git_test.rb
|
101
100
|
- test_launcher.gemspec
|
102
101
|
homepage: http://github.com/petekinnecom/test_launcher
|
@@ -145,7 +144,8 @@ test_files:
|
|
145
144
|
- test/test_launcher/queries/line_number_query_test.rb
|
146
145
|
- test/test_launcher/queries/multi_path_query_test.rb
|
147
146
|
- test/test_launcher/queries/path_query_test.rb
|
148
|
-
- test/test_launcher/queries/search_query_test.rb
|
149
147
|
- test/test_launcher/rspec_integration_test.rb
|
150
148
|
- test/test_launcher/rubymine_test.rb
|
149
|
+
- test/test_launcher/search/ag_test.rb
|
151
150
|
- test/test_launcher/search/git_test.rb
|
151
|
+
has_rdoc:
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "test_launcher/base_error"
|
2
|
-
require "test_launcher/queries"
|
3
|
-
require "test_launcher/cli/request"
|
4
|
-
|
5
|
-
module TestLauncher
|
6
|
-
module CLI
|
7
|
-
class Query < BaseQuery
|
8
|
-
attr_reader :shell, :searcher
|
9
|
-
|
10
|
-
def command
|
11
|
-
def queries
|
12
|
-
requests.map {|request| Queries::GenericQuery.new(request: request)}
|
13
|
-
end
|
14
|
-
|
15
|
-
def requests
|
16
|
-
@frameworks.map {|framework|
|
17
|
-
Request.new(
|
18
|
-
framework: framework,
|
19
|
-
search_string: @search_string,
|
20
|
-
run_all: @run_all,
|
21
|
-
disable_spring: @disable_spring,
|
22
|
-
example_name: @example_name,
|
23
|
-
shell: shell,
|
24
|
-
searcher: searcher
|
25
|
-
)
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "test_helpers/mocks"
|
3
|
-
require "test_launcher/queries"
|
4
|
-
|
5
|
-
module TestLauncher
|
6
|
-
module Queries
|
7
|
-
class SearchQueryTest < TestCase
|
8
|
-
include DefaultMocks
|
9
|
-
|
10
|
-
def test__multi_search_term__hits
|
11
|
-
command_finder = Mock.new(Queries::CommandFinder, multi_path_query: :multi_path_query)
|
12
|
-
request = MockRequest.new(search_string: "a b")
|
13
|
-
|
14
|
-
assert_equal :multi_path_query, SearchQuery.new(request, command_finder).command
|
15
|
-
end
|
16
|
-
|
17
|
-
def test__multi_search_term__misses
|
18
|
-
command_finder = Mock.new(Queries::CommandFinder, multi_path_query: nil, single_search_term: :single_search_term)
|
19
|
-
request = MockRequest.new(search_string: "a b")
|
20
|
-
|
21
|
-
assert_equal :single_search_term, SearchQuery.new(request, command_finder).command
|
22
|
-
end
|
23
|
-
|
24
|
-
def test__line_number__hits
|
25
|
-
command_finder = Mock.new(Queries::CommandFinder, line_number: :line_number)
|
26
|
-
request = MockRequest.new(search_string: "a:1")
|
27
|
-
|
28
|
-
assert_equal :line_number, SearchQuery.new(request, command_finder).command
|
29
|
-
end
|
30
|
-
|
31
|
-
def test__line_number__misses
|
32
|
-
command_finder = Mock.new(Queries::CommandFinder, line_number: nil, single_search_term: :single_search_term)
|
33
|
-
request = MockRequest.new(search_string: "a:1")
|
34
|
-
|
35
|
-
assert_equal :single_search_term, SearchQuery.new(request, command_finder).command
|
36
|
-
end
|
37
|
-
|
38
|
-
def test__single_search_term
|
39
|
-
command_finder = Mock.new(Queries::CommandFinder, single_search_term: :single_search_term)
|
40
|
-
request = MockRequest.new(search_string: "a")
|
41
|
-
|
42
|
-
assert_equal :single_search_term, SearchQuery.new(request, command_finder).command
|
43
|
-
end
|
44
|
-
|
45
|
-
def test__none
|
46
|
-
command_finder = Mock.new(Queries::CommandFinder, single_search_term: nil)
|
47
|
-
request = MockRequest.new(search_string: "a")
|
48
|
-
|
49
|
-
assert_equal nil, SearchQuery.new(request, command_finder).command
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|