test_launcher 1.5.2 → 2.0.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 +81 -37
- data/lib/test_launcher/cli.rb +1 -3
- data/lib/test_launcher/cli/input_parser.rb +10 -6
- data/lib/test_launcher/frameworks/base.rb +11 -0
- data/lib/test_launcher/frameworks/{elixir.rb → ex_unit.rb} +16 -20
- data/lib/test_launcher/frameworks/minitest.rb +29 -17
- data/lib/test_launcher/frameworks/rspec.rb +14 -7
- data/lib/test_launcher/queries.rb +47 -31
- data/lib/test_launcher/shell/runner.rb +2 -1
- data/lib/test_launcher/version.rb +1 -1
- data/test/test_helpers/integration_helper.rb +6 -13
- data/test/test_helpers/mocks.rb +1 -0
- data/test/test_helpers/mocks/searcher_mock.rb +3 -1
- data/test/test_launcher/ex_unit_integration_test.rb +392 -0
- data/test/test_launcher/fixtures/minitest/test/class_1_test.rb +4 -15
- data/test/test_launcher/fixtures/minitest/test/class_2_test.rb +7 -3
- data/test/test_launcher/frameworks/minitest/runner_test.rb +10 -10
- data/test/test_launcher/frameworks/minitest/searcher_test.rb +11 -10
- data/test/test_launcher/frameworks/rspec/runner_test.rb +5 -5
- data/test/test_launcher/frameworks/rspec/searcher_test.rb +4 -4
- data/test/test_launcher/minitest_integration_test.rb +533 -38
- data/test/test_launcher/queries/example_name_query_test.rb +5 -1
- data/test/test_launcher/queries/line_number_query_test.rb +7 -7
- data/test/test_launcher/queries/multi_term_query_test.rb +0 -12
- data/test/test_launcher/rspec_integration_test.rb +458 -35
- metadata +5 -5
- data/test/test_launcher/queries/specified_name_query_test.rb +0 -112
@@ -1,17 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def test__file_name_1__method_name_2
|
7
|
-
test_unit_test_method_body
|
8
|
-
end
|
9
|
-
|
10
|
-
def test__multiple_files__same_method
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def helper_method
|
15
|
-
|
1
|
+
require 'minitest/autorun'
|
2
|
+
class Class1Test < Minitest::Test
|
3
|
+
def test_1
|
4
|
+
assert false, "1 was run"
|
16
5
|
end
|
17
6
|
end
|
@@ -1,5 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'minitest/autorun'
|
2
|
+
class Class2Test < Minitest::Test
|
3
|
+
def test_1
|
4
|
+
assert false, "Class2: test_1 was run"
|
5
|
+
end
|
6
|
+
def test_2
|
7
|
+
assert false, "Class2: test_2 was run"
|
4
8
|
end
|
5
9
|
end
|
@@ -15,10 +15,10 @@ module TestLauncher
|
|
15
15
|
test_case = MockTestCase.new(
|
16
16
|
example: "example_name",
|
17
17
|
app_root: "app_root",
|
18
|
-
|
18
|
+
example_runner: "example_runner",
|
19
19
|
file: "file"
|
20
20
|
)
|
21
|
-
assert_equal "cd app_root &&
|
21
|
+
assert_equal "cd app_root && example_runner file --name=/example_name/", Runner.new.single_example(test_case)
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_multiple_examples_same_file
|
@@ -26,27 +26,27 @@ module TestLauncher
|
|
26
26
|
MockTestCase.new(
|
27
27
|
example: "example_name",
|
28
28
|
app_root: "app_root",
|
29
|
-
|
29
|
+
example_runner: "example_runner",
|
30
30
|
file: "file"
|
31
31
|
),
|
32
32
|
MockTestCase.new(
|
33
33
|
example: "example_name",
|
34
34
|
app_root: "app_root",
|
35
|
-
|
35
|
+
example_runner: "example_runner",
|
36
36
|
file: "file"
|
37
37
|
)
|
38
38
|
]
|
39
|
-
assert_equal "cd app_root &&
|
39
|
+
assert_equal "cd app_root && example_runner file --name=/example_name/", Runner.new.multiple_examples_same_file(test_cases)
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_single_file
|
43
43
|
test_case = MockTestCase.new(
|
44
44
|
example: "example_name",
|
45
45
|
app_root: "app_root",
|
46
|
-
|
46
|
+
file_runner: "file_runner",
|
47
47
|
file: "file"
|
48
48
|
)
|
49
|
-
assert_equal "cd app_root &&
|
49
|
+
assert_equal "cd app_root && file_runner file", Runner.new.single_file(test_case)
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_one_or_more_files
|
@@ -54,17 +54,17 @@ module TestLauncher
|
|
54
54
|
MockTestCase.new(
|
55
55
|
example: "example_name",
|
56
56
|
app_root: "app_root",
|
57
|
-
|
57
|
+
file_runner: "file_runner",
|
58
58
|
file: "file_1"
|
59
59
|
),
|
60
60
|
MockTestCase.new(
|
61
61
|
example: "example_name",
|
62
62
|
app_root: "app_root",
|
63
|
-
|
63
|
+
file_runner: "file_runner",
|
64
64
|
file: "file_2"
|
65
65
|
)
|
66
66
|
]
|
67
|
-
assert_equal "cd app_root &&
|
67
|
+
assert_equal "cd app_root && file_runner file_1 file_2", Runner.new.one_or_more_files(test_cases)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -13,7 +13,7 @@ module TestLauncher
|
|
13
13
|
mocks Search::Git
|
14
14
|
|
15
15
|
impl :grep do |regex, file_pattern:|
|
16
|
-
example_name_regex = "^ *def test_.*.*" #TODO: no bueno copying this
|
16
|
+
example_name_regex = "^ *def +test_.*.*" #TODO: no bueno copying this
|
17
17
|
case [regex, file_pattern]
|
18
18
|
when [example_name_regex, "test/test_launcher/single_test.rb"]
|
19
19
|
[
|
@@ -34,6 +34,7 @@ module TestLauncher
|
|
34
34
|
"test/dir/2_multiple_test.rb:30: def test__second",
|
35
35
|
]
|
36
36
|
else
|
37
|
+
require "pry";binding.pry
|
37
38
|
raise "unmocked search: #{regex}, #{file_pattern}"
|
38
39
|
end
|
39
40
|
end
|
@@ -59,42 +60,42 @@ module TestLauncher
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def test_by_line__file_not_found
|
62
|
-
assert_equal
|
63
|
+
assert_equal [], searcher.by_line("not_found_test.rb", 1)
|
63
64
|
end
|
64
65
|
|
65
66
|
def test_by_line__file_is_not_test_file
|
66
|
-
assert_equal
|
67
|
+
assert_equal [], searcher.by_line("non_test_file.rb", 1)
|
67
68
|
end
|
68
69
|
|
69
70
|
def test_by_line__single_file_line_before_all_examples
|
70
|
-
expected_result = {file: "test/test_launcher/single_test.rb"}
|
71
|
+
expected_result = [{file: "test/test_launcher/single_test.rb"}]
|
71
72
|
assert_equal expected_result, searcher.by_line("single_test.rb", 1)
|
72
73
|
end
|
73
74
|
|
74
75
|
def test_by_line__single_file_line_exact_number
|
75
|
-
expected_result = {
|
76
|
+
expected_result = [{
|
76
77
|
file: "test/test_launcher/single_test.rb",
|
77
78
|
example_name: "test__first",
|
78
79
|
line_number: 8
|
79
|
-
}
|
80
|
+
}]
|
80
81
|
assert_equal expected_result, searcher.by_line("single_test.rb", 8)
|
81
82
|
end
|
82
83
|
|
83
84
|
def test_by_line__single_file_line_after_example
|
84
|
-
expected_result = {
|
85
|
+
expected_result = [{
|
85
86
|
file: "test/test_launcher/single_test.rb",
|
86
87
|
example_name: "test__first",
|
87
88
|
line_number: 8
|
88
|
-
}
|
89
|
+
}]
|
89
90
|
assert_equal expected_result, searcher.by_line("single_test.rb", 10)
|
90
91
|
end
|
91
92
|
|
92
93
|
def test_by_line__single_file_line_after_example_2
|
93
|
-
expected_result = {
|
94
|
+
expected_result = [{
|
94
95
|
file: "test/test_launcher/single_test.rb",
|
95
96
|
example_name: "test__second",
|
96
97
|
line_number: 13
|
97
|
-
}
|
98
|
+
}]
|
98
99
|
assert_equal expected_result, searcher.by_line("single_test.rb", 17)
|
99
100
|
end
|
100
101
|
|
@@ -17,7 +17,7 @@ module TestLauncher
|
|
17
17
|
app_root: "app_root",
|
18
18
|
file: "file"
|
19
19
|
)
|
20
|
-
assert_equal "cd app_root && rspec file --example example_name", Runner.new.single_example(test_case)
|
20
|
+
assert_equal "cd app_root && bundle exec rspec file --example example_name", Runner.new.single_example(test_case)
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_single_example__with_messy_name
|
@@ -26,7 +26,7 @@ module TestLauncher
|
|
26
26
|
app_root: "app_root",
|
27
27
|
file: "file"
|
28
28
|
)
|
29
|
-
assert_equal "cd app_root && rspec file --example this\\ is\\ it\\'s\\ name\\ :\\(", Runner.new.single_example(test_case)
|
29
|
+
assert_equal "cd app_root && bundle exec rspec file --example this\\ is\\ it\\'s\\ name\\ :\\(", Runner.new.single_example(test_case)
|
30
30
|
end
|
31
31
|
|
32
32
|
|
@@ -43,7 +43,7 @@ module TestLauncher
|
|
43
43
|
file: "file"
|
44
44
|
)
|
45
45
|
]
|
46
|
-
assert_equal "cd app_root && rspec file --example example_name", Runner.new.multiple_examples_same_file(test_cases)
|
46
|
+
assert_equal "cd app_root && bundle exec rspec file --example example_name", Runner.new.multiple_examples_same_file(test_cases)
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_single_file
|
@@ -52,7 +52,7 @@ module TestLauncher
|
|
52
52
|
app_root: "app_root",
|
53
53
|
file: "file"
|
54
54
|
)
|
55
|
-
assert_equal "cd app_root && rspec file", Runner.new.single_file(test_case)
|
55
|
+
assert_equal "cd app_root && bundle exec rspec file", Runner.new.single_file(test_case)
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_one_or_more_files
|
@@ -68,7 +68,7 @@ module TestLauncher
|
|
68
68
|
file: "file_2"
|
69
69
|
)
|
70
70
|
]
|
71
|
-
assert_equal "cd app_root && rspec file_1 file_2", Runner.new.one_or_more_files(test_cases)
|
71
|
+
assert_equal "cd app_root && bundle exec rspec file_1 file_2", Runner.new.one_or_more_files(test_cases)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -33,18 +33,18 @@ module TestLauncher
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_by_line__file_not_found
|
36
|
-
assert_equal
|
36
|
+
assert_equal [], searcher.by_line("not_found_spec.rb", 1)
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_by_line__file_is_not_test_file
|
40
|
-
assert_equal
|
40
|
+
assert_equal [], searcher.by_line("non_test_file.rb", 1)
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_by_line__file_is_found
|
44
|
-
expected_result = {
|
44
|
+
expected_result = [{
|
45
45
|
file: "spec/test_launcher/single_spec.rb",
|
46
46
|
line_number: 8
|
47
|
-
}
|
47
|
+
}]
|
48
48
|
|
49
49
|
assert_equal expected_result, searcher.by_line("single_spec.rb", 8)
|
50
50
|
end
|
@@ -5,71 +5,566 @@ module TestLauncher
|
|
5
5
|
class MinitestIntegrationTest < TestCase
|
6
6
|
include IntegrationHelper
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
8
|
+
def launch(query, env: {}, searcher:)
|
9
|
+
query += " --framework minitest "
|
10
|
+
shell_mock.reset
|
11
|
+
CLI.launch(query.split(" "), env, shell: shell_mock, searcher: searcher)
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
14
|
+
def test__by_example__single_method
|
15
|
+
searcher = MemorySearcher.new do |searcher|
|
16
|
+
searcher.mock_file do |f|
|
17
|
+
f.path "/src/test/class_1_test.rb"
|
18
|
+
f.contents <<-RB
|
19
|
+
class Class1Test
|
20
|
+
def test_name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
RB
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
launch("test_name", searcher: searcher)
|
28
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name=/test_name/", shell_mock.recall_exec
|
29
|
+
|
30
|
+
launch("n", searcher: searcher)
|
31
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name=/n/", shell_mock.recall_exec
|
32
|
+
end
|
33
|
+
|
34
|
+
def test__by_example__multiple_methods__same_file
|
35
|
+
searcher = MemorySearcher.new do |searcher|
|
36
|
+
searcher.mock_file do |f|
|
37
|
+
f.path "/src/test/class_1_test.rb"
|
38
|
+
f.contents <<-RB
|
39
|
+
class Class1Test
|
40
|
+
def test_name_1
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_name_2
|
44
|
+
end
|
45
|
+
end
|
46
|
+
RB
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
launch("name_", searcher: searcher)
|
51
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name=/name_/", shell_mock.recall_exec
|
16
52
|
end
|
17
53
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
54
|
+
def test__by_example__multiple_methods__regex_issue
|
55
|
+
searcher = MemorySearcher.new do |searcher|
|
56
|
+
searcher.mock_file do |f|
|
57
|
+
f.path "/src/test/class_1_test.rb"
|
58
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
59
|
+
f.contents <<-RB
|
60
|
+
def test_name_1
|
61
|
+
RB
|
62
|
+
end
|
63
|
+
|
64
|
+
searcher.mock_file do |f|
|
65
|
+
f.path "/src/test/class_2_test.rb"
|
66
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
67
|
+
f.contents <<-RB
|
68
|
+
def test_somename
|
69
|
+
RB
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
launch("test_name", searcher: searcher)
|
74
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name=/test_name/", shell_mock.recall_exec
|
75
|
+
|
76
|
+
skip
|
77
|
+
# not seeing a good solution here...
|
78
|
+
# we cannot tell whether the _ is part of the test_ or not.
|
79
|
+
# might need to do two passes: first with user input, then
|
80
|
+
# filter down to those that match test_...would that work?
|
81
|
+
launch("_name", searcher: searcher)
|
82
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name=/test_name/", shell_mock.recall_exec
|
21
83
|
end
|
22
84
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
85
|
+
def test__by_example__multiple_methods__different_files
|
86
|
+
searcher = MemorySearcher.new do |searcher|
|
87
|
+
searcher.mock_file do |f|
|
88
|
+
f.path "/src/test/class_1_test.rb"
|
89
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
90
|
+
f.contents <<-RB
|
91
|
+
def test_name_1
|
92
|
+
def test_name_2
|
93
|
+
RB
|
94
|
+
end
|
95
|
+
|
96
|
+
searcher.mock_file do |f|
|
97
|
+
f.path "/src/test/class_2_test.rb"
|
98
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
99
|
+
f.contents <<-RB
|
100
|
+
def test_name_1
|
101
|
+
def test_name_2
|
102
|
+
RB
|
103
|
+
end
|
104
|
+
|
105
|
+
searcher.mock_file do |f|
|
106
|
+
f.path "/src/test/class_3_test.rb"
|
107
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
108
|
+
f.contents <<-RB
|
109
|
+
def test_name_2
|
110
|
+
RB
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
launch("name_1", searcher: searcher)
|
115
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/class_2_test.rb --name=/name_1/", shell_mock.recall_exec
|
116
|
+
|
117
|
+
launch("name_2", searcher: searcher)
|
118
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/class_2_test.rb --name=/name_2/", shell_mock.recall_exec
|
119
|
+
|
120
|
+
launch("name_1 --all", searcher: searcher)
|
121
|
+
assert_equal "cd /src && bundle exec ruby -I test -e \"ARGV.push('--name=/name_1/')\" -r /src/test/class_1_test.rb -r /src/test/class_2_test.rb", shell_mock.recall_exec
|
122
|
+
|
123
|
+
launch("name_2 --all", searcher: searcher)
|
124
|
+
assert_equal "cd /src && bundle exec ruby -I test -e \"ARGV.push('--name=/name_2/')\" -r /src/test/class_1_test.rb -r /src/test/class_2_test.rb -r /src/test/class_3_test.rb", shell_mock.recall_exec
|
125
|
+
|
126
|
+
launch("name_1|name_2 --all", searcher: searcher)
|
127
|
+
assert_equal "cd /src && bundle exec ruby -I test -e \"ARGV.push('--name=/name_1|name_2/')\" -r /src/test/class_1_test.rb -r /src/test/class_2_test.rb -r /src/test/class_3_test.rb", shell_mock.recall_exec
|
128
|
+
end
|
129
|
+
|
130
|
+
def test__by_filename
|
131
|
+
searcher = MemorySearcher.new do |searcher|
|
132
|
+
searcher.mock_file do |f|
|
133
|
+
f.path "/src/test/file_1_test.rb"
|
134
|
+
f.contents ""
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
launch("file_1", searcher: searcher)
|
139
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
140
|
+
|
141
|
+
launch("file_1_test.rb", searcher: searcher)
|
142
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
143
|
+
|
144
|
+
launch("/file_1", searcher: searcher)
|
145
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
146
|
+
|
147
|
+
launch(".rb", searcher: searcher)
|
148
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
149
|
+
|
150
|
+
launch("/src/test/file_1", searcher: searcher)
|
151
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
152
|
+
|
153
|
+
launch("src/test/file_1", searcher: searcher)
|
154
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
155
|
+
|
156
|
+
launch("st/file_1", searcher: searcher)
|
157
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
26
158
|
end
|
27
159
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
160
|
+
def test__by_filename__multiple_files_found
|
161
|
+
searcher = MemorySearcher.new do |searcher|
|
162
|
+
searcher.mock_file do |f|
|
163
|
+
f.path "/src/test/file_1_test.rb"
|
164
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
165
|
+
end
|
166
|
+
|
167
|
+
searcher.mock_file do |f|
|
168
|
+
f.path "/src/test/file_2_test.rb"
|
169
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
170
|
+
end
|
171
|
+
|
172
|
+
searcher.mock_file do |f|
|
173
|
+
f.path "/src/test/file_3_test.rb"
|
174
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
175
|
+
end
|
176
|
+
|
177
|
+
searcher.mock_file do |f|
|
178
|
+
f.path "/src/test/other_test.rb"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
launch("file_1", searcher: searcher)
|
183
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
184
|
+
|
185
|
+
launch("file", searcher: searcher)
|
186
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_2_test.rb", shell_mock.recall_exec
|
187
|
+
|
188
|
+
launch("file --all", searcher: searcher)
|
189
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb /src/test/file_3_test.rb", shell_mock.recall_exec
|
31
190
|
end
|
32
191
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
192
|
+
def test__by_filename__preferred_over_regex_and_test_name_matches
|
193
|
+
searcher = MemorySearcher.new do |searcher|
|
194
|
+
searcher.mock_file do |f|
|
195
|
+
f.path "/src/test/class_1_test.rb"
|
196
|
+
f.contents <<-RB
|
197
|
+
def test_name
|
198
|
+
RB
|
199
|
+
end
|
200
|
+
|
201
|
+
searcher.mock_file do |f|
|
202
|
+
f.path "/src/test/name_test.rb"
|
203
|
+
end
|
204
|
+
|
205
|
+
searcher.mock_file do |f|
|
206
|
+
f.path "/src/test/other_test.rb"
|
207
|
+
f.contents <<-RB
|
208
|
+
regex will match name_test
|
209
|
+
RB
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
launch("name_test", searcher: searcher)
|
214
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/name_test.rb", shell_mock.recall_exec
|
36
215
|
end
|
37
216
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
217
|
+
def test__by_multiple_filenames__multiple_files_found
|
218
|
+
searcher = MemorySearcher.new do |searcher|
|
219
|
+
searcher.mock_file do |f|
|
220
|
+
f.path "/src/test/file_1_test.rb"
|
221
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
222
|
+
f.contents ""
|
223
|
+
end
|
224
|
+
|
225
|
+
searcher.mock_file do |f|
|
226
|
+
f.path "/src/test/file_2_test.rb"
|
227
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
228
|
+
f.contents ""
|
229
|
+
end
|
230
|
+
|
231
|
+
searcher.mock_file do |f|
|
232
|
+
f.path "/src/test/file_3_test.rb"
|
233
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
234
|
+
f.contents ""
|
235
|
+
end
|
236
|
+
|
237
|
+
searcher.mock_file do |f|
|
238
|
+
f.path "/src/test/other_test.rb"
|
239
|
+
f.contents ""
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
launch("file_1 file_2", searcher: searcher)
|
244
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb", shell_mock.recall_exec
|
245
|
+
|
246
|
+
launch("file_1 file", searcher: searcher)
|
247
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb /src/test/file_3_test.rb", shell_mock.recall_exec
|
248
|
+
|
249
|
+
# If multiple queries are submitted but not all of them match,
|
250
|
+
# then what should we do? For now, we assume that it's only
|
251
|
+
# considered a match if each query term matches at least one
|
252
|
+
# or more files.
|
253
|
+
launch("file_1 gibberish", searcher: searcher)
|
254
|
+
assert_equal nil, shell_mock.recall_exec
|
41
255
|
end
|
42
256
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
257
|
+
def test_uses_spring__if_spring_binstub_found
|
258
|
+
searcher = MemorySearcher.new do |searcher|
|
259
|
+
searcher.mock_file do |f|
|
260
|
+
f.path "/src/test/class_1_test.rb"
|
261
|
+
f.contents <<-RB
|
262
|
+
def test_name
|
263
|
+
RB
|
264
|
+
end
|
265
|
+
|
266
|
+
searcher.mock_file do |f|
|
267
|
+
f.path "/src/bin/spring"
|
268
|
+
f.contents ""
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
|
273
|
+
launch("class_1_test.rb", env: {}, searcher: searcher)
|
274
|
+
assert_equal "cd /src && bundle exec spring testunit /src/test/class_1_test.rb", shell_mock.recall_exec
|
275
|
+
|
276
|
+
launch("class_1_test.rb", env: {"DISABLE_SPRING" => "1"}, searcher: searcher)
|
277
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/class_1_test.rb", shell_mock.recall_exec
|
46
278
|
end
|
47
279
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
280
|
+
def test__by_regex__one_match
|
281
|
+
searcher = MemorySearcher.new do |searcher|
|
282
|
+
searcher.mock_file do |f|
|
283
|
+
f.path "/src/test/file_1_test.rb"
|
284
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
285
|
+
f.contents <<-RB
|
286
|
+
regex match 1
|
287
|
+
regex match 2
|
288
|
+
regex match 3
|
289
|
+
RB
|
290
|
+
end
|
291
|
+
|
292
|
+
searcher.mock_file do |f|
|
293
|
+
f.path "/src/test/file_2_test.rb"
|
294
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
295
|
+
f.contents <<-RB
|
296
|
+
regex match 1
|
297
|
+
regex match 2
|
298
|
+
RB
|
299
|
+
end
|
300
|
+
|
301
|
+
searcher.mock_file do |f|
|
302
|
+
f.path "/src/test/file_3_test.rb"
|
303
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
304
|
+
f.contents <<-RB
|
305
|
+
regex match 1
|
306
|
+
regex match 3
|
307
|
+
RB
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
launch("regex match 1", searcher: searcher)
|
312
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_2_test.rb", shell_mock.recall_exec
|
313
|
+
|
314
|
+
launch("regex match 3", searcher: searcher)
|
315
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_3_test.rb", shell_mock.recall_exec
|
316
|
+
|
317
|
+
launch("regex match", searcher: searcher)
|
318
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_2_test.rb", shell_mock.recall_exec
|
319
|
+
|
320
|
+
launch("regex match --all", searcher: searcher)
|
321
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb /src/test/file_3_test.rb", shell_mock.recall_exec
|
52
322
|
end
|
53
323
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
324
|
+
def test__by_example__preferred_over_regex
|
325
|
+
searcher = MemorySearcher.new do |searcher|
|
326
|
+
searcher.mock_file do |f|
|
327
|
+
f.path "/src/test/file_1_test.rb"
|
328
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
329
|
+
f.contents <<-RB
|
330
|
+
def test_regex_match
|
331
|
+
RB
|
332
|
+
end
|
333
|
+
|
334
|
+
searcher.mock_file do |f|
|
335
|
+
f.path "/src/test/file_2_test.rb"
|
336
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
337
|
+
f.contents <<-RB
|
338
|
+
regex_match
|
339
|
+
RB
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
launch("regex_match", searcher: searcher)
|
344
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/regex_match/", shell_mock.recall_exec
|
57
345
|
end
|
58
346
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
347
|
+
def test__helper_methods_are_considered_regexes
|
348
|
+
searcher = MemorySearcher.new do |searcher|
|
349
|
+
searcher.mock_file do |f|
|
350
|
+
f.path "/src/test/file_1_test.rb"
|
351
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
352
|
+
f.contents <<-RB
|
353
|
+
def helper_method
|
354
|
+
RB
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
launch("helper_method", searcher: searcher)
|
359
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
62
360
|
end
|
63
361
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
362
|
+
def test__by_example__handles_regex_for_example_name
|
363
|
+
searcher = MemorySearcher.new do |searcher|
|
364
|
+
searcher.mock_file do |f|
|
365
|
+
f.path "/src/test/file_1_test.rb"
|
366
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
367
|
+
f.contents <<-RB
|
368
|
+
def test_name_1
|
369
|
+
RB
|
370
|
+
end
|
371
|
+
|
372
|
+
searcher.mock_file do |f|
|
373
|
+
f.path "/src/test/file_2_test.rb"
|
374
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
375
|
+
f.contents <<-RB
|
376
|
+
def test_name_2
|
377
|
+
RB
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
launch("test_name_1$", searcher: searcher)
|
382
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/test_name_1\\$/", shell_mock.recall_exec
|
383
|
+
|
384
|
+
launch("test_name_2|test_name_1", searcher: searcher)
|
385
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_2_test.rb --name=/test_name_2\\|test_name_1/", shell_mock.recall_exec
|
386
|
+
|
387
|
+
launch('test_name_\d', searcher: searcher)
|
388
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_2_test.rb --name=/test_name_\\\\d/", shell_mock.recall_exec
|
389
|
+
|
390
|
+
launch('test_name_\d --all', searcher: searcher)
|
391
|
+
assert_equal "cd /src && bundle exec ruby -I test -e \"ARGV.push('--name=/test_name_\\d/')\" -r /src/test/file_1_test.rb -r /src/test/file_2_test.rb", shell_mock.recall_exec
|
67
392
|
end
|
68
393
|
|
69
394
|
def test__not_found
|
70
|
-
|
395
|
+
searcher = MemorySearcher.new do |searcher|
|
396
|
+
searcher.mock_file do |f|
|
397
|
+
f.path "/src/test/file_1_test.rb"
|
398
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
399
|
+
f.contents <<-RB
|
400
|
+
some stuff
|
401
|
+
RB
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
launch("gibberish", searcher: searcher)
|
71
406
|
assert_equal nil, shell_mock.recall_exec
|
72
407
|
end
|
73
408
|
|
409
|
+
def test__different_roots
|
410
|
+
searcher = MemorySearcher.new do |searcher|
|
411
|
+
searcher.mock_file do |f|
|
412
|
+
f.path "/src/test/file_1_test.rb"
|
413
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
414
|
+
f.contents <<-RB
|
415
|
+
def test_name_1
|
416
|
+
RB
|
417
|
+
end
|
418
|
+
|
419
|
+
searcher.mock_file do |f|
|
420
|
+
f.path "/src/test/file_2_test.rb"
|
421
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
422
|
+
f.contents <<-RB
|
423
|
+
def test_name_2
|
424
|
+
RB
|
425
|
+
end
|
426
|
+
|
427
|
+
searcher.mock_file do |f|
|
428
|
+
f.path "/src/inline/gem/test/file_1_test.rb"
|
429
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
430
|
+
f.contents <<-RB
|
431
|
+
def test_name_1
|
432
|
+
RB
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
launch("test_name_1", searcher: searcher)
|
437
|
+
assert_equal "cd /src/inline/gem && bundle exec ruby -I test /src/inline/gem/test/file_1_test.rb --name=/test_name_1/", shell_mock.recall_exec
|
438
|
+
|
439
|
+
launch("test_name_1 --all", searcher: searcher)
|
440
|
+
assert_equal "cd /src && bundle exec ruby -I test -e \"ARGV.push('--name=/test_name_1/')\" -r /src/test/file_1_test.rb; cd -;\n\ncd /src/inline/gem && bundle exec ruby -I test -e \"ARGV.push('--name=/test_name_1/')\" -r /src/inline/gem/test/file_1_test.rb", shell_mock.recall_exec
|
441
|
+
|
442
|
+
launch("file --all", searcher: searcher)
|
443
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb; cd -;\n\ncd /src/inline/gem && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/inline/gem/test/file_1_test.rb", shell_mock.recall_exec
|
444
|
+
|
445
|
+
launch("file_1", searcher: searcher)
|
446
|
+
assert_equal "cd /src/inline/gem && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/inline/gem/test/file_1_test.rb", shell_mock.recall_exec
|
447
|
+
|
448
|
+
launch("file_1 --all", searcher: searcher)
|
449
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb; cd -;\n\ncd /src/inline/gem && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/inline/gem/test/file_1_test.rb", shell_mock.recall_exec
|
450
|
+
end
|
451
|
+
|
452
|
+
def test__specified_example_name__simple
|
453
|
+
searcher = MemorySearcher.new do |searcher|
|
454
|
+
searcher.mock_file do |f|
|
455
|
+
f.path "/src/test/file_1_test.rb"
|
456
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
457
|
+
f.contents <<-RB
|
458
|
+
def test_name_1
|
459
|
+
RB
|
460
|
+
end
|
461
|
+
|
462
|
+
searcher.mock_file do |f|
|
463
|
+
f.path "/src/inline/gem/test/file_2_test.rb"
|
464
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
465
|
+
f.contents <<-RB
|
466
|
+
def test_name_2
|
467
|
+
RB
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
launch("file_1 --name test_name_1", searcher: searcher)
|
472
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/test_name_1/", shell_mock.recall_exec
|
473
|
+
|
474
|
+
launch("file_2 --name test_name_2", searcher: searcher)
|
475
|
+
assert_equal "cd /src/inline/gem && bundle exec ruby -I test /src/inline/gem/test/file_2_test.rb --name=/test_name_2/", shell_mock.recall_exec
|
476
|
+
end
|
477
|
+
|
478
|
+
def test__specified_example_name__multiple_files_same_name
|
479
|
+
searcher = MemorySearcher.new do |searcher|
|
480
|
+
searcher.mock_file do |f|
|
481
|
+
f.path "/src/test/file_1_test.rb"
|
482
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
483
|
+
f.contents <<-RB
|
484
|
+
def test_name_1
|
485
|
+
RB
|
486
|
+
end
|
487
|
+
|
488
|
+
searcher.mock_file do |f|
|
489
|
+
f.path "/src/inline/gem/test/file_1_test.rb"
|
490
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
491
|
+
f.contents <<-RB
|
492
|
+
def test_name_1
|
493
|
+
RB
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
launch("file_1 --name test_name_1", searcher: searcher)
|
498
|
+
assert_equal "cd /src/inline/gem && bundle exec ruby -I test /src/inline/gem/test/file_1_test.rb --name=/test_name_1/", shell_mock.recall_exec
|
499
|
+
end
|
500
|
+
|
501
|
+
def test__by_line_number
|
502
|
+
searcher = MemorySearcher.new do |searcher|
|
503
|
+
searcher.mock_file do |f|
|
504
|
+
f.path "/src/test/file_1_test.rb"
|
505
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
506
|
+
f.contents <<-RB
|
507
|
+
class File1Test
|
508
|
+
def test_name_1
|
509
|
+
things
|
510
|
+
end
|
511
|
+
|
512
|
+
def test_name_2
|
513
|
+
things
|
514
|
+
end
|
515
|
+
end
|
516
|
+
RB
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
launch("file_1_test.rb:1", searcher: searcher)
|
521
|
+
assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
|
522
|
+
|
523
|
+
launch("file_1_test.rb:2", searcher: searcher)
|
524
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/test_name_1/", shell_mock.recall_exec
|
525
|
+
|
526
|
+
launch("file_1_test.rb:3", searcher: searcher)
|
527
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/test_name_1/", shell_mock.recall_exec
|
528
|
+
|
529
|
+
launch("file_1_test.rb:4", searcher: searcher)
|
530
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/test_name_1/", shell_mock.recall_exec
|
531
|
+
|
532
|
+
launch("file_1_test.rb:5", searcher: searcher)
|
533
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/test_name_1/", shell_mock.recall_exec
|
534
|
+
|
535
|
+
launch("file_1_test.rb:6", searcher: searcher)
|
536
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/test_name_2/", shell_mock.recall_exec
|
537
|
+
|
538
|
+
launch("file_1_test.rb:7", searcher: searcher)
|
539
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/test_name_2/", shell_mock.recall_exec
|
540
|
+
|
541
|
+
launch("file_1_test.rb:8", searcher: searcher)
|
542
|
+
assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name=/test_name_2/", shell_mock.recall_exec
|
543
|
+
end
|
544
|
+
|
545
|
+
def test__by_line_number__multiple_files
|
546
|
+
searcher = MemorySearcher.new do |searcher|
|
547
|
+
searcher.mock_file do |f|
|
548
|
+
f.path "/src/test/file_1_test.rb"
|
549
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
550
|
+
f.contents <<-RB
|
551
|
+
class File1Test
|
552
|
+
def test_name_1
|
553
|
+
RB
|
554
|
+
end
|
555
|
+
|
556
|
+
searcher.mock_file do |f|
|
557
|
+
f.path "/src/inline/gem/test/file_1_test.rb"
|
558
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
559
|
+
f.contents <<-RB
|
560
|
+
class File1Test
|
561
|
+
def test_name_1
|
562
|
+
RB
|
563
|
+
end
|
564
|
+
end
|
565
|
+
|
566
|
+
launch("file_1_test.rb:1", searcher: searcher)
|
567
|
+
assert shell_mock.recall(:warn).first.first.to_s.match(/Open an issue/)
|
568
|
+
end
|
74
569
|
end
|
75
570
|
end
|