test_launcher 2.3.0 → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f1ee0a4fbf3c9e6973fd82d15b3cbe1c0751153
4
- data.tar.gz: b35970bb6e285cd651b83f7441af0138a5f3cc8a
3
+ metadata.gz: 15db8103099d657fa88ed3321e03766dc28ccbc3
4
+ data.tar.gz: 49f24e6a8e3a4f886c28fcfe3193b6314d5d167d
5
5
  SHA512:
6
- metadata.gz: 3019301764f5ab3dc68b3dde5af0641c6457660f4bda05d828476a76b3297d75cbb3de01fafbcedd6c392e6d76fc67eec0c2b1fa8b0816736c646bb230776ab0
7
- data.tar.gz: 2c842f83bbb877e31b6271093aa31ee86522989852e3e5ca909bc7a7a9a1898091d1d3fbc2dbe6ce03553c8239fb6e750b96c8ab26a15212054f72d11d40714a
6
+ metadata.gz: 38c67f9eb592ab6d61a15cb2fa1710a847ce42632d4693835cb6e6c14de124c3c7b4e7da03f7c83755327d4139124d343f57d5d19a970b0afe4ce06612e5f819
7
+ data.tar.gz: 9589081ac966e5ef5894b08ec948344275e95ea4a7febe7e411459d40f58c291f91d3026f0a702aaff503bfb757f8742366b3a435d9be5bf0109f6dd68db34e9
data/README.md CHANGED
@@ -194,6 +194,9 @@ Suppose you type `test_launcher thing`. It will run tests using this priority p
194
194
  1. Any test file based on a generic search
195
195
  - runs `stuff_test.rb` because it found the word `thing` inside of it
196
196
 
197
+ 1. Finally, if the query matches against a non-test file, it will simply run that file
198
+ - runs `ruby thing.rb` because it found `thing.rb`
199
+
197
200
  If your query looks like it's specifying a line number (e.g. `file_test.rb:17`), that search will be preferred.
198
201
 
199
202
  Any time it matches multiple files, it will default to running the most recently edited file. You can append `--all` if you want to run all matching tests, even if they are in different engines/gems!
@@ -5,6 +5,7 @@ require "test_launcher/version"
5
5
  require "test_launcher/frameworks/rspec"
6
6
  require "test_launcher/frameworks/minitest"
7
7
  require "test_launcher/frameworks/ex_unit"
8
+ require "test_launcher/frameworks/generic"
8
9
  require "test_launcher/cli/options"
9
10
 
10
11
  module TestLauncher
@@ -56,8 +57,10 @@ VERSION: #{TestLauncher::VERSION}
56
57
  [Frameworks::Minitest]
57
58
  elsif @options[:framework] == "ex_unit"
58
59
  [Frameworks::ExUnit]
60
+ elsif @options[:framework] == "generic"
61
+ [Frameworks::Generic]
59
62
  else
60
- [Frameworks::Minitest, Frameworks::RSpec, Frameworks::ExUnit]
63
+ [Frameworks::Minitest, Frameworks::RSpec, Frameworks::ExUnit, Frameworks::Generic]
61
64
  end
62
65
 
63
66
  Options.new(
@@ -0,0 +1,80 @@
1
+ require 'shellwords'
2
+ require "test_launcher/base_error"
3
+
4
+ module TestLauncher
5
+ module Frameworks
6
+ NotSupportedError = Class.new(BaseError)
7
+
8
+ module Generic
9
+ def self.active?
10
+ true
11
+ end
12
+
13
+ def self.test_case(*a)
14
+ TestCase.new(*a)
15
+ end
16
+
17
+ def self.searcher(*a)
18
+ Searcher.new(*a)
19
+ end
20
+
21
+ def self.runner(*a)
22
+ Runner.new(*a)
23
+ end
24
+
25
+ class Searcher < Base::Searcher
26
+ MultipleByLineMatches = Class.new(BaseError)
27
+
28
+ def by_line(*)
29
+ return []
30
+ end
31
+
32
+ def examples(*)
33
+ []
34
+ end
35
+
36
+ def grep(*)
37
+ []
38
+ end
39
+
40
+ private
41
+
42
+ def file_name_regex
43
+ /\.rb$/
44
+ end
45
+
46
+ def file_name_pattern
47
+ "*.rb"
48
+ end
49
+ end
50
+
51
+ class Runner < Base::Runner
52
+ def by_line_number(test_case)
53
+ raise NotSupportedError.new("You should not have hit this error. File an issue. :(")
54
+ end
55
+
56
+ def single_example(test_case, name: test_case.example, exact_match: false)
57
+ raise NotSupportedError.new("You should not have hit this error. File an issue. :(")
58
+ end
59
+
60
+ def multiple_examples_same_file(test_cases)
61
+ raise NotSupportedError.new("You should not have hit this error. File an issue. :(")
62
+ end
63
+
64
+ def multiple_examples_same_root(test_cases)
65
+ raise NotSupportedError.new("You should not have hit this error. File an issue. :(")
66
+ end
67
+
68
+ def one_or_more_files(test_cases)
69
+ %{#{test_cases.first.file_runner} #{test_cases.map(&:file).uniq.join(" ")}}
70
+ end
71
+ end
72
+
73
+ class TestCase < Base::TestCase
74
+ def file_runner
75
+ "ruby"
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,3 +1,3 @@
1
1
  module TestLauncher
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
@@ -0,0 +1,44 @@
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)
9
+ query += " --framework generic "
10
+ shell.reset
11
+ CLI.launch(query.split(" "), env, shell: shell, searcher: searcher)
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
+ end
44
+ 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.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Kinnecom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-05 00:00:00.000000000 Z
11
+ date: 2017-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,7 @@ files:
60
60
  - lib/test_launcher/cli/request.rb
61
61
  - lib/test_launcher/frameworks/base.rb
62
62
  - lib/test_launcher/frameworks/ex_unit.rb
63
+ - lib/test_launcher/frameworks/generic.rb
63
64
  - lib/test_launcher/frameworks/implementation/test_case.rb
64
65
  - lib/test_launcher/frameworks/minitest.rb
65
66
  - lib/test_launcher/frameworks/rspec.rb
@@ -88,6 +89,7 @@ files:
88
89
  - test/test_launcher/frameworks/minitest/searcher_test.rb
89
90
  - test/test_launcher/frameworks/rspec/runner_test.rb
90
91
  - test/test_launcher/frameworks/rspec/searcher_test.rb
92
+ - test/test_launcher/generic_integration_test.rb
91
93
  - test/test_launcher/minitest_integration_test.rb
92
94
  - test/test_launcher/queries/example_name_query_test.rb
93
95
  - test/test_launcher/queries/full_regex_query_test.rb
@@ -140,6 +142,7 @@ test_files:
140
142
  - test/test_launcher/frameworks/minitest/searcher_test.rb
141
143
  - test/test_launcher/frameworks/rspec/runner_test.rb
142
144
  - test/test_launcher/frameworks/rspec/searcher_test.rb
145
+ - test/test_launcher/generic_integration_test.rb
143
146
  - test/test_launcher/minitest_integration_test.rb
144
147
  - test/test_launcher/queries/example_name_query_test.rb
145
148
  - test/test_launcher/queries/full_regex_query_test.rb