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.
- checksums.yaml +4 -4
- data/lib/test_launcher/frameworks/minitest.rb +7 -2
- data/lib/test_launcher/search/git.rb +2 -1
- data/lib/test_launcher/version.rb +1 -1
- data/test_launcher.gemspec +1 -1
- metadata +3 -60
- data/.gitignore +0 -16
- data/Gemfile +0 -8
- data/README.md +0 -419
- data/Rakefile +0 -9
- data/test/install +0 -3
- data/test/test_helper.rb +0 -65
- data/test/test_helpers/integration_helper.rb +0 -33
- data/test/test_helpers/mock.rb +0 -59
- data/test/test_helpers/mock_searcher.rb +0 -1
- data/test/test_helpers/mocks.rb +0 -77
- data/test/test_helpers/mocks/searcher_mock.rb +0 -84
- data/test/test_launcher/cli/input_parser_test.rb +0 -79
- data/test/test_launcher/ex_unit_integration_test.rb +0 -413
- data/test/test_launcher/frameworks/implementation/test_case_test.rb +0 -73
- data/test/test_launcher/frameworks/minitest/runner_test.rb +0 -76
- data/test/test_launcher/frameworks/minitest/searcher_test.rb +0 -109
- data/test/test_launcher/frameworks/rspec/runner_test.rb +0 -83
- data/test/test_launcher/frameworks/rspec/searcher_test.rb +0 -54
- data/test/test_launcher/generic_integration_test.rb +0 -62
- data/test/test_launcher/minitest_integration_test.rb +0 -683
- data/test/test_launcher/queries/example_name_query_test.rb +0 -221
- data/test/test_launcher/queries/full_regex_query_test.rb +0 -153
- data/test/test_launcher/queries/generic_query_test.rb +0 -23
- data/test/test_launcher/queries/line_number_query_test.rb +0 -107
- data/test/test_launcher/queries/multi_path_query_test.rb +0 -126
- data/test/test_launcher/queries/path_query_test.rb +0 -192
- data/test/test_launcher/rspec_integration_test.rb +0 -574
- data/test/test_launcher/rubymine_test.rb +0 -65
- data/test/test_launcher/search/ag_test.rb +0 -42
- data/test/test_launcher/search/git_test.rb +0 -41
@@ -1,73 +0,0 @@
|
|
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__find_configru
|
44
|
-
test_case = DummyTestCase.new(file: "/path/root/test/dummy/test/thing_test.rb")
|
45
|
-
|
46
|
-
Dir.stubs(:entries).with("/path/root").returns([".", "..", "gem.gemspec", "other_stuff.rb"])
|
47
|
-
Dir.stubs(:entries).with("/path/root/test").returns([".", "..", "other_stuff.rb"])
|
48
|
-
Dir.stubs(:entries).with("/path/root/test/dummy").returns([".", "..", "config.ru"])
|
49
|
-
|
50
|
-
assert_equal "/path/root/test/dummy", test_case.app_root
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_app_root__multiple_test_dirs__prefers_deeply_nested_dirs
|
54
|
-
test_case = DummyTestCase.new(file: "/path/root/test/inline_gem/test/thing_test.rb")
|
55
|
-
|
56
|
-
Dir.stubs(:entries).with("/path/root").returns(["Gemfile"])
|
57
|
-
Dir.stubs(:entries).with("/path/root/test/inline_gem").returns(["Gemfile"])
|
58
|
-
|
59
|
-
assert_equal "/path/root/test/inline_gem", test_case.app_root
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_app_root__multiple_test_dirs__finds_no_info__defaults_outward
|
63
|
-
test_case = DummyTestCase.new(file: "/path/root/test/inline_gem/test/thing_test.rb")
|
64
|
-
|
65
|
-
Dir.stubs(:entries).with("/path/root").returns([".", ".."])
|
66
|
-
Dir.stubs(:entries).with("/path/root/test/inline_gem").returns([".", ".."])
|
67
|
-
|
68
|
-
assert_equal "/path/root", test_case.app_root
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "test_helpers/mocks"
|
3
|
-
require "test_launcher/frameworks/minitest"
|
4
|
-
|
5
|
-
module TestLauncher
|
6
|
-
module Frameworks
|
7
|
-
module Minitest
|
8
|
-
class RunnerTest < ::TestCase
|
9
|
-
|
10
|
-
class MockTestCase < Mock
|
11
|
-
mocks Minitest::TestCase
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_single_example
|
15
|
-
test_case = MockTestCase.new(
|
16
|
-
example: "example_name",
|
17
|
-
app_root: "app_root",
|
18
|
-
example_runner: "example_runner",
|
19
|
-
file: "file",
|
20
|
-
spring_enabled?: false
|
21
|
-
)
|
22
|
-
assert_equal "cd app_root && example_runner file --name='/example_name/'", Runner.new.single_example(test_case)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_multiple_examples_same_file
|
26
|
-
test_cases = [
|
27
|
-
MockTestCase.new(
|
28
|
-
example: "example_name",
|
29
|
-
app_root: "app_root",
|
30
|
-
example_runner: "example_runner",
|
31
|
-
file: "file",
|
32
|
-
spring_enabled?: false
|
33
|
-
),
|
34
|
-
MockTestCase.new(
|
35
|
-
example: "example_name",
|
36
|
-
app_root: "app_root",
|
37
|
-
example_runner: "example_runner",
|
38
|
-
file: "file"
|
39
|
-
)
|
40
|
-
]
|
41
|
-
assert_equal "cd app_root && example_runner file --name='/example_name/'", Runner.new.multiple_examples_same_file(test_cases)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_single_file
|
45
|
-
test_case = MockTestCase.new(
|
46
|
-
example: "example_name",
|
47
|
-
app_root: "app_root",
|
48
|
-
file_runner: "file_runner",
|
49
|
-
file: "file",
|
50
|
-
spring_enabled?: false
|
51
|
-
)
|
52
|
-
assert_equal "cd app_root && file_runner file", Runner.new.single_file(test_case)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_one_or_more_files
|
56
|
-
test_cases = [
|
57
|
-
MockTestCase.new(
|
58
|
-
example: "example_name",
|
59
|
-
app_root: "app_root",
|
60
|
-
file_runner: "file_runner",
|
61
|
-
file: "file_1",
|
62
|
-
spring_enabled?: false
|
63
|
-
),
|
64
|
-
MockTestCase.new(
|
65
|
-
example: "example_name",
|
66
|
-
app_root: "app_root",
|
67
|
-
file_runner: "file_runner",
|
68
|
-
file: "file_2"
|
69
|
-
)
|
70
|
-
]
|
71
|
-
assert_equal "cd app_root && file_runner file_1 file_2", Runner.new.one_or_more_files(test_cases)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "test_helpers/mocks"
|
3
|
-
require "test_launcher/search/git"
|
4
|
-
require "test_launcher/frameworks/minitest"
|
5
|
-
|
6
|
-
module TestLauncher
|
7
|
-
module Frameworks
|
8
|
-
module Minitest
|
9
|
-
class SearcherTest < ::TestCase
|
10
|
-
include DefaultMocks
|
11
|
-
|
12
|
-
class RawSearcherMock < Mock
|
13
|
-
mocks Search::Git
|
14
|
-
|
15
|
-
impl :grep do |regex, file_pattern:|
|
16
|
-
example_name_regex = "^ *def +test_.*().*" #TODO: no bueno copying this
|
17
|
-
case [regex, file_pattern]
|
18
|
-
when [example_name_regex, "test/test_launcher/single_test.rb"]
|
19
|
-
[
|
20
|
-
{file: "test/test_launcher/single_test.rb", line_number: 8, line: "def test__first"},
|
21
|
-
{file: "test/test_launcher/single_test.rb", line_number: 13, line: "def test__second"},
|
22
|
-
{file: "test/test_launcher/single_test.rb", line_number: 18, line: "def test__third"},
|
23
|
-
]
|
24
|
-
when [example_name_regex, "root_path/non_test_file"]
|
25
|
-
[]
|
26
|
-
when [example_name_regex, "root_path/multiple_1"]
|
27
|
-
[
|
28
|
-
"test/dir/1_multiple_test.rb:8: def test__first",
|
29
|
-
"test/dir/1_multiple_test.rb:13: def test__second",
|
30
|
-
]
|
31
|
-
when [example_name_regex, "root_path/multiple_2"]
|
32
|
-
[
|
33
|
-
"test/dir/2_multiple_test.rb:12: def test__first",
|
34
|
-
"test/dir/2_multiple_test.rb:30: def test__second",
|
35
|
-
]
|
36
|
-
else
|
37
|
-
raise "unmocked search: #{regex}, #{file_pattern}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
impl :find_files do |pattern|
|
42
|
-
case pattern
|
43
|
-
when "not_found_test.rb"
|
44
|
-
[]
|
45
|
-
when "single_test.rb"
|
46
|
-
["test/test_launcher/single_test.rb"]
|
47
|
-
when "non_test_file.rb"
|
48
|
-
["non_test_file.rb"]
|
49
|
-
when "multiple_test.rb"
|
50
|
-
["test/dir/1_multiple_test.rb", "test/dir/2_multiple_test.rb"]
|
51
|
-
else
|
52
|
-
raise "unmocked search: #{pattern}"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def searcher
|
58
|
-
@searcher ||= Searcher.new(RawSearcherMock.new)
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_by_line__file_not_found
|
62
|
-
assert_equal [], searcher.by_line("not_found_test.rb", 1)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_by_line__file_is_not_test_file
|
66
|
-
assert_equal [], searcher.by_line("non_test_file.rb", 1)
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_by_line__single_file_line_before_all_examples
|
70
|
-
expected_result = [{file: "test/test_launcher/single_test.rb"}]
|
71
|
-
assert_equal expected_result, searcher.by_line("single_test.rb", 1)
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_by_line__single_file_line_exact_number
|
75
|
-
expected_result = [{
|
76
|
-
file: "test/test_launcher/single_test.rb",
|
77
|
-
example_name: "test__first",
|
78
|
-
line_number: 8
|
79
|
-
}]
|
80
|
-
assert_equal expected_result, searcher.by_line("single_test.rb", 8)
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_by_line__single_file_line_after_example
|
84
|
-
expected_result = [{
|
85
|
-
file: "test/test_launcher/single_test.rb",
|
86
|
-
example_name: "test__first",
|
87
|
-
line_number: 8
|
88
|
-
}]
|
89
|
-
assert_equal expected_result, searcher.by_line("single_test.rb", 10)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_by_line__single_file_line_after_example_2
|
93
|
-
expected_result = [{
|
94
|
-
file: "test/test_launcher/single_test.rb",
|
95
|
-
example_name: "test__second",
|
96
|
-
line_number: 13
|
97
|
-
}]
|
98
|
-
assert_equal expected_result, searcher.by_line("single_test.rb", 17)
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_by_line__multiple_files__raises_error_for_now
|
102
|
-
assert_raises Searcher::MultipleByLineMatches do
|
103
|
-
searcher.by_line("multiple_test.rb", 1)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "test_helpers/mocks"
|
3
|
-
require "test_launcher/frameworks/rspec"
|
4
|
-
|
5
|
-
module TestLauncher
|
6
|
-
module Frameworks
|
7
|
-
module RSpec
|
8
|
-
class RunnerTest < ::TestCase
|
9
|
-
|
10
|
-
class MockTestCase < Mock
|
11
|
-
mocks RSpec::TestCase
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_single_example
|
15
|
-
test_case = MockTestCase.new(
|
16
|
-
example: "example_name",
|
17
|
-
app_root: "app_root",
|
18
|
-
file: "file",
|
19
|
-
runner: "bundle exec rspec"
|
20
|
-
)
|
21
|
-
assert_equal "cd app_root && bundle exec rspec file --example example_name", Runner.new.single_example(test_case)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_single_example__with_messy_name
|
25
|
-
test_case = MockTestCase.new(
|
26
|
-
example: "this is it's name :(",
|
27
|
-
app_root: "app_root",
|
28
|
-
file: "file",
|
29
|
-
runner: "bundle exec rspec"
|
30
|
-
)
|
31
|
-
assert_equal "cd app_root && bundle exec rspec file --example this\\ is\\ it\\'s\\ name\\ :\\(", Runner.new.single_example(test_case)
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
def test_multiple_examples_same_file
|
36
|
-
test_cases = [
|
37
|
-
MockTestCase.new(
|
38
|
-
example: "example_name",
|
39
|
-
app_root: "app_root",
|
40
|
-
file: "file",
|
41
|
-
runner: "bundle exec rspec"
|
42
|
-
),
|
43
|
-
MockTestCase.new(
|
44
|
-
example: "example_name",
|
45
|
-
app_root: "app_root",
|
46
|
-
file: "file",
|
47
|
-
runner: "bundle exec rspec"
|
48
|
-
)
|
49
|
-
]
|
50
|
-
assert_equal "cd app_root && bundle exec rspec file --example example_name", Runner.new.multiple_examples_same_file(test_cases)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_single_file
|
54
|
-
test_case = MockTestCase.new(
|
55
|
-
example: "example_name",
|
56
|
-
app_root: "app_root",
|
57
|
-
file: "file",
|
58
|
-
runner: "bundle exec rspec"
|
59
|
-
)
|
60
|
-
assert_equal "cd app_root && bundle exec rspec file", Runner.new.single_file(test_case)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_one_or_more_files
|
64
|
-
test_cases = [
|
65
|
-
MockTestCase.new(
|
66
|
-
example: "example_name",
|
67
|
-
app_root: "app_root",
|
68
|
-
file: "file_1",
|
69
|
-
runner: "bin/rspec"
|
70
|
-
),
|
71
|
-
MockTestCase.new(
|
72
|
-
example: "example_name",
|
73
|
-
app_root: "app_root",
|
74
|
-
file: "file_2",
|
75
|
-
runner: "bin/rspec"
|
76
|
-
)
|
77
|
-
]
|
78
|
-
assert_equal "cd app_root && bin/rspec file_1 file_2", Runner.new.one_or_more_files(test_cases)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "test_helpers/mocks"
|
3
|
-
require "test_launcher/search/git"
|
4
|
-
require "test_launcher/frameworks/rspec"
|
5
|
-
|
6
|
-
module TestLauncher
|
7
|
-
module Frameworks
|
8
|
-
module RSpec
|
9
|
-
class SearcherTest < ::TestCase
|
10
|
-
include DefaultMocks
|
11
|
-
|
12
|
-
class RawSearcherMock < Mock
|
13
|
-
mocks Search::Git
|
14
|
-
|
15
|
-
impl :find_files do |pattern|
|
16
|
-
case pattern
|
17
|
-
when "not_found_spec.rb"
|
18
|
-
[]
|
19
|
-
when "single_spec.rb"
|
20
|
-
["spec/test_launcher/single_spec.rb"]
|
21
|
-
when "non_test_file.rb"
|
22
|
-
["non_test_file.rb"]
|
23
|
-
when "multiple_spec.rb"
|
24
|
-
["spec/dir/1_multiple_spec.rb", "spec/dir/2_multiple_spec.rb"]
|
25
|
-
else
|
26
|
-
raise "unmocked search: #{pattern}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def searcher
|
32
|
-
@searcher ||= Searcher.new(RawSearcherMock.new)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_by_line__file_not_found
|
36
|
-
assert_equal [], searcher.by_line("not_found_spec.rb", 1)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_by_line__file_is_not_test_file
|
40
|
-
assert_equal [], searcher.by_line("non_test_file.rb", 1)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_by_line__file_is_found
|
44
|
-
expected_result = [{
|
45
|
-
file: "spec/test_launcher/single_spec.rb",
|
46
|
-
line_number: 8
|
47
|
-
}]
|
48
|
-
|
49
|
-
assert_equal expected_result, searcher.by_line("single_spec.rb", 8)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "test_helpers/integration_helper"
|
3
|
-
|
4
|
-
module TestLauncher
|
5
|
-
class GenericIntegrationTest < TestCase
|
6
|
-
include IntegrationHelper
|
7
|
-
|
8
|
-
def launch(query, env: {}, searcher:, shell: shell_mock, &block)
|
9
|
-
query += " --framework generic "
|
10
|
-
shell.reset
|
11
|
-
CLI.launch(query.split(" "), env, shell: shell, searcher: searcher, &block)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test__by_filename
|
15
|
-
searcher = MemorySearcher.new do |searcher|
|
16
|
-
searcher.mock_file do |f|
|
17
|
-
f.path "/src/test/file_1.rb"
|
18
|
-
f.contents ""
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
launch("file_1", searcher: searcher)
|
23
|
-
assert_equal "ruby /src/test/file_1.rb", shell_mock.recall_exec
|
24
|
-
end
|
25
|
-
|
26
|
-
def test__not_filename
|
27
|
-
searcher = MemorySearcher.new do |searcher|
|
28
|
-
searcher.mock_file do |f|
|
29
|
-
f.path "/src/test/file_1.rb"
|
30
|
-
f.contents "runme"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
launch("runme", searcher: searcher)
|
35
|
-
assert_equal nil, shell_mock.recall_exec
|
36
|
-
|
37
|
-
launch("file:1", searcher: searcher)
|
38
|
-
assert_equal nil, shell_mock.recall_exec
|
39
|
-
|
40
|
-
launch("/src/test/file_1.rb:1", searcher: searcher)
|
41
|
-
assert_equal nil, shell_mock.recall_exec
|
42
|
-
end
|
43
|
-
|
44
|
-
def test__cli_yields_block
|
45
|
-
# TODO: don't test this here
|
46
|
-
searcher = MemorySearcher.new do |searcher|
|
47
|
-
searcher.mock_file do |f|
|
48
|
-
f.path "/src/test/file_1.rb"
|
49
|
-
f.contents "runme"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
@yielded = false
|
53
|
-
launch("/src/test/file_1.rb", searcher: searcher) do |command|
|
54
|
-
@yielded = true
|
55
|
-
assert_equal "ruby /src/test/file_1.rb", command
|
56
|
-
"new_command"
|
57
|
-
end
|
58
|
-
assert @yielded
|
59
|
-
assert_equal "new_command", shell_mock.recall_exec
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|