test_launcher 2.20.0 → 2.21.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/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
data/Rakefile
DELETED
data/test/install
DELETED
data/test/test_helper.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.split(File.dirname(__FILE__))[0], 'lib'))
|
2
|
-
require "minitest/autorun"
|
3
|
-
require "mocha/mini_test"
|
4
|
-
require "pry"
|
5
|
-
|
6
|
-
require "test_launcher"
|
7
|
-
require "test_launcher/shell/runner"
|
8
|
-
|
9
|
-
class TestLauncher::Shell::Runner
|
10
|
-
def exec(cmd)
|
11
|
-
raise "execed twice" if defined?(@exec)
|
12
|
-
@@exec = cmd
|
13
|
-
end
|
14
|
-
|
15
|
-
def notify(*)
|
16
|
-
# silence logs during test
|
17
|
-
end
|
18
|
-
|
19
|
-
def warn(*)
|
20
|
-
# silence logs during test
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.recall_exec
|
24
|
-
return unless @@exec
|
25
|
-
@@exec.to_s
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.reset
|
29
|
-
@@exec = nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class TestCase < Minitest::Test
|
34
|
-
|
35
|
-
def setup
|
36
|
-
TestLauncher::Shell::Runner.reset
|
37
|
-
end
|
38
|
-
|
39
|
-
class DummyShell
|
40
|
-
|
41
|
-
def method_missing(method, *args)
|
42
|
-
instance_variable_set(:"@#{method}", [args])
|
43
|
-
|
44
|
-
self.class.send(:define_method, method) do |*a|
|
45
|
-
if ! instance_variable_get(:"@#{method}")
|
46
|
-
instance_variable_set(:"@#{method}", [a])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def recall(method)
|
52
|
-
instance_variable_get(:"@#{method}") || []
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def system_path(relative_dir)
|
59
|
-
File.join(Dir.pwd, relative_dir)
|
60
|
-
end
|
61
|
-
|
62
|
-
def dummy_shell
|
63
|
-
@dummy_shell ||= DummyShell.new
|
64
|
-
end
|
65
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require "test_launcher/search/git"
|
2
|
-
require "test_launcher/shell/runner"
|
3
|
-
|
4
|
-
require "test_launcher/cli"
|
5
|
-
require "test_helpers/mocks"
|
6
|
-
require "test_launcher/shell/history_runner"
|
7
|
-
|
8
|
-
module TestLauncher
|
9
|
-
module IntegrationHelper
|
10
|
-
include DefaultMocks
|
11
|
-
|
12
|
-
class IntegrationShell < MockShell
|
13
|
-
def exec(string)
|
14
|
-
raise "Cannot exec twice!" if @exec
|
15
|
-
@exec = string
|
16
|
-
end
|
17
|
-
|
18
|
-
def recall_exec
|
19
|
-
@exec
|
20
|
-
end
|
21
|
-
|
22
|
-
def reset
|
23
|
-
@exec = nil
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def shell_mock
|
30
|
-
@shell_mock ||= IntegrationShell.new
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/test/test_helpers/mock.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
class Mock
|
2
|
-
UnmockedMethodError = Class.new(StandardError)
|
3
|
-
MockingUnimplementedMethodError = Class.new(StandardError)
|
4
|
-
|
5
|
-
def self.impl(method_name)
|
6
|
-
define_method method_name do |*args|
|
7
|
-
record_call(method_name, args)
|
8
|
-
yield(*args) if block_given?
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.mocks(klass)
|
13
|
-
define_method(:mocked_klass) do
|
14
|
-
klass
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def impl(method_name)
|
19
|
-
define_singleton_method method_name do |*args|
|
20
|
-
record_call(method_name, args)
|
21
|
-
yield(*args) if block_given?
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def initialize(*args)
|
26
|
-
@attrs = args.pop || {}
|
27
|
-
@klass = args.first if args.any?
|
28
|
-
@calls = {}
|
29
|
-
yield(self) if block_given?
|
30
|
-
raise "Mocked class not specified" unless mocked_klass
|
31
|
-
end
|
32
|
-
|
33
|
-
def recall(method_name)
|
34
|
-
@calls[method_name] || []
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def method_missing(method_name, *args)
|
40
|
-
record_call(method_name, args)
|
41
|
-
|
42
|
-
if @attrs.key?(method_name)
|
43
|
-
@attrs[method_name]
|
44
|
-
else
|
45
|
-
raise UnmockedMethodError, "#{method_name} is not mocked"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def record_call(method_name, args)
|
50
|
-
if !mocked_klass.method_defined?(method_name)
|
51
|
-
raise MockingUnimplementedMethodError, "#{mocked_klass} does not implement #{method_name}"
|
52
|
-
end
|
53
|
-
(@calls[method_name] ||= []) << args
|
54
|
-
end
|
55
|
-
|
56
|
-
def mocked_klass
|
57
|
-
@klass
|
58
|
-
end
|
59
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
require "test_helpers/mock"
|
data/test/test_helpers/mocks.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require "test_helpers/mock"
|
2
|
-
require "test_helpers/mocks/searcher_mock"
|
3
|
-
|
4
|
-
module TestLauncher
|
5
|
-
|
6
|
-
require "test_launcher/frameworks/base"
|
7
|
-
class MockSearcher < Mock
|
8
|
-
mocks Frameworks::Base::Searcher
|
9
|
-
end
|
10
|
-
|
11
|
-
require "test_launcher/shell/runner"
|
12
|
-
class MockShell < Mock
|
13
|
-
mocks Shell::Runner
|
14
|
-
|
15
|
-
impl :warn
|
16
|
-
impl :notify
|
17
|
-
impl :puts
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
require "test_launcher/queries"
|
22
|
-
class MockCommandFinder < Mock
|
23
|
-
mocks Queries::CommandFinder
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
require "test_launcher/cli/request"
|
28
|
-
class MockRequest < Mock
|
29
|
-
mocks CLI::Request
|
30
|
-
|
31
|
-
impl :test_case do |*args|
|
32
|
-
Frameworks::Implementation::TestCase.new(*args)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
require "test_launcher/frameworks/base"
|
37
|
-
class MockRunner < Mock
|
38
|
-
mocks Frameworks::Base::Runner
|
39
|
-
|
40
|
-
impl(:single_file) { "single_file_return" }
|
41
|
-
impl(:multiple_files) { "multiple_files_return" }
|
42
|
-
impl(:single_example) { "single_example_return" }
|
43
|
-
impl(:by_line_number) { "by_line_number_return" }
|
44
|
-
end
|
45
|
-
|
46
|
-
require "test_launcher/frameworks/base"
|
47
|
-
class MockTestCase < Mock
|
48
|
-
mocks Frameworks::Base::TestCase
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
module DefaultMocks
|
53
|
-
def default_searcher
|
54
|
-
@default_searcher ||= MockSearcher.new
|
55
|
-
end
|
56
|
-
|
57
|
-
def default_shell
|
58
|
-
@default_shell ||= MockShell.new
|
59
|
-
end
|
60
|
-
|
61
|
-
def default_command_finder
|
62
|
-
@default_command_finder ||= MockCommandFinder.new
|
63
|
-
end
|
64
|
-
|
65
|
-
def default_request
|
66
|
-
@default_runner ||= MockRequest.new
|
67
|
-
end
|
68
|
-
|
69
|
-
def default_runner
|
70
|
-
@default_runner ||= MockRunner.new
|
71
|
-
end
|
72
|
-
|
73
|
-
def default_test_case
|
74
|
-
@default_test_case ||= MockTestCase.new
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require "test_helpers/mock"
|
2
|
-
require "test_launcher/search/git"
|
3
|
-
|
4
|
-
module TestLauncher
|
5
|
-
class MemorySearcher < Mock
|
6
|
-
class FileBuilder
|
7
|
-
def path(path)
|
8
|
-
@path = path
|
9
|
-
end
|
10
|
-
|
11
|
-
def contents(string)
|
12
|
-
@lines = string.split("\n")
|
13
|
-
end
|
14
|
-
|
15
|
-
def mtime(time) # TODO: this doesn't work yet!
|
16
|
-
@mtime = time
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_file_mock
|
20
|
-
FileMock.new(@path, @lines, @mtime)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class FileMock < Struct.new(:path, :lines, :mtime)
|
25
|
-
attr_reader :path, :lines
|
26
|
-
def initialize(path, lines, mtime)
|
27
|
-
@path = path
|
28
|
-
@lines = lines
|
29
|
-
File.stubs(:mtime).with(path).returns(mtime)
|
30
|
-
File.stubs(:exist?).returns(false)
|
31
|
-
File.stubs(:exist?).with(path).returns(true)
|
32
|
-
end
|
33
|
-
|
34
|
-
def grep(regex)
|
35
|
-
lines
|
36
|
-
.each_with_index
|
37
|
-
.map {|line_text, line_number|
|
38
|
-
{
|
39
|
-
file: path,
|
40
|
-
line: line_text.strip,
|
41
|
-
line_number: line_number + 1
|
42
|
-
}
|
43
|
-
}
|
44
|
-
.select {|result|
|
45
|
-
result[:line].match(regex)
|
46
|
-
}
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
mocks Search::Git
|
51
|
-
|
52
|
-
def initialize
|
53
|
-
yield(self)
|
54
|
-
end
|
55
|
-
|
56
|
-
def find_files(glob_pattern)
|
57
|
-
file_mocks_for_pattern(glob_pattern).map(&:path)
|
58
|
-
end
|
59
|
-
|
60
|
-
def grep(regex, file_pattern: '*')
|
61
|
-
file_mocks_for_pattern(file_pattern)
|
62
|
-
.flat_map { |file|
|
63
|
-
file.grep(regex)
|
64
|
-
}
|
65
|
-
end
|
66
|
-
|
67
|
-
def mock_file
|
68
|
-
file_builder = FileBuilder.new
|
69
|
-
yield(file_builder)
|
70
|
-
file_mocks << file_builder.to_file_mock
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def file_mocks_for_pattern(glob_pattern)
|
76
|
-
regex = glob_pattern.gsub("*", ".*")
|
77
|
-
file_mocks.select {|fm| fm.path.match(regex)}
|
78
|
-
end
|
79
|
-
|
80
|
-
def file_mocks
|
81
|
-
@file_mocks ||= []
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "test_launcher/cli/input_parser"
|
3
|
-
|
4
|
-
module TestLauncher
|
5
|
-
module CLI
|
6
|
-
class InputParserTest < TestCase
|
7
|
-
|
8
|
-
def test_request__defaults
|
9
|
-
options = parse("a_string", {})
|
10
|
-
|
11
|
-
assert_equal "a_string", options.search_string
|
12
|
-
assert_equal false, options.run_all
|
13
|
-
assert_equal false, options.disable_spring
|
14
|
-
assert_equal nil, options.example_name
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_request__all
|
18
|
-
options = parse("a_string --all", {})
|
19
|
-
|
20
|
-
assert_equal "a_string", options.search_string
|
21
|
-
assert_equal true, options.run_all
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_request__rerun
|
25
|
-
options = parse("--rerun", {})
|
26
|
-
|
27
|
-
assert_equal true, options.rerun
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def test_request__disable_spring
|
32
|
-
options = parse("a_string", {"DISABLE_SPRING" => "1"})
|
33
|
-
|
34
|
-
assert_equal "a_string", options.search_string
|
35
|
-
assert_equal true, options.disable_spring
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_request__example_name
|
39
|
-
options = parse("path/to/file_test.rb --name example_name", {})
|
40
|
-
|
41
|
-
assert_equal "path/to/file_test.rb", options.search_string
|
42
|
-
assert_equal "example_name", options.example_name
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_request__example_name__regex
|
46
|
-
options = parse("path/to/file_test.rb --name /example_name/", {})
|
47
|
-
|
48
|
-
assert_equal "path/to/file_test.rb", options.search_string
|
49
|
-
assert_equal "/example_name/", options.example_name
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_request__example_name__with_equal_sign
|
53
|
-
options = parse("path/to/file_test.rb --name=/example_name/", {})
|
54
|
-
|
55
|
-
assert_equal "path/to/file_test.rb", options.search_string
|
56
|
-
assert_equal "/example_name/", options.example_name
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_request__example_name__short_option
|
60
|
-
options = parse("path/to/file_test.rb -n /example_name/", {})
|
61
|
-
|
62
|
-
assert_equal "path/to/file_test.rb", options.search_string
|
63
|
-
assert_equal "/example_name/", options.example_name
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_joins_spaces
|
67
|
-
options = parse("query with spaces", {})
|
68
|
-
|
69
|
-
assert_equal "query with spaces", options.search_string
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
def parse(input, env)
|
75
|
-
InputParser.new(input.split(" "), env).parsed_options(shell: dummy_shell, searcher: nil)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,413 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "test_helpers/integration_helper"
|
3
|
-
|
4
|
-
module TestLauncher
|
5
|
-
class ExUnitIntegrationTest < TestCase
|
6
|
-
include IntegrationHelper
|
7
|
-
|
8
|
-
def launch(query, env: {}, searcher:, shell: shell_mock)
|
9
|
-
query += " --framework ex_unit "
|
10
|
-
shell.reset
|
11
|
-
CLI.launch(query.split(" "), env, shell: shell, searcher: searcher)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test__by_example__single_method
|
15
|
-
searcher = MemorySearcher.new do |searcher|
|
16
|
-
searcher.mock_file do |f|
|
17
|
-
f.path "/src/test/file_1_test.exs"
|
18
|
-
f.contents <<-RB
|
19
|
-
defmodule MyApp.File1Test do
|
20
|
-
test "test_name" do
|
21
|
-
end
|
22
|
-
end
|
23
|
-
RB
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
launch("test_name", searcher: searcher)
|
28
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs:2", shell_mock.recall_exec
|
29
|
-
|
30
|
-
launch("n", searcher: searcher)
|
31
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs:2", 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/file_1_test.exs"
|
38
|
-
f.contents <<-RB
|
39
|
-
defmodule File1Test do
|
40
|
-
test "test_name_1" do
|
41
|
-
end
|
42
|
-
|
43
|
-
test "test_name_2" do
|
44
|
-
end
|
45
|
-
end
|
46
|
-
RB
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
launch("name_", searcher: searcher)
|
51
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", shell_mock.recall_exec
|
52
|
-
end
|
53
|
-
|
54
|
-
def test__by_example__multiple_methods__different_files
|
55
|
-
searcher = MemorySearcher.new do |searcher|
|
56
|
-
searcher.mock_file do |f|
|
57
|
-
f.path "/src/test/file_1_test.exs"
|
58
|
-
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
59
|
-
f.contents <<-RB
|
60
|
-
test "test_name_1" do
|
61
|
-
test "test_name_2" do
|
62
|
-
RB
|
63
|
-
end
|
64
|
-
|
65
|
-
searcher.mock_file do |f|
|
66
|
-
f.path "/src/test/file_2_test.exs"
|
67
|
-
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
68
|
-
f.contents <<-RB
|
69
|
-
test "test_name_1" do
|
70
|
-
test "test_name_2" do
|
71
|
-
RB
|
72
|
-
end
|
73
|
-
|
74
|
-
searcher.mock_file do |f|
|
75
|
-
f.path "/src/test/file_3_test.exs"
|
76
|
-
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
77
|
-
f.contents <<-RB
|
78
|
-
test "test_name_2" do
|
79
|
-
RB
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
launch("name_1", searcher: searcher)
|
84
|
-
assert_equal "cd /src && mix test /src/test/file_2_test.exs:1", shell_mock.recall_exec
|
85
|
-
|
86
|
-
launch("name_2", searcher: searcher)
|
87
|
-
assert_equal "cd /src && mix test /src/test/file_2_test.exs:2", shell_mock.recall_exec
|
88
|
-
|
89
|
-
launch("name_1 --all", searcher: searcher)
|
90
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs /src/test/file_2_test.exs", shell_mock.recall_exec
|
91
|
-
|
92
|
-
launch("name_2 --all", searcher: searcher)
|
93
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs /src/test/file_2_test.exs /src/test/file_3_test.exs", shell_mock.recall_exec
|
94
|
-
end
|
95
|
-
|
96
|
-
def test__by_filename
|
97
|
-
searcher = MemorySearcher.new do |searcher|
|
98
|
-
searcher.mock_file do |f|
|
99
|
-
f.path "/src/test/file_1_test.exs"
|
100
|
-
f.contents ""
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
launch("file_1", searcher: searcher)
|
105
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", shell_mock.recall_exec
|
106
|
-
|
107
|
-
launch("file_1_test.exs", searcher: searcher)
|
108
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", shell_mock.recall_exec
|
109
|
-
|
110
|
-
launch("/file_1", searcher: searcher)
|
111
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", shell_mock.recall_exec
|
112
|
-
|
113
|
-
launch(".exs", searcher: searcher)
|
114
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", shell_mock.recall_exec
|
115
|
-
|
116
|
-
launch("/src/test/file_1", searcher: searcher)
|
117
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", shell_mock.recall_exec
|
118
|
-
|
119
|
-
launch("src/test/file_1", searcher: searcher)
|
120
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", shell_mock.recall_exec
|
121
|
-
|
122
|
-
launch("st/file_1", searcher: searcher)
|
123
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", shell_mock.recall_exec
|
124
|
-
end
|
125
|
-
|
126
|
-
def test__by_filename__multiple_files_found
|
127
|
-
searcher = MemorySearcher.new do |searcher|
|
128
|
-
searcher.mock_file do |f|
|
129
|
-
f.path "/src/test/file_1_test.exs"
|
130
|
-
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
131
|
-
end
|
132
|
-
|
133
|
-
searcher.mock_file do |f|
|
134
|
-
f.path "/src/test/file_2_test.exs"
|
135
|
-
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
136
|
-
end
|
137
|
-
|
138
|
-
searcher.mock_file do |f|
|
139
|
-
f.path "/src/test/file_3_test.exs"
|
140
|
-
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
141
|
-
end
|
142
|
-
|
143
|
-
searcher.mock_file do |f|
|
144
|
-
f.path "/src/test/other_test.exs"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
launch("file_1", searcher: searcher)
|
149
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", shell_mock.recall_exec
|
150
|
-
|
151
|
-
launch("file", searcher: searcher)
|
152
|
-
assert_equal "cd /src && mix test /src/test/file_2_test.exs", shell_mock.recall_exec
|
153
|
-
|
154
|
-
launch("file --all", searcher: searcher)
|
155
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs /src/test/file_2_test.exs /src/test/file_3_test.exs", shell_mock.recall_exec
|
156
|
-
end
|
157
|
-
|
158
|
-
def test__by_filename__preferred_over_regex_and_test_name_matches
|
159
|
-
searcher = MemorySearcher.new do |searcher|
|
160
|
-
searcher.mock_file do |f|
|
161
|
-
f.path "/src/test/file_1_test.exs"
|
162
|
-
f.contents <<-RB
|
163
|
-
test "test_name" do
|
164
|
-
RB
|
165
|
-
end
|
166
|
-
|
167
|
-
searcher.mock_file do |f|
|
168
|
-
f.path "/src/test/name_test.exs"
|
169
|
-
end
|
170
|
-
|
171
|
-
searcher.mock_file do |f|
|
172
|
-
f.path "/src/test/other_test.exs"
|
173
|
-
f.contents <<-RB
|
174
|
-
regex will match name_test
|
175
|
-
RB
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
launch("name_test", searcher: searcher)
|
180
|
-
assert_equal "cd /src && mix test /src/test/name_test.exs", shell_mock.recall_exec
|
181
|
-
end
|
182
|
-
|
183
|
-
def test__by_multiple_filenames__multiple_files_found
|
184
|
-
searcher = MemorySearcher.new do |searcher|
|
185
|
-
searcher.mock_file do |f|
|
186
|
-
f.path "/src/test/file_1_test.exs"
|
187
|
-
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
188
|
-
f.contents ""
|
189
|
-
end
|
190
|
-
|
191
|
-
searcher.mock_file do |f|
|
192
|
-
f.path "/src/test/file_2_test.exs"
|
193
|
-
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
194
|
-
f.contents ""
|
195
|
-
end
|
196
|
-
|
197
|
-
searcher.mock_file do |f|
|
198
|
-
f.path "/src/test/file_3_test.exs"
|
199
|
-
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
200
|
-
f.contents ""
|
201
|
-
end
|
202
|
-
|
203
|
-
searcher.mock_file do |f|
|
204
|
-
f.path "/src/test/other_test.exs"
|
205
|
-
f.contents ""
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
launch("file_1 file_2", searcher: searcher)
|
210
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs /src/test/file_2_test.exs", shell_mock.recall_exec
|
211
|
-
|
212
|
-
launch("file_1 file", searcher: searcher)
|
213
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs /src/test/file_2_test.exs /src/test/file_3_test.exs", shell_mock.recall_exec
|
214
|
-
|
215
|
-
# If multiple queries are submitted but not all of them match,
|
216
|
-
# then what should we do? For now, we assume that it's only
|
217
|
-
# considered a match if each query term matches at least one
|
218
|
-
# or more files.
|
219
|
-
launch("file_1 gibberish", searcher: searcher)
|
220
|
-
assert_equal nil, shell_mock.recall_exec
|
221
|
-
end
|
222
|
-
|
223
|
-
def test__by_regex__one_match
|
224
|
-
searcher = MemorySearcher.new do |searcher|
|
225
|
-
searcher.mock_file do |f|
|
226
|
-
f.path "/src/test/file_1_test.exs"
|
227
|
-
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
228
|
-
f.contents <<-RB
|
229
|
-
regex match 1
|
230
|
-
regex match 2
|
231
|
-
regex match 3
|
232
|
-
RB
|
233
|
-
end
|
234
|
-
|
235
|
-
searcher.mock_file do |f|
|
236
|
-
f.path "/src/test/file_2_test.exs"
|
237
|
-
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
238
|
-
f.contents <<-RB
|
239
|
-
regex match 1
|
240
|
-
regex match 2
|
241
|
-
RB
|
242
|
-
end
|
243
|
-
|
244
|
-
searcher.mock_file do |f|
|
245
|
-
f.path "/src/test/file_3_test.exs"
|
246
|
-
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
247
|
-
f.contents <<-RB
|
248
|
-
regex match 1
|
249
|
-
regex match 3
|
250
|
-
RB
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
launch("regex match 1", searcher: searcher)
|
255
|
-
assert_equal "cd /src && mix test /src/test/file_2_test.exs", shell_mock.recall_exec
|
256
|
-
|
257
|
-
launch("regex match 3", searcher: searcher)
|
258
|
-
assert_equal "cd /src && mix test /src/test/file_3_test.exs", shell_mock.recall_exec
|
259
|
-
|
260
|
-
launch("regex match", searcher: searcher)
|
261
|
-
assert_equal "cd /src && mix test /src/test/file_2_test.exs", shell_mock.recall_exec
|
262
|
-
|
263
|
-
launch("regex match --all", searcher: searcher)
|
264
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs /src/test/file_2_test.exs /src/test/file_3_test.exs", shell_mock.recall_exec
|
265
|
-
end
|
266
|
-
|
267
|
-
def test__by_example__handles_regex_for_example_name
|
268
|
-
searcher = MemorySearcher.new do |searcher|
|
269
|
-
searcher.mock_file do |f|
|
270
|
-
f.path "/src/test/file_1_test.exs"
|
271
|
-
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
272
|
-
f.contents <<-RB
|
273
|
-
test "test_name_1" do
|
274
|
-
RB
|
275
|
-
end
|
276
|
-
|
277
|
-
searcher.mock_file do |f|
|
278
|
-
f.path "/src/test/file_2_test.exs"
|
279
|
-
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
280
|
-
f.contents <<-RB
|
281
|
-
test "test_name_2" do
|
282
|
-
RB
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
launch("test_name_1x?", searcher: searcher)
|
287
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs:1", shell_mock.recall_exec
|
288
|
-
|
289
|
-
launch("test_name_2|test_name_1", searcher: searcher)
|
290
|
-
assert_equal "cd /src && mix test /src/test/file_2_test.exs:1", shell_mock.recall_exec
|
291
|
-
|
292
|
-
launch('test_name_\d', searcher: searcher)
|
293
|
-
assert_equal "cd /src && mix test /src/test/file_2_test.exs:1", shell_mock.recall_exec
|
294
|
-
|
295
|
-
launch('test_name_\d --all', searcher: searcher)
|
296
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs /src/test/file_2_test.exs", shell_mock.recall_exec
|
297
|
-
end
|
298
|
-
|
299
|
-
def test__not_found
|
300
|
-
searcher = MemorySearcher.new do |searcher|
|
301
|
-
searcher.mock_file do |f|
|
302
|
-
f.path "/src/test/file_1_test.exs"
|
303
|
-
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
304
|
-
f.contents <<-RB
|
305
|
-
some stuff
|
306
|
-
RB
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
launch("gibberish", searcher: searcher)
|
311
|
-
assert_equal nil, shell_mock.recall_exec
|
312
|
-
end
|
313
|
-
|
314
|
-
def test__different_roots
|
315
|
-
searcher = MemorySearcher.new do |searcher|
|
316
|
-
searcher.mock_file do |f|
|
317
|
-
f.path "/src/test/file_1_test.exs"
|
318
|
-
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
319
|
-
f.contents <<-RB
|
320
|
-
test "test_name_1" do
|
321
|
-
RB
|
322
|
-
end
|
323
|
-
|
324
|
-
searcher.mock_file do |f|
|
325
|
-
f.path "/src/test/file_2_test.exs"
|
326
|
-
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
327
|
-
f.contents <<-RB
|
328
|
-
test "test_name_2" do
|
329
|
-
RB
|
330
|
-
end
|
331
|
-
|
332
|
-
searcher.mock_file do |f|
|
333
|
-
f.path "/src/inline/project/test/file_1_test.exs"
|
334
|
-
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
335
|
-
f.contents <<-RB
|
336
|
-
test "test_name_1" do
|
337
|
-
RB
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
launch("test_name_1", searcher: searcher)
|
342
|
-
assert_equal "cd /src/inline/project && mix test /src/inline/project/test/file_1_test.exs:1", shell_mock.recall_exec
|
343
|
-
|
344
|
-
launch("test_name_1 --all", searcher: searcher)
|
345
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs; cd -;\n\ncd /src/inline/project && mix test /src/inline/project/test/file_1_test.exs", shell_mock.recall_exec
|
346
|
-
|
347
|
-
launch("file --all", searcher: searcher)
|
348
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs /src/test/file_2_test.exs; cd -;\n\ncd /src/inline/project && mix test /src/inline/project/test/file_1_test.exs", shell_mock.recall_exec
|
349
|
-
|
350
|
-
launch("file_1", searcher: searcher)
|
351
|
-
assert_equal "cd /src/inline/project && mix test /src/inline/project/test/file_1_test.exs", shell_mock.recall_exec
|
352
|
-
|
353
|
-
launch("file_1 --all", searcher: searcher)
|
354
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs; cd -;\n\ncd /src/inline/project && mix test /src/inline/project/test/file_1_test.exs", shell_mock.recall_exec
|
355
|
-
end
|
356
|
-
|
357
|
-
def test__by_line_number__just_passes_through_to_ex_unit
|
358
|
-
searcher = MemorySearcher.new do |searcher|
|
359
|
-
searcher.mock_file do |f|
|
360
|
-
f.path "/src/test/file_1_test.exs"
|
361
|
-
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
362
|
-
f.contents ""
|
363
|
-
end
|
364
|
-
end
|
365
|
-
|
366
|
-
launch("file_1_test.exs:1", searcher: searcher)
|
367
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs:1", shell_mock.recall_exec
|
368
|
-
|
369
|
-
launch("file_1_test.exs:273", searcher: searcher)
|
370
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs:273", shell_mock.recall_exec
|
371
|
-
end
|
372
|
-
|
373
|
-
def test__by_line_number__multiple_files
|
374
|
-
searcher = MemorySearcher.new do |searcher|
|
375
|
-
searcher.mock_file do |f|
|
376
|
-
f.path "/src/test/file_1_test.exs"
|
377
|
-
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
378
|
-
f.contents ""
|
379
|
-
end
|
380
|
-
|
381
|
-
searcher.mock_file do |f|
|
382
|
-
f.path "/src/inline/project/test/file_1_test.exs"
|
383
|
-
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
384
|
-
f.contents ""
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
launch("file_1_test.exs:1", searcher: searcher)
|
389
|
-
assert_equal "cd /src/inline/project && mix test /src/inline/project/test/file_1_test.exs:1", shell_mock.recall_exec
|
390
|
-
end
|
391
|
-
|
392
|
-
def test__rerun
|
393
|
-
searcher = MemorySearcher.new do |searcher|
|
394
|
-
searcher.mock_file do |f|
|
395
|
-
f.path "/src/test/file_1_test.exs"
|
396
|
-
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
397
|
-
end
|
398
|
-
searcher.mock_file do |f|
|
399
|
-
f.path "/src/test/file_2_test.exs"
|
400
|
-
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
history_shell = Shell::HistoryRunner.new(shell: shell_mock, history_path: File.expand_path(File.join(__dir__, '../../tmp/test_history.log')))
|
405
|
-
|
406
|
-
launch("file_1_test.exs", searcher: searcher, shell: history_shell)
|
407
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", history_shell.recall_exec
|
408
|
-
|
409
|
-
launch("--rerun", searcher: searcher, shell: history_shell)
|
410
|
-
assert_equal "cd /src && mix test /src/test/file_1_test.exs", history_shell.recall_exec
|
411
|
-
end
|
412
|
-
end
|
413
|
-
end
|