test_launcher 2.23.0 → 2.27.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 36291b804b53a382960871ce80a0d4c8f7e970d7
4
- data.tar.gz: 04c1e9c5cc445604178eb93f73268f9d7b4e8798
2
+ SHA256:
3
+ metadata.gz: e7ec057af100586d64b53b846e170557e38d2933deb5c36b311e12372cd64080
4
+ data.tar.gz: d24c42f24628fce2eb6d1936ac89853b9e0af21d4d1752717d40d87e1c7455c2
5
5
  SHA512:
6
- metadata.gz: 242965dc63b3cca5bf48fc4c6a16da2ac09e9bf731e1e0e0d9805f8dae8675d4dc85b4555bcc9960873e41953cd4f2b6eede4e199a6bfc813e6ec5247bb43fc3
7
- data.tar.gz: ba132f4e999694c2d602e3cd438a200a65369d8c8ae4c1839523870e6587a3db15b6edab8f5d07ff272fc71af5bf608d9a43055a256018d995f4983bf0fb13b0
6
+ metadata.gz: '049bad337c0799ff8990bab76c1e27ed9699fe549a9a5f2ac01b8f409ba3a9c602e9ae234f88894c9a9ed16d8c78eed16b31eb0afc3758e857e87bb19d38f735'
7
+ data.tar.gz: a1d4822e25ab350eabcf99e708e20a3eeb9a6f3c19098f691f9aae592c57a71305f6d9a8be1bdb7ca194d8a591cb6fc17ecc3cb234a92d0b943b81da0b0626c5
@@ -1,20 +1,39 @@
1
1
  module TestLauncher
2
2
  module CLI
3
- class Options < Struct.new(
4
- :search_string,
5
- :frameworks,
6
- :rerun,
7
- :run_all,
8
- :disable_spring,
9
- :force_spring,
10
- :example_name,
11
- :shell,
12
- :searcher
13
- )
14
- def initialize(**args)
15
- raise ArgumentError.new("These keys are allowed and required: #{members}") unless args.keys.sort == members.sort
16
- args.each { |k, v| self[k] = v }
3
+ class Options
4
+ attr_reader(
5
+ :disable_spring,
6
+ :example_name,
7
+ :force_spring,
8
+ :frameworks,
9
+ :rerun,
10
+ :run_all,
11
+ :search_string,
12
+ :searcher,
13
+ :shell
14
+ )
15
+ def initialize(
16
+ disable_spring:,
17
+ example_name:,
18
+ force_spring:,
19
+ frameworks:,
20
+ rerun:,
21
+ run_all:,
22
+ search_string:,
23
+ searcher:,
24
+ shell:
25
+ )
26
+ @disable_spring = disable_spring
27
+ @example_name = example_name
28
+ @force_spring = force_spring
29
+ @frameworks = frameworks
30
+ @rerun = rerun
31
+ @run_all = run_all
32
+ @search_string = search_string
33
+ @searcher = searcher
34
+ @shell = shell
17
35
  end
36
+
18
37
  end
19
38
  end
20
39
  end
@@ -51,12 +51,12 @@ module TestLauncher
51
51
  framework.searcher(@searcher)
52
52
  end
53
53
 
54
- def runner(*a)
55
- framework.runner(*a)
54
+ def runner(*a, **o)
55
+ framework.runner(*a, **o)
56
56
  end
57
57
 
58
- def test_case(*a)
59
- framework.test_case(*a)
58
+ def test_case(*a, **o)
59
+ framework.test_case(*a, **o)
60
60
  end
61
61
 
62
62
  def shell
@@ -6,7 +6,12 @@ require "test_launcher/cli/request"
6
6
 
7
7
  module TestLauncher
8
8
  module CLI
9
- class MultiFrameworkQuery < Struct.new(:cli_options)
9
+ class MultiFrameworkQuery
10
+ attr_reader :cli_options
11
+ def initialize(cli_options)
12
+ @cli_options = cli_options
13
+ end
14
+
10
15
  def command
11
16
  command = nil
12
17
  command_finders.each do |command_finder|
@@ -3,7 +3,12 @@ require "test_launcher/frameworks/implementation/test_case"
3
3
  module TestLauncher
4
4
  module Frameworks
5
5
  module Base
6
- class Searcher < Struct.new(:raw_searcher)
6
+ class Searcher
7
+ attr_reader :raw_searcher
8
+ def initialize(raw_searcher, **)
9
+ @raw_searcher = raw_searcher
10
+ end
11
+
7
12
  def test_files(query)
8
13
  raw_searcher
9
14
  .find_files(query)
@@ -38,6 +43,10 @@ module TestLauncher
38
43
  end
39
44
 
40
45
  class Runner
46
+ def initialize(*, **)
47
+ super()
48
+ end
49
+
41
50
  def by_line_number(test_case)
42
51
  raise NotImplementedError
43
52
  end
@@ -9,16 +9,16 @@ module TestLauncher
9
9
  `git ls-files '*.exs'`.split("\n").any?
10
10
  end
11
11
 
12
- def self.test_case(*a)
13
- TestCase.new(*a)
12
+ def self.test_case(*a, **o)
13
+ TestCase.new(*a, **o)
14
14
  end
15
15
 
16
- def self.searcher(*a)
17
- Searcher.new(*a)
16
+ def self.searcher(*a, **o)
17
+ Searcher.new(*a, **o)
18
18
  end
19
19
 
20
- def self.runner(*a)
21
- Runner.new(*a)
20
+ def self.runner(*a, **o)
21
+ Runner.new(*a, **o)
22
22
  end
23
23
 
24
24
  class Searcher < Base::Searcher
@@ -10,16 +10,16 @@ module TestLauncher
10
10
  true
11
11
  end
12
12
 
13
- def self.test_case(*a)
14
- TestCase.new(*a)
13
+ def self.test_case(*a, **o)
14
+ TestCase.new(*a, **o)
15
15
  end
16
16
 
17
- def self.searcher(*a)
18
- Searcher.new(*a)
17
+ def self.searcher(*a, **o)
18
+ Searcher.new(*a, **o)
19
19
  end
20
20
 
21
- def self.runner(*a)
22
- Runner.new(*a)
21
+ def self.runner(*a, **o)
22
+ Runner.new(*a, **o)
23
23
  end
24
24
 
25
25
  class Searcher < Base::Searcher
@@ -10,16 +10,16 @@ module TestLauncher
10
10
  `git ls-files '*_test.rb'`.split("\n").any?
11
11
  end
12
12
 
13
- def self.test_case(*a)
14
- TestCase.new(*a)
13
+ def self.test_case(*a, **o)
14
+ TestCase.new(*a, **o)
15
15
  end
16
16
 
17
- def self.searcher(*a)
18
- Searcher.new(*a)
17
+ def self.searcher(*a, **o)
18
+ Searcher.new(*a, **o)
19
19
  end
20
20
 
21
- def self.runner(*a)
22
- Runner.new(*a)
21
+ def self.runner(*a, **o)
22
+ Runner.new(*a, **o)
23
23
  end
24
24
 
25
25
  class Searcher < Base::Searcher
@@ -84,14 +84,14 @@ module TestLauncher
84
84
  end
85
85
 
86
86
  def multiple_files_error
87
- MultipleByLineMatches.new(<<-MSG)
88
- It looks like you are running a line number in a test file.
87
+ MultipleByLineMatches.new(<<~MSG)
88
+ It looks like you are running a line number in a test file.
89
89
 
90
- Multiple files have been found that match your query.
90
+ Multiple files have been found that match your query.
91
91
 
92
- This case is not supported for Minitest.
92
+ This case is not supported for Minitest.
93
93
 
94
- Open an issue on https://github.com/petekinnecom/test_launcher if this is something you have run into at least 3 times. :)
94
+ Open an issue on https://github.com/petekinnecom/test_launcher if this is something you have run into at least 3 times. :)
95
95
  MSG
96
96
  end
97
97
 
@@ -147,7 +147,7 @@ Open an issue on https://github.com/petekinnecom/test_launcher if this is someth
147
147
  class TestCase < Base::TestCase
148
148
  def example_runner
149
149
  if spring_enabled?
150
- "bundle exec spring rails test"
150
+ "#{spring_runner} rails test"
151
151
  else
152
152
  "bundle exec ruby -I test"
153
153
  end
@@ -155,7 +155,7 @@ Open an issue on https://github.com/petekinnecom/test_launcher if this is someth
155
155
 
156
156
  def file_runner
157
157
  if spring_enabled?
158
- "bundle exec spring rails test"
158
+ "#{spring_runner} rails test"
159
159
  else
160
160
  "bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}'"
161
161
  end
@@ -169,12 +169,15 @@ Open an issue on https://github.com/petekinnecom/test_launcher if this is someth
169
169
  return false if request.disable_spring?
170
170
  return true if request.force_spring?
171
171
 
172
- [
173
- "bin/spring",
174
- "bin/testunit"
175
- ].any? {|f|
176
- File.exist?(File.join(app_root, f))
177
- }
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
178
181
  end
179
182
 
180
183
  def example
@@ -9,16 +9,16 @@ module TestLauncher
9
9
  `git ls-files '*pec.js'`.split("\n").any?
10
10
  end
11
11
 
12
- def self.test_case(*a)
13
- TestCase.new(*a)
12
+ def self.test_case(*a, **o)
13
+ TestCase.new(*a, **o)
14
14
  end
15
15
 
16
- def self.searcher(*a)
17
- Searcher.new(*a)
16
+ def self.searcher(*a, **o)
17
+ Searcher.new(*a, **o)
18
18
  end
19
19
 
20
- def self.runner(*a)
21
- Runner.new(*a)
20
+ def self.runner(*a, **o)
21
+ Runner.new(*a, **o)
22
22
  end
23
23
 
24
24
  class Searcher < Base::Searcher
@@ -9,16 +9,16 @@ module TestLauncher
9
9
  `git ls-files '*_spec.rb'`.split("\n").any?
10
10
  end
11
11
 
12
- def self.test_case(*a)
13
- TestCase.new(*a)
12
+ def self.test_case(*a, **o)
13
+ TestCase.new(*a, **o)
14
14
  end
15
15
 
16
- def self.searcher(*a)
17
- Searcher.new(*a)
16
+ def self.searcher(*a, **o)
17
+ Searcher.new(*a, **o)
18
18
  end
19
19
 
20
- def self.runner(*a)
21
- Runner.new(*a)
20
+ def self.runner(*a, **o)
21
+ Runner.new(*a, **o)
22
22
  end
23
23
 
24
24
  class Searcher < Base::Searcher
@@ -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 = "cd #{test_case.app_root} && bundle exec ruby -I test #{args.join(" ")}"
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,13 +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][/--name=(.*)/, 1],
53
+ example: args[-1][%r{--name=#{TEST_NAME_REGEX}}, 1],
44
54
  request: request
45
55
  )
46
56
  elsif args[-2]&.match("--name")
47
57
  Frameworks::Minitest::TestCase.new(
48
58
  file: args[-3],
49
- example: args[-1][/\/?([^\/]*)\/?/, 1],
59
+ example: args[-1][TEST_NAME_REGEX, 1],
50
60
  request: request
51
61
  )
52
62
  else
@@ -0,0 +1,64 @@
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 (
37
+ arg.match("minitest_runner.rb") &&
38
+ env.key?("INTELLIJ_IDEA_RUN_CONF_TEST_FILE_PATH")
39
+ )
40
+ arg.sub(
41
+ %r{/.+/minitest_runner.rb['"]?},
42
+ env.fetch("INTELLIJ_IDEA_RUN_CONF_TEST_FILE_PATH")
43
+ )
44
+ elsif (
45
+ arg.match("tunit_or_minitest_in_folder_runner.rb") &&
46
+ env.key?("INTELLIJ_IDEA_RUN_CONF_FOLDER_PATH"))
47
+ arg.sub(
48
+ %r{/.+/tunit_or_minitest_in_folder_runner.rb['"]?},
49
+ File.join(env.fetch("INTELLIJ_IDEA_RUN_CONF_FOLDER_PATH"), "**/*.rb")
50
+ )
51
+ else
52
+ arg
53
+ end
54
+ }
55
+
56
+ Launcher.new(
57
+ args: args,
58
+ shell: shell,
59
+ request: request
60
+ ).launch
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,41 +1,3 @@
1
- require "test_launcher/shell/runner"
2
- require "test_launcher/rubymine/launcher"
3
- require "test_launcher/rubymine/request"
1
+ require "test_launcher/rubymine/parser"
4
2
 
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
- 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
@@ -1,3 +1,3 @@
1
1
  module TestLauncher
2
- VERSION = "2.23.0"
2
+ VERSION = "2.27.0.pre"
3
3
  end
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "bundler", ">= 1.7"
22
+ spec.add_development_dependency "rake", ">= 12.3.3"
23
23
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_launcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.23.0
4
+ version: 2.27.0.pre
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: 2019-12-06 00:00:00.000000000 Z
11
+ date: 2022-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.7'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  description: no really
42
42
  email:
43
43
  - pete.kinnecom@appfolio.com
@@ -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
@@ -88,13 +89,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
89
  version: '0'
89
90
  required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  requirements:
91
- - - ">="
92
+ - - ">"
92
93
  - !ruby/object:Gem::Version
93
- version: '0'
94
+ version: 1.3.1
94
95
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.5.2
97
- signing_key:
96
+ rubygems_version: 3.2.22
97
+ signing_key:
98
98
  specification_version: 4
99
99
  summary: Easily run tests
100
100
  test_files: []