test_launcher 2.21.0 → 2.26.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 +5 -5
- data/lib/test_launcher/frameworks/implementation/test_case.rb +2 -4
- data/lib/test_launcher/frameworks/minitest.rb +31 -16
- data/lib/test_launcher/rubymine.rb +2 -40
- data/lib/test_launcher/rubymine/launcher.rb +18 -2
- data/lib/test_launcher/rubymine/parser.rb +51 -0
- data/lib/test_launcher/shell/runner.rb +0 -1
- data/lib/test_launcher/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 969bdf386bd70aad1f3fe5c3a5fdfe4d84f5563830e76fe89df3e26aa8a17ec8
|
4
|
+
data.tar.gz: 6153978e2039b70eff76093d6fd817b90b0c49ff5fdae8b43e686696e756da45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7c8a07385383100bd867642861011c51967e8127069baa83a486af9776350b09c9f4344eec3a36f7bf7fcbdb9effaa3cb1b045e58384e6a375a5dfd8d060a54
|
7
|
+
data.tar.gz: '0139155f5ac50725ca3ac6cba826c1917d9331f9c059dc8b4736668e408bf6a6a56bac67639bf6b6656abbba5d95c6aa3b037c4edc4ad6541f9b8fcc166cd86b'
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
1
|
module TestLauncher
|
4
2
|
module Frameworks
|
5
3
|
module Implementation
|
@@ -24,7 +22,7 @@ module TestLauncher
|
|
24
22
|
def mtime
|
25
23
|
@mtime ||= File.mtime(file)
|
26
24
|
end
|
27
|
-
|
25
|
+
|
28
26
|
def relative_file
|
29
27
|
file.sub(/^#{File.join(app_root, '/')}/, '')
|
30
28
|
end
|
@@ -56,7 +54,7 @@ module TestLauncher
|
|
56
54
|
end
|
57
55
|
|
58
56
|
def exploded_path
|
59
|
-
|
57
|
+
file.split("/")
|
60
58
|
end
|
61
59
|
end
|
62
60
|
end
|
@@ -45,9 +45,16 @@ module TestLauncher
|
|
45
45
|
.min_by {|r| line_number - r[:line_number]}
|
46
46
|
|
47
47
|
if best_result
|
48
|
+
example_name =
|
49
|
+
if match = best_result[:line].match(/def\s+(?<name>test_[\w\?]+)/)
|
50
|
+
match[:name]
|
51
|
+
elsif match = best_result[:line].match(/test\s+['"](?<name>.*)['"]\s+do/)
|
52
|
+
"test_#{match[:name]}"
|
53
|
+
end
|
54
|
+
|
48
55
|
[{
|
49
56
|
file: best_result[:file],
|
50
|
-
example_name:
|
57
|
+
example_name: example_name,
|
51
58
|
line_number: best_result[:line_number]
|
52
59
|
}]
|
53
60
|
else
|
@@ -101,17 +108,22 @@ Open an issue on https://github.com/petekinnecom/test_launcher if this is someth
|
|
101
108
|
|
102
109
|
def single_example(test_case, name: test_case.example, exact_match: false)
|
103
110
|
name_arg =
|
104
|
-
if exact_match
|
111
|
+
if exact_match && name.match(/[^\w]/)
|
112
|
+
Shellwords.escape(name)
|
113
|
+
elsif !exact_match
|
114
|
+
"'/#{name}/'"
|
115
|
+
else
|
105
116
|
name
|
117
|
+
end
|
118
|
+
|
119
|
+
file =
|
120
|
+
if test_case.spring_enabled?
|
121
|
+
test_case.relative_file
|
106
122
|
else
|
107
|
-
|
123
|
+
test_case.file
|
108
124
|
end
|
109
125
|
|
110
|
-
|
111
|
-
%{cd #{test_case.app_root} && #{test_case.example_runner} #{test_case.relative_file} --name='#{name_arg}'}
|
112
|
-
else
|
113
|
-
%{cd #{test_case.app_root} && #{test_case.example_runner} #{test_case.file} --name='#{name_arg}'}
|
114
|
-
end
|
126
|
+
%{cd #{test_case.app_root} && #{test_case.example_runner} #{file} --name=#{name_arg}}
|
115
127
|
end
|
116
128
|
|
117
129
|
def multiple_examples_same_file(test_cases)
|
@@ -135,7 +147,7 @@ Open an issue on https://github.com/petekinnecom/test_launcher if this is someth
|
|
135
147
|
class TestCase < Base::TestCase
|
136
148
|
def example_runner
|
137
149
|
if spring_enabled?
|
138
|
-
"
|
150
|
+
"#{spring_runner} rails test"
|
139
151
|
else
|
140
152
|
"bundle exec ruby -I test"
|
141
153
|
end
|
@@ -143,7 +155,7 @@ Open an issue on https://github.com/petekinnecom/test_launcher if this is someth
|
|
143
155
|
|
144
156
|
def file_runner
|
145
157
|
if spring_enabled?
|
146
|
-
"
|
158
|
+
"#{spring_runner} rails test"
|
147
159
|
else
|
148
160
|
"bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}'"
|
149
161
|
end
|
@@ -157,12 +169,15 @@ Open an issue on https://github.com/petekinnecom/test_launcher if this is someth
|
|
157
169
|
return false if request.disable_spring?
|
158
170
|
return true if request.force_spring?
|
159
171
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
172
|
+
File.exist?(File.join(app_root, "bin/spring"))
|
173
|
+
end
|
174
|
+
|
175
|
+
def spring_runner
|
176
|
+
if File.exist?(File.join(app_root, "bin/spring"))
|
177
|
+
"bin/spring"
|
178
|
+
else
|
179
|
+
"bundle exec spring"
|
180
|
+
end
|
166
181
|
end
|
167
182
|
|
168
183
|
def example
|
@@ -1,41 +1,3 @@
|
|
1
|
-
require "test_launcher/
|
2
|
-
require "test_launcher/rubymine/launcher"
|
3
|
-
require "test_launcher/rubymine/request"
|
1
|
+
require "test_launcher/rubymine/parser"
|
4
2
|
|
5
|
-
|
6
|
-
#
|
7
|
-
# -r test_launcher/rubymine
|
8
|
-
#
|
9
|
-
# we need to put the currently executing script in with the args.
|
10
|
-
#
|
11
|
-
# Consider the following examples:
|
12
|
-
#
|
13
|
-
# ruby -r test_launcher/rubymine /path/to/test.rb
|
14
|
-
#
|
15
|
-
# vs
|
16
|
-
#
|
17
|
-
# ruby -r test_launcher/rubymine spring testunit /path/to/test.rb
|
18
|
-
#
|
19
|
-
# In one case, our test to run is $0 and in another case it's an ARGV.
|
20
|
-
# So we throw them in the same bucket and let the launcher figure it
|
21
|
-
# out. It doesn't matter since we will `exec` a new command anyway.
|
22
|
-
|
23
|
-
module TestLauncher
|
24
|
-
module Rubymine
|
25
|
-
def self.launch
|
26
|
-
shell = TestLauncher::Shell::Runner.new(log_path: "/dev/null")
|
27
|
-
|
28
|
-
request = Request.new(
|
29
|
-
disable_spring: ENV["DISABLE_SPRING"]
|
30
|
-
)
|
31
|
-
|
32
|
-
Launcher.new(
|
33
|
-
args: [$0].concat(ARGV),
|
34
|
-
shell: shell,
|
35
|
-
request: request
|
36
|
-
).launch
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
TestLauncher::Rubymine.launch
|
3
|
+
TestLauncher::Rubymine::Parser.launch
|
@@ -3,6 +3,9 @@ require "test_launcher/shell/runner"
|
|
3
3
|
|
4
4
|
module TestLauncher
|
5
5
|
module Rubymine
|
6
|
+
# Parsing command line args with regex is not ideal ...¯\_(ツ)_/¯
|
7
|
+
TEST_NAME_REGEX = %r{['"]*/?\^?([^/'"\$]*)\$?/?['"]*}
|
8
|
+
|
6
9
|
class Launcher
|
7
10
|
def initialize(args:, shell:, request:)
|
8
11
|
@args = args
|
@@ -14,7 +17,14 @@ module TestLauncher
|
|
14
17
|
if args.any? {|a| a.match("ruby-debug-ide")}
|
15
18
|
shell.puts "test_launcher: hijacking and debugging"
|
16
19
|
|
17
|
-
debug_command =
|
20
|
+
debug_command = (
|
21
|
+
if args.first.match(/bash/)
|
22
|
+
"cd #{test_case.app_root} && #{args.join(" ")}"
|
23
|
+
else
|
24
|
+
"cd #{test_case.app_root} && bundle exec ruby -I test #{args.join(" ")}"
|
25
|
+
end
|
26
|
+
)
|
27
|
+
|
18
28
|
shell.puts debug_command
|
19
29
|
shell.exec debug_command
|
20
30
|
else
|
@@ -40,7 +50,13 @@ module TestLauncher
|
|
40
50
|
if args[-1].match("--name=")
|
41
51
|
Frameworks::Minitest::TestCase.new(
|
42
52
|
file: args[-2],
|
43
|
-
example: args[-1][
|
53
|
+
example: args[-1][%r{--name=#{TEST_NAME_REGEX}}, 1],
|
54
|
+
request: request
|
55
|
+
)
|
56
|
+
elsif args[-2]&.match("--name")
|
57
|
+
Frameworks::Minitest::TestCase.new(
|
58
|
+
file: args[-3],
|
59
|
+
example: args[-1][TEST_NAME_REGEX, 1],
|
44
60
|
request: request
|
45
61
|
)
|
46
62
|
else
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "test_launcher/shell/runner"
|
2
|
+
require "test_launcher/rubymine/launcher"
|
3
|
+
require "test_launcher/rubymine/request"
|
4
|
+
|
5
|
+
# To allow us to simply specify our run configuration as:
|
6
|
+
#
|
7
|
+
# -r test_launcher/rubymine
|
8
|
+
#
|
9
|
+
# we need to put the currently executing script in with the args.
|
10
|
+
#
|
11
|
+
# Consider the following examples:
|
12
|
+
#
|
13
|
+
# ruby -r test_launcher/rubymine /path/to/test.rb
|
14
|
+
#
|
15
|
+
# vs
|
16
|
+
#
|
17
|
+
# ruby -r test_launcher/rubymine spring testunit /path/to/test.rb
|
18
|
+
#
|
19
|
+
# In one case, our test to run is $0 and in another case it's an ARGV.
|
20
|
+
# So we throw them in the same bucket and let the launcher figure it
|
21
|
+
# out. It doesn't matter since we will `exec` a new command anyway.
|
22
|
+
|
23
|
+
module TestLauncher
|
24
|
+
module Rubymine
|
25
|
+
module Parser
|
26
|
+
def self.launch(
|
27
|
+
shell: TestLauncher::Shell::Runner.new(log_path: "/dev/null"),
|
28
|
+
argv: ARGV,
|
29
|
+
env: ENV
|
30
|
+
)
|
31
|
+
request = Request.new(
|
32
|
+
disable_spring: ENV["DISABLE_SPRING"]
|
33
|
+
)
|
34
|
+
|
35
|
+
args = [$0].concat(argv).map { |arg|
|
36
|
+
if arg.match("minitest_runner.rb") && env.key?("INTELLIJ_IDEA_RUN_CONF_TEST_FILE_PATH")
|
37
|
+
arg.sub(%r{/.+/minitest_runner.rb['"]?}, env.fetch("INTELLIJ_IDEA_RUN_CONF_TEST_FILE_PATH"))
|
38
|
+
else
|
39
|
+
arg
|
40
|
+
end
|
41
|
+
}
|
42
|
+
|
43
|
+
Launcher.new(
|
44
|
+
args: args,
|
45
|
+
shell: shell,
|
46
|
+
request: request
|
47
|
+
).launch
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_launcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Kinnecom
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/test_launcher/queries.rb
|
65
65
|
- lib/test_launcher/rubymine.rb
|
66
66
|
- lib/test_launcher/rubymine/launcher.rb
|
67
|
+
- lib/test_launcher/rubymine/parser.rb
|
67
68
|
- lib/test_launcher/rubymine/request.rb
|
68
69
|
- lib/test_launcher/search.rb
|
69
70
|
- lib/test_launcher/search/ag.rb
|
@@ -77,7 +78,7 @@ homepage: http://github.com/petekinnecom/test_launcher
|
|
77
78
|
licenses:
|
78
79
|
- MIT
|
79
80
|
metadata: {}
|
80
|
-
post_install_message:
|
81
|
+
post_install_message:
|
81
82
|
rdoc_options: []
|
82
83
|
require_paths:
|
83
84
|
- lib
|
@@ -92,9 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
|
-
|
96
|
-
|
97
|
-
signing_key:
|
96
|
+
rubygems_version: 3.0.3
|
97
|
+
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Easily run tests
|
100
100
|
test_files: []
|