test_launcher 2.20.0 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/test_launcher/frameworks/minitest.rb +7 -2
  3. data/lib/test_launcher/search/git.rb +2 -1
  4. data/lib/test_launcher/version.rb +1 -1
  5. data/test_launcher.gemspec +1 -1
  6. metadata +3 -60
  7. data/.gitignore +0 -16
  8. data/Gemfile +0 -8
  9. data/README.md +0 -419
  10. data/Rakefile +0 -9
  11. data/test/install +0 -3
  12. data/test/test_helper.rb +0 -65
  13. data/test/test_helpers/integration_helper.rb +0 -33
  14. data/test/test_helpers/mock.rb +0 -59
  15. data/test/test_helpers/mock_searcher.rb +0 -1
  16. data/test/test_helpers/mocks.rb +0 -77
  17. data/test/test_helpers/mocks/searcher_mock.rb +0 -84
  18. data/test/test_launcher/cli/input_parser_test.rb +0 -79
  19. data/test/test_launcher/ex_unit_integration_test.rb +0 -413
  20. data/test/test_launcher/frameworks/implementation/test_case_test.rb +0 -73
  21. data/test/test_launcher/frameworks/minitest/runner_test.rb +0 -76
  22. data/test/test_launcher/frameworks/minitest/searcher_test.rb +0 -109
  23. data/test/test_launcher/frameworks/rspec/runner_test.rb +0 -83
  24. data/test/test_launcher/frameworks/rspec/searcher_test.rb +0 -54
  25. data/test/test_launcher/generic_integration_test.rb +0 -62
  26. data/test/test_launcher/minitest_integration_test.rb +0 -683
  27. data/test/test_launcher/queries/example_name_query_test.rb +0 -221
  28. data/test/test_launcher/queries/full_regex_query_test.rb +0 -153
  29. data/test/test_launcher/queries/generic_query_test.rb +0 -23
  30. data/test/test_launcher/queries/line_number_query_test.rb +0 -107
  31. data/test/test_launcher/queries/multi_path_query_test.rb +0 -126
  32. data/test/test_launcher/queries/path_query_test.rb +0 -192
  33. data/test/test_launcher/rspec_integration_test.rb +0 -574
  34. data/test/test_launcher/rubymine_test.rb +0 -65
  35. data/test/test_launcher/search/ag_test.rb +0 -42
  36. data/test/test_launcher/search/git_test.rb +0 -41
@@ -1,221 +0,0 @@
1
- require "test_helper"
2
- require "test_helpers/mocks"
3
- require "test_launcher/queries"
4
- require "test_launcher/frameworks/minitest"
5
-
6
- module TestLauncher
7
- module Queries
8
- class ExampleNameQueryTest < TestCase
9
- include DefaultMocks
10
-
11
- def raw_searcher
12
- @raw_searcher ||= MemorySearcher.new do |searcher|
13
- searcher.mock_file do |f|
14
- f.path "file_1_test.rb"
15
- f.mtime Time.now - 3000
16
- f.contents <<-RB
17
- class SingleTest
18
- def test__one_example
19
- matches_single
20
- end
21
-
22
- def test__same_file_1
23
- end
24
-
25
- def test__same_file_2
26
- end
27
-
28
- def test__different_files
29
- end
30
- end
31
- RB
32
- end
33
-
34
- searcher.mock_file do |f|
35
- f.path "file_2_test.rb"
36
- f.mtime Time.now
37
- f.contents <<-RB
38
- class MultipleMatches1Test
39
- def test__different_files
40
- end
41
- end
42
- RB
43
- end
44
-
45
- searcher.mock_file do |f|
46
- f.path "multiple_matches_2_test.rb"
47
- f.mtime Time.now
48
- f.contents <<-RB
49
- class MultipleMatches2Test
50
- def test__1
51
- multiple_matches_2
52
- end
53
-
54
- def test__2
55
- multiple_matches_2
56
- end
57
- end
58
- RB
59
- end
60
- end
61
- end
62
-
63
- def searcher
64
- @searcher ||= Frameworks::Minitest::Searcher.new(raw_searcher)
65
- end
66
-
67
- def runner
68
- @runner ||= MockRunner.new do |m|
69
-
70
- m.impl :single_example do |test_case|
71
- "single_example #{test_case.file} #{test_case.example}"
72
- end
73
-
74
- m.impl :multiple_examples_same_file do |test_cases|
75
- "multiple_examples_same_file #{test_cases.first.file} #{test_cases.first.example}"
76
- end
77
-
78
- m.impl :multiple_files do |test_cases|
79
- "multiple_files #{test_cases.map(&:file).join(" ")}"
80
- end
81
-
82
- m.impl :multiple_examples do |test_cases|
83
- "multiple_examples #{test_cases.map(&:file).join(" ")}"
84
- end
85
- end
86
- end
87
-
88
- def test_command__example_not_found__returns_nil
89
- request = MockRequest.new(
90
- search_string: "not_found",
91
- searcher: searcher
92
- )
93
-
94
- command = ExampleNameQuery.new(request, default_command_finder).command
95
-
96
- assert_equal nil, command
97
- end
98
-
99
- def test_command__one_example_found
100
- request = MockRequest.new(
101
- search_string: "one_example",
102
- searcher: searcher,
103
- runner: runner,
104
- shell: default_shell
105
- )
106
-
107
- command = ExampleNameQuery.new(request, default_command_finder).command
108
-
109
- assert_equal "single_example file_1_test.rb one_example", command
110
- end
111
-
112
- def test_command__one_example_found__notifies
113
- request = MockRequest.new(
114
- search_string: "one_example",
115
- searcher: searcher,
116
- runner: runner,
117
- shell: default_shell
118
- )
119
-
120
- command = ExampleNameQuery.new(request, default_command_finder).command
121
-
122
- messages = [
123
- ["Found 1 example in 1 file."],
124
- ]
125
- assert_equal messages, default_shell.recall(:notify)
126
- end
127
-
128
- def test_command__multiple_examples__one_file
129
- request = MockRequest.new(
130
- search_string: "same_file",
131
- searcher: searcher,
132
- runner: runner,
133
- shell: default_shell
134
- )
135
-
136
- command = ExampleNameQuery.new(request, default_command_finder).command
137
-
138
- assert_equal "multiple_examples_same_file file_1_test.rb same_file", command
139
- end
140
-
141
- def test_command__multiple_examples__one_file__notifies
142
- request = MockRequest.new(
143
- search_string: "same_file",
144
- searcher: searcher,
145
- runner: runner,
146
- shell: default_shell
147
- )
148
-
149
- command = ExampleNameQuery.new(request, default_command_finder).command
150
-
151
- messages = [
152
- ["Found 2 examples in 1 file."],
153
- ]
154
- assert_equal messages, default_shell.recall(:notify)
155
- end
156
-
157
- def test_command__multiple_examples__multiple_files__no_all
158
- request = MockRequest.new(
159
- search_string: "different_files",
160
- searcher: searcher,
161
- runner: runner,
162
- shell: default_shell,
163
- run_all?: false
164
- )
165
-
166
- command = ExampleNameQuery.new(request, default_command_finder).command
167
-
168
- assert_equal "single_example file_2_test.rb different_files", command
169
- end
170
-
171
- def test_command__multiple_examples__multiple_files__no_all__notifies
172
- request = MockRequest.new(
173
- search_string: "different_files",
174
- searcher: searcher,
175
- runner: runner,
176
- shell: default_shell,
177
- run_all?: false
178
- )
179
-
180
- command = ExampleNameQuery.new(request, default_command_finder).command
181
-
182
- messages = [
183
- ["Found 2 examples in 2 files."],
184
- ["Running most recently edited. Run with '--all' to run all the tests."],
185
- ]
186
- assert_equal messages, default_shell.recall(:notify)
187
- end
188
-
189
- def test_command__multiple_examples__multiple_files__all
190
- request = MockRequest.new(
191
- search_string: "different_files",
192
- searcher: searcher,
193
- runner: runner,
194
- shell: default_shell,
195
- run_all?: true
196
- )
197
-
198
- command = ExampleNameQuery.new(request, default_command_finder).command
199
-
200
- assert_equal "multiple_examples file_1_test.rb file_2_test.rb", command
201
- end
202
-
203
- def test_command__multiple_examples__multiple_files__all__notifies
204
- request = MockRequest.new(
205
- search_string: "different_files",
206
- searcher: searcher,
207
- runner: runner,
208
- shell: default_shell,
209
- run_all?: true
210
- )
211
-
212
- command = ExampleNameQuery.new(request, default_command_finder).command
213
-
214
- messages = [
215
- ["Found 2 examples in 2 files."],
216
- ]
217
- assert_equal messages, default_shell.recall(:notify)
218
- end
219
- end
220
- end
221
- end
@@ -1,153 +0,0 @@
1
- require "test_helper"
2
- require "test_helpers/mocks"
3
- require "test_launcher/queries"
4
- require "test_launcher/frameworks/minitest"
5
-
6
- module TestLauncher
7
- module Queries
8
- class FullRegexQueryTest < TestCase
9
- include DefaultMocks
10
-
11
- def raw_searcher
12
- @raw_searcher ||= MemorySearcher.new do |searcher|
13
- searcher.mock_file do |f|
14
- f.path "single_test.rb"
15
- f.contents <<-RB
16
- class SingleTest
17
- def test__1
18
- matches_single
19
- end
20
- end
21
- RB
22
- end
23
-
24
- searcher.mock_file do |f|
25
- f.path "multiple_matches_1_test.rb"
26
- f.mtime Time.now - 3000
27
- f.contents <<-RB
28
- class MultipleMatches1Test
29
- def test__1
30
- multiple_matches_1
31
- end
32
-
33
- def test__2
34
- multiple_matches_1
35
- end
36
- end
37
- RB
38
- end
39
-
40
- searcher.mock_file do |f|
41
- f.path "multiple_matches_2_test.rb"
42
- f.mtime Time.now
43
- f.contents <<-RB
44
- class MultipleMatches2Test
45
- def test__1
46
- multiple_matches_2
47
- end
48
-
49
- def test__2
50
- multiple_matches_2
51
- end
52
- end
53
- RB
54
- end
55
- end
56
- end
57
-
58
- def searcher
59
- @searcher ||= Frameworks::Minitest::Searcher.new(raw_searcher)
60
- end
61
-
62
- def runner
63
- @runner ||= MockRunner.new do |m|
64
- m.impl :single_file do |test_case|
65
- case test_case.file
66
- when "single_test.rb"
67
- "single_file single_test.rb"
68
- when "multiple_matches_1_test.rb"
69
- "single_file multiple_matches_1_test.rb"
70
- when "multiple_matches_2_test.rb"
71
- "single_file multiple_matches_2_test.rb"
72
- else
73
- raise "unmocked single_file: #{test_case.file}"
74
- end
75
- end
76
-
77
- m.impl :multiple_files do |test_cases|
78
- case test_cases.map(&:file)
79
- when ["multiple_matches_1_test.rb", "multiple_matches_2_test.rb"]
80
- "multiple_files multiple_matches_1_test.rb multiple_matches_2_test.rb"
81
- else
82
- raise "unmocked multiple_files: #{test_cases}"
83
- end
84
- end
85
- end
86
- end
87
-
88
- def test_command__regex_not_found
89
- request = MockRequest.new(
90
- search_string: "not_found",
91
- searcher: searcher
92
- )
93
-
94
- command = FullRegexQuery.new(request, default_command_finder).command
95
- assert_equal nil, command
96
- end
97
-
98
- def test_command__single_match
99
- request = MockRequest.new(
100
- search_string: "single",
101
- searcher: searcher,
102
- runner: runner,
103
- shell: default_shell
104
- )
105
-
106
- command = FullRegexQuery.new(request, default_command_finder).command
107
-
108
- assert_equal "single_file single_test.rb", command
109
- end
110
-
111
- def test_command__multiple_matches_same_file
112
- request = MockRequest.new(
113
- search_string: "multiple_matches_1",
114
- searcher: searcher,
115
- runner: runner,
116
- shell: default_shell
117
- )
118
-
119
- command = FullRegexQuery.new(request, default_command_finder).command
120
-
121
- assert_equal "single_file multiple_matches_1_test.rb", command
122
- end
123
-
124
- def test_command__multiple_matches_different_files__no_all
125
- request = MockRequest.new(
126
- search_string: "multiple_matches",
127
- searcher: searcher,
128
- runner: runner,
129
- shell: default_shell,
130
- run_all?: false
131
- )
132
-
133
- command = FullRegexQuery.new(request, default_command_finder).command
134
-
135
- assert_equal "single_file multiple_matches_2_test.rb", command
136
- end
137
-
138
- def test_command__multiple_matches_different_files__all
139
- request = MockRequest.new(
140
- search_string: "multiple_matches",
141
- searcher: searcher,
142
- runner: runner,
143
- shell: default_shell,
144
- run_all?: true
145
- )
146
-
147
- command = FullRegexQuery.new(request, default_command_finder).command
148
-
149
- assert_equal "multiple_files multiple_matches_1_test.rb multiple_matches_2_test.rb", command
150
- end
151
- end
152
- end
153
- end
@@ -1,23 +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 GenericQueryTest < TestCase
8
- include DefaultMocks
9
-
10
- def test__specified_name
11
- command_finder = Mock.new(Queries::CommandFinder, specified_name: :specified_name)
12
-
13
- assert_equal :specified_name, GenericQuery.new(MockRequest.new(example_name: "name_present", rerun?: false), command_finder).command
14
- end
15
-
16
- def test__example_name
17
- command_finder = Mock.new(Queries::CommandFinder, full_search: :full_search)
18
-
19
- assert_equal :full_search, GenericQuery.new(MockRequest.new(example_name: nil, rerun?: false), command_finder).command
20
- end
21
- end
22
- end
23
- end
@@ -1,107 +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 LineNumberQueryTest < TestCase
8
- include DefaultMocks
9
-
10
- def searcher
11
- @searcher ||= MockSearcher.new do |m|
12
- m.impl :by_line do |file, line_number|
13
- case [file, line_number]
14
- when ["not_found", 1]
15
- []
16
- when ["found", 17]
17
- [{file: "found", example_name: "test_example", line_number: 14}]
18
- when ["found", 1]
19
- [{file: "found"}]
20
- when ["found", 9999]
21
- raise "invalid line number"
22
- when ["multiple", 1]
23
- raise "multiple files matched with line query"
24
- else
25
- raise "unmocked search_string: #{file}, #{line_number}"
26
- end
27
- end
28
- end
29
- end
30
-
31
- def create_mock_request(**attrs)
32
- MockRequest.new(**attrs) do |m|
33
- m.impl(:test_case) do |file:, example: nil, request:, line_number: nil|
34
- case [file, example]
35
- when ["found", nil]
36
- whole_file_test_case
37
- when ["found", "test_example"]
38
- example_name_test_case
39
- else
40
- raise "unmocked file: #{file}"
41
- end
42
- end
43
- end
44
- end
45
-
46
- def whole_file_test_case
47
- @whole_file_test_case ||= MockTestCase.new(file: "found")
48
- end
49
-
50
- def example_name_test_case
51
- @example_name_test_case ||= MockTestCase.new(file: "found", example_name: "test_example")
52
- end
53
-
54
- def test_command__file_not_found
55
- request = create_mock_request(
56
- search_string: "not_found:1",
57
- searcher: searcher
58
- )
59
-
60
- command = LineNumberQuery.new(request, default_command_finder).command
61
- assert_equal nil, command
62
- end
63
-
64
- def test_command__search_string_does_not_have_colon
65
- request = create_mock_request(
66
- search_string: "not_found",
67
- searcher: searcher
68
- )
69
-
70
- command = LineNumberQuery.new(request, default_command_finder).command
71
-
72
- assert_equal nil, command
73
- end
74
-
75
- def test_command__file_found__line_number_not_in_example
76
- request = create_mock_request(
77
- search_string: "found:1",
78
- searcher: searcher,
79
- runner: default_runner,
80
- shell: default_shell
81
- )
82
-
83
- command = LineNumberQuery.new(request, default_command_finder).command
84
-
85
- assert_equal [[whole_file_test_case]], default_runner.recall(:by_line_number)
86
-
87
- assert_equal "by_line_number_return", command
88
- end
89
-
90
-
91
- def test_command__file_found__line_number_inside_example
92
- request = create_mock_request(
93
- search_string: "found:17",
94
- searcher: searcher,
95
- runner: default_runner,
96
- shell: default_shell
97
- )
98
-
99
- command = LineNumberQuery.new(request, default_command_finder).command
100
-
101
- assert_equal [[example_name_test_case]], default_runner.recall(:by_line_number)
102
-
103
- assert_equal "by_line_number_return", command
104
- end
105
- end
106
- end
107
- end