test_launcher 2.14.0 → 2.14.1.pre1

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: e3b59f00b901cff2468945b801e83ea7cf896709
4
- data.tar.gz: 657c4065ed96c0c9b965064edbc0ddf6dac808b1
3
+ metadata.gz: d4a45be4f0446aca788daa527994210037afe9a7
4
+ data.tar.gz: 100256d6001d57eca614037a69def2499e86b08a
5
5
  SHA512:
6
- metadata.gz: d4a978c3bdd1b7e569722c19923249f883e290024b2380e1077e79b9c9c23c42b8a9ca0e93c6065aa243bd9741ca34c897ea98608474041055bfb0094388d6d2
7
- data.tar.gz: bc82003b5c1e82a701fa7777af459f184999d293f0f05eac52ed1e82b7f90711e5db53012142d1d05e92277030a2801adc3c92f79585af87cbd6fb0ce6ef4941
6
+ metadata.gz: 80e4ba43679d1e492bf8427113b798f188fa3bb5211c4876a2ab034c09b90cba155f7d55ebac2fd3ce09576546744c97ad05b2edc659a4a9e7adf2ac4e553b92
7
+ data.tar.gz: e52381314b0d8136ba4c2937c403440d0517161921466e6ebf2f76097174acfd0c872a58151568c11037ee10ab6c4cde8050ffa37f5df4d9135590c1905d21c9
data/README.md CHANGED
@@ -362,63 +362,33 @@ If you don't want to use spring to run your tests, but test_launcher tries to us
362
362
 
363
363
  # Visual Studio Code Support
364
364
 
365
- To run tests from the editor, we need to define some tasks. I like to have three tasks defined: run the test that contains the cursor, run the whole test file, and rerun the last test.
366
-
367
- You can add these to your `.vscode/tasks.json` file:
368
-
369
- ```
370
- {
371
- "version": "2.0.0",
372
- "tasks": [
373
- {
374
- "taskName": "run-test-line",
375
- "command": "test_launcher",
376
- "runner": "terminal",
377
- "args": [
378
- "${file}:${lineNumber}",
379
- "--disable-spring"
380
- ]
381
- },
382
- {
383
- "taskName": "run-test-file",
384
- "command": "test_launcher",
385
- "runner": "terminal",
386
- "args": [
387
- "${file}",
388
- "--disable-spring"
389
- ]
390
- },
391
- {
392
- "taskName": "rerun-last-test",
393
- "command": "test_launcher",
394
- "runner": "terminal",
395
- "args": [
396
- "--rerun"
397
- ]
398
- }
399
- ]
400
- }
401
- ```
402
-
403
- Next, we need some key-combos to trigger each task. Add this to your `.vscode/keybindings.json` and tweak the key-combos to your liking:
404
- ```
405
- ...
406
- {
407
- "key": "shift+cmd+r",
408
- "command": "workbench.action.tasks.runTask",
409
- "args": "run-test-line"
410
- },
411
- {
412
- "key": "alt+cmd+r",
413
- "command": "workbench.action.tasks.runTask",
414
- "args": "run-test-file"
415
- },
416
- {
417
- "key": "cmd+r",
418
- "command": "workbench.action.tasks.runTask",
419
- "args": "rerun-last-test"
420
- }
421
- ...
365
+ Install the [Run in Terminal](https://marketplace.visualstudio.com/items?itemName=kortina.run-in-terminal) extension. This allows us to assign keybindings to specific terminal commands. Then we can add TestLauncher keybindings to our `keybindings.json`. Here is an example configuration:
366
+
367
+ ```
368
+ {
369
+ "key": "shift+cmd+r",
370
+ "command": "runInTerminal.run",
371
+ "args": {
372
+ "cmd": "test_launcher ${file}:${line}",
373
+ "match": ".*"
374
+ }
375
+ },
376
+ {
377
+ "key": "alt+cmd+r",
378
+ "command": "runInTerminal.run",
379
+ "args": {
380
+ "cmd": "test_launcher ${file}",
381
+ "match": ".*"
382
+ }
383
+ },
384
+ {
385
+ "key": "cmd+r",
386
+ "command": "runInTerminal.run",
387
+ "args": {
388
+ "cmd": "test_launcher --rerun",
389
+ "match": ".*"
390
+ }
391
+ },
422
392
  ```
423
393
 
424
394
  # Atom Support
@@ -37,7 +37,7 @@ module TestLauncher
37
37
  end
38
38
  end
39
39
 
40
- def self.launch(argv, env, shell: Shell::HistoryRunner.new, searcher: Search.searcher(shell))
40
+ def self.launch(argv, env, shell: Shell::HistoryRunner.new(shell: Shell::Runner.new(log_path: '/tmp/test_launcher.log')), searcher: Search.searcher(shell))
41
41
  options = CLI::InputParser.new(
42
42
  argv,
43
43
  env
@@ -6,6 +6,7 @@ require "test_launcher/frameworks/rspec"
6
6
  require "test_launcher/frameworks/minitest"
7
7
  require "test_launcher/frameworks/ex_unit"
8
8
  require "test_launcher/frameworks/generic"
9
+ require "test_launcher/frameworks/mochajs"
9
10
  require "test_launcher/cli/options"
10
11
 
11
12
  module TestLauncher
@@ -60,7 +61,12 @@ VERSION: #{TestLauncher::VERSION}
60
61
  elsif @options[:framework] == "generic"
61
62
  [Frameworks::Generic]
62
63
  else
63
- [Frameworks::Minitest, Frameworks::RSpec, Frameworks::ExUnit, Frameworks::Generic]
64
+ [Frameworks::Minitest,
65
+ Frameworks::RSpec,
66
+ Frameworks::ExUnit,
67
+ Frameworks::Mochajs,
68
+ Frameworks::Generic,
69
+ ]
64
70
  end
65
71
 
66
72
  Options.new(
@@ -0,0 +1,109 @@
1
+ require "shellwords"
2
+ require "test_launcher/frameworks/base"
3
+
4
+ module TestLauncher
5
+ module Frameworks
6
+ module Mochajs
7
+
8
+ def self.active?
9
+ output = `find . -name package-lock.json -exec grep mocha {} \;`
10
+ !output.chomp.strip.empty?.tap {|r| puts "mochajs: #{r}"}
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
+
27
+ def by_line(file_pattern, line_number)
28
+ files = test_files(file_pattern)
29
+ return [] unless files.any?
30
+ raise multiple_files_error if files.size > 1
31
+ #
32
+ file = files.first
33
+ grep_results = raw_searcher.grep(example_name_regex, file_pattern: file)
34
+
35
+ if grep_results.empty?
36
+ # the file exists, but doesn't appear to contain any tests...
37
+ # we'll try to run it anyway
38
+ return [file: file]
39
+ end
40
+
41
+ best_result =
42
+ grep_results
43
+ .select {|r| line_number >= r[:line_number]}
44
+ .min_by {|r| line_number - r[:line_number]}
45
+
46
+ if best_result
47
+ [{
48
+ file: best_result[:file],
49
+ example_name: best_result[:line].match(/(it|describe)\(["'](.*)['"],/)[2],
50
+ line_number: best_result[:line_number]
51
+ }]
52
+ else
53
+ # line number outside of example. Run whole file
54
+ [{
55
+ file: grep_results.first[:file]
56
+ }]
57
+ end
58
+ end
59
+
60
+ private
61
+
62
+ def file_name_regex
63
+ /.*pec\.js/
64
+ end
65
+
66
+ def file_name_pattern
67
+ '*pec.js'
68
+ end
69
+
70
+ def example_name_regex(query="")
71
+ "^\s*(it|describe).*(#{query}).*,.*"
72
+ end
73
+ end
74
+
75
+ class Runner < Base::Runner
76
+ def by_line_number(test_case)
77
+ if test_case.example
78
+ single_example(test_case, exact_match: true)
79
+ else
80
+ single_file(test_case)
81
+ end
82
+ end
83
+
84
+ def single_example(test_case, **_)
85
+ multiple_examples_same_root([test_case])
86
+ end
87
+
88
+ def multiple_examples_same_file(test_cases)
89
+ test_case = test_cases.first
90
+ single_example(test_case)
91
+ end
92
+
93
+ def multiple_examples_same_root(test_cases)
94
+ %{cd #{test_cases.first.app_root} && npm run test #{test_cases.map(&:file).join(" ")} -- --grep #{Shellwords.escape(test_cases.first.example)}}
95
+ end
96
+
97
+ def one_or_more_files(test_cases)
98
+ %{cd #{test_cases.first.app_root} && npm run test #{test_cases.map(&:file).join(" ")}}
99
+ end
100
+ end
101
+
102
+ class TestCase < Base::TestCase
103
+ def test_root_dir_name
104
+ "test"
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -1,3 +1,3 @@
1
1
  module TestLauncher
2
- VERSION = "2.14.0"
2
+ VERSION = "2.14.1.pre1"
3
3
  end
@@ -34,14 +34,14 @@ module TestLauncher
34
34
 
35
35
  def test_launch__debug__example
36
36
  args = "/Users/username/.rvm/gems/ruby-2.2.3/gems/ruby-debug-ide-0.6.1.beta2/bin/rdebug-ide --disable-int-handler --evaluation-timeout 10 --rubymine-protocol-extensions --port 58930 --host 0.0.0.0 --dispatcher-port 58931 -- /Users/username/some_app/bin/spring testunit /Users/username/some_app/engines/some_engine/test/does_something_test.rb --name=some_test_name"
37
- expected_command = "cd /Users/username/some_app/engines/some_engine && ruby -I test /Users/username/.rvm/gems/ruby-2.2.3/gems/ruby-debug-ide-0.6.1.beta2/bin/rdebug-ide --disable-int-handler --evaluation-timeout 10 --rubymine-protocol-extensions --port 58930 --host 0.0.0.0 --dispatcher-port 58931 -- /Users/username/some_app/bin/spring testunit /Users/username/some_app/engines/some_engine/test/does_something_test.rb --name=some_test_name"
37
+ expected_command = "cd /Users/username/some_app/engines/some_engine && bundle exec ruby -I test /Users/username/.rvm/gems/ruby-2.2.3/gems/ruby-debug-ide-0.6.1.beta2/bin/rdebug-ide --disable-int-handler --evaluation-timeout 10 --rubymine-protocol-extensions --port 58930 --host 0.0.0.0 --dispatcher-port 58931 -- /Users/username/some_app/bin/spring testunit /Users/username/some_app/engines/some_engine/test/does_something_test.rb --name=some_test_name"
38
38
 
39
39
  assert_executes(expected_command, args)
40
40
  end
41
41
 
42
42
  def test_launch__debug__file
43
43
  args = "/Users/username/.rvm/gems/ruby-2.2.3/gems/ruby-debug-ide-0.6.1.beta2/bin/rdebug-ide --disable-int-handler --evaluation-timeout 10 --rubymine-protocol-extensions --port 58930 --host 0.0.0.0 --dispatcher-port 58931 -- /Users/username/some_app/bin/spring testunit /Users/username/some_app/engines/some_engine/test/does_something_test.rb"
44
- expected_command = "cd /Users/username/some_app/engines/some_engine && ruby -I test /Users/username/.rvm/gems/ruby-2.2.3/gems/ruby-debug-ide-0.6.1.beta2/bin/rdebug-ide --disable-int-handler --evaluation-timeout 10 --rubymine-protocol-extensions --port 58930 --host 0.0.0.0 --dispatcher-port 58931 -- /Users/username/some_app/bin/spring testunit /Users/username/some_app/engines/some_engine/test/does_something_test.rb"
44
+ expected_command = "cd /Users/username/some_app/engines/some_engine && bundle exec ruby -I test /Users/username/.rvm/gems/ruby-2.2.3/gems/ruby-debug-ide-0.6.1.beta2/bin/rdebug-ide --disable-int-handler --evaluation-timeout 10 --rubymine-protocol-extensions --port 58930 --host 0.0.0.0 --dispatcher-port 58931 -- /Users/username/some_app/bin/spring testunit /Users/username/some_app/engines/some_engine/test/does_something_test.rb"
45
45
 
46
46
  assert_executes(expected_command, args)
47
47
  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.14.0
4
+ version: 2.14.1.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Kinnecom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-03 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,7 @@ files:
63
63
  - lib/test_launcher/frameworks/generic.rb
64
64
  - lib/test_launcher/frameworks/implementation/test_case.rb
65
65
  - lib/test_launcher/frameworks/minitest.rb
66
+ - lib/test_launcher/frameworks/mochajs.rb
66
67
  - lib/test_launcher/frameworks/rspec.rb
67
68
  - lib/test_launcher/queries.rb
68
69
  - lib/test_launcher/rubymine.rb
@@ -118,9 +119,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
119
  version: '0'
119
120
  required_rubygems_version: !ruby/object:Gem::Requirement
120
121
  requirements:
121
- - - ">="
122
+ - - ">"
122
123
  - !ruby/object:Gem::Version
123
- version: '0'
124
+ version: 1.3.1
124
125
  requirements: []
125
126
  rubyforge_project:
126
127
  rubygems_version: 2.5.2