test_launcher 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/README.md +101 -18
  4. data/Rakefile +6 -0
  5. data/bin/test_launcher +8 -35
  6. data/lib/test_launcher.rb +22 -0
  7. data/lib/test_launcher/cli/input_parser.rb +73 -0
  8. data/lib/test_launcher/frameworks.rb +32 -0
  9. data/lib/test_launcher/frameworks/base.rb +54 -0
  10. data/lib/test_launcher/frameworks/implementation/collection.rb +27 -0
  11. data/lib/test_launcher/{tests/minitest → frameworks/implementation}/consolidator.rb +30 -32
  12. data/lib/test_launcher/frameworks/implementation/locator.rb +74 -0
  13. data/lib/test_launcher/frameworks/implementation/test_case.rb +65 -0
  14. data/lib/test_launcher/frameworks/minitest.rb +67 -0
  15. data/lib/test_launcher/frameworks/rspec.rb +50 -0
  16. data/lib/test_launcher/rubymine.rb +26 -0
  17. data/lib/test_launcher/rubymine/launcher.rb +55 -0
  18. data/lib/test_launcher/search/git.rb +64 -0
  19. data/lib/test_launcher/shell/runner.rb +19 -22
  20. data/lib/test_launcher/version.rb +1 -1
  21. data/test/install +3 -0
  22. data/test/test_helper.rb +32 -17
  23. data/test/test_launcher/fixtures/minitest/test/class_1_test.rb +17 -0
  24. data/test/test_launcher/fixtures/minitest/test/class_2_test.rb +5 -0
  25. data/test/test_launcher/fixtures/minitest/test/different_root/bin/spring +1 -0
  26. data/test/test_launcher/fixtures/minitest/test/different_root/test/different_root_test.rb +2 -0
  27. data/test/test_launcher/fixtures/rspec/spec/class_1_spec.rb +16 -0
  28. data/test/test_launcher/fixtures/rspec/spec/class_2_spec.rb +6 -0
  29. data/test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb +2 -0
  30. data/test/test_launcher/minitest_integration_test.rb +67 -0
  31. data/test/test_launcher/rspec_integration_test.rb +67 -0
  32. data/test/test_launcher/rubymine_test.rb +48 -0
  33. data/test_launcher.gemspec +2 -3
  34. metadata +39 -44
  35. data/bin/test_runner +0 -1
  36. data/lib/test_launcher/searchers/git_searcher.rb +0 -38
  37. data/lib/test_launcher/tests/minitest/finder.rb +0 -50
  38. data/lib/test_launcher/tests/minitest/wrappers/multiple_files.rb +0 -23
  39. data/lib/test_launcher/tests/minitest/wrappers/multiple_roots.rb +0 -23
  40. data/lib/test_launcher/tests/minitest/wrappers/single_file.rb +0 -29
  41. data/lib/test_launcher/tests/minitest/wrappers/single_root.rb +0 -27
  42. data/lib/test_launcher/tests/minitest/wrappers/single_test.rb +0 -37
  43. data/lib/test_launcher/utils/path.rb +0 -32
  44. data/lib/test_launcher/utils/pluralize.rb +0 -14
  45. data/test/test_launcher/searchers/git_searcher_test.rb +0 -50
  46. data/test/test_launcher/tests/minitest/consolidator_integration_test.rb +0 -191
  47. data/test/test_launcher/tests/minitest/finder_test.rb +0 -71
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["pete.kinnecom@appfolio.com"]
11
11
  spec.summary = %q{Easily run tests}
12
12
  spec.description = %q{no really}
13
- spec.homepage = ""
13
+ spec.homepage = "http://github.com/petekinnecom/test_launcher"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -18,7 +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_dependency("thor", [">= 0.19", "< 1.0"])
22
- spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_dependency "bundler", "~> 1.7"
23
22
  spec.add_development_dependency "rake", "~> 10.0"
24
23
  end
metadata CHANGED
@@ -1,35 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_launcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.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: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: thor
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0.19'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '1.0'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '0.19'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '1.0'
33
13
  - !ruby/object:Gem::Dependency
34
14
  name: bundler
35
15
  requirement: !ruby/object:Gem::Requirement
@@ -37,7 +17,7 @@ dependencies:
37
17
  - - "~>"
38
18
  - !ruby/object:Gem::Version
39
19
  version: '1.7'
40
- type: :development
20
+ type: :runtime
41
21
  prerelease: false
42
22
  version_requirements: !ruby/object:Gem::Requirement
43
23
  requirements:
@@ -63,7 +43,6 @@ email:
63
43
  - pete.kinnecom@appfolio.com
64
44
  executables:
65
45
  - test_launcher
66
- - test_runner
67
46
  extensions: []
68
47
  extra_rdoc_files: []
69
48
  files:
@@ -73,27 +52,36 @@ files:
73
52
  - README.md
74
53
  - Rakefile
75
54
  - bin/test_launcher
76
- - bin/test_runner
77
55
  - lib/test_launcher.rb
78
- - lib/test_launcher/searchers/git_searcher.rb
56
+ - lib/test_launcher/cli/input_parser.rb
57
+ - lib/test_launcher/frameworks.rb
58
+ - lib/test_launcher/frameworks/base.rb
59
+ - lib/test_launcher/frameworks/implementation/collection.rb
60
+ - lib/test_launcher/frameworks/implementation/consolidator.rb
61
+ - lib/test_launcher/frameworks/implementation/locator.rb
62
+ - lib/test_launcher/frameworks/implementation/test_case.rb
63
+ - lib/test_launcher/frameworks/minitest.rb
64
+ - lib/test_launcher/frameworks/rspec.rb
65
+ - lib/test_launcher/rubymine.rb
66
+ - lib/test_launcher/rubymine/launcher.rb
67
+ - lib/test_launcher/search/git.rb
79
68
  - lib/test_launcher/shell/color.rb
80
69
  - lib/test_launcher/shell/runner.rb
81
- - lib/test_launcher/tests/minitest/consolidator.rb
82
- - lib/test_launcher/tests/minitest/finder.rb
83
- - lib/test_launcher/tests/minitest/wrappers/multiple_files.rb
84
- - lib/test_launcher/tests/minitest/wrappers/multiple_roots.rb
85
- - lib/test_launcher/tests/minitest/wrappers/single_file.rb
86
- - lib/test_launcher/tests/minitest/wrappers/single_root.rb
87
- - lib/test_launcher/tests/minitest/wrappers/single_test.rb
88
- - lib/test_launcher/utils/path.rb
89
- - lib/test_launcher/utils/pluralize.rb
90
70
  - lib/test_launcher/version.rb
71
+ - test/install
91
72
  - test/test_helper.rb
92
- - test/test_launcher/searchers/git_searcher_test.rb
93
- - test/test_launcher/tests/minitest/consolidator_integration_test.rb
94
- - test/test_launcher/tests/minitest/finder_test.rb
73
+ - test/test_launcher/fixtures/minitest/test/class_1_test.rb
74
+ - test/test_launcher/fixtures/minitest/test/class_2_test.rb
75
+ - test/test_launcher/fixtures/minitest/test/different_root/bin/spring
76
+ - test/test_launcher/fixtures/minitest/test/different_root/test/different_root_test.rb
77
+ - test/test_launcher/fixtures/rspec/spec/class_1_spec.rb
78
+ - test/test_launcher/fixtures/rspec/spec/class_2_spec.rb
79
+ - test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb
80
+ - test/test_launcher/minitest_integration_test.rb
81
+ - test/test_launcher/rspec_integration_test.rb
82
+ - test/test_launcher/rubymine_test.rb
95
83
  - test_launcher.gemspec
96
- homepage: ''
84
+ homepage: http://github.com/petekinnecom/test_launcher
97
85
  licenses:
98
86
  - MIT
99
87
  metadata: {}
@@ -113,13 +101,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
101
  version: '0'
114
102
  requirements: []
115
103
  rubyforge_project:
116
- rubygems_version: 2.4.3
104
+ rubygems_version: 2.4.5.1
117
105
  signing_key:
118
106
  specification_version: 4
119
107
  summary: Easily run tests
120
108
  test_files:
109
+ - test/install
121
110
  - test/test_helper.rb
122
- - test/test_launcher/searchers/git_searcher_test.rb
123
- - test/test_launcher/tests/minitest/consolidator_integration_test.rb
124
- - test/test_launcher/tests/minitest/finder_test.rb
125
- has_rdoc:
111
+ - test/test_launcher/fixtures/minitest/test/class_1_test.rb
112
+ - test/test_launcher/fixtures/minitest/test/class_2_test.rb
113
+ - test/test_launcher/fixtures/minitest/test/different_root/bin/spring
114
+ - test/test_launcher/fixtures/minitest/test/different_root/test/different_root_test.rb
115
+ - test/test_launcher/fixtures/rspec/spec/class_1_spec.rb
116
+ - test/test_launcher/fixtures/rspec/spec/class_2_spec.rb
117
+ - test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb
118
+ - test/test_launcher/minitest_integration_test.rb
119
+ - test/test_launcher/rspec_integration_test.rb
120
+ - test/test_launcher/rubymine_test.rb
@@ -1 +0,0 @@
1
- puts "`test_runner` no longer exists. Please use `test_launcher` instead (update any aliases you may have)"
@@ -1,38 +0,0 @@
1
- module TestLauncher
2
- module Searchers
3
- class GitSearcher < Struct.new(:shell)
4
-
5
- def find_files(pattern)
6
- shell.run("git ls-files '*#{pattern}*'")
7
- end
8
-
9
- def grep(regex, file_pattern: '*')
10
- results = shell.run("git grep --untracked '#{regex}' -- '#{file_pattern}'")
11
- results.map do |result|
12
- interpret_grep_result(result)
13
- end
14
- end
15
-
16
- private
17
-
18
- def interpret_grep_result(grep_result)
19
- splits = grep_result.split(/:/)
20
- file = splits.shift.strip
21
- # we rejoin on ':' because our
22
- # code may have colons inside of it.
23
- #
24
- # example:
25
- # path/to/file: run_method(a: A, b: B)
26
- #
27
- # so shift the first one out, then
28
- # rejoin the rest
29
- line = splits.join(':').strip
30
-
31
- {
32
- :file => file,
33
- :line => line,
34
- }
35
- end
36
- end
37
- end
38
- end
@@ -1,50 +0,0 @@
1
- require "test_launcher/searchers/git_searcher"
2
-
3
- module TestLauncher
4
- module Tests
5
- module Minitest
6
- class Finder < Struct.new(:query, :searcher)
7
-
8
- def self.find(query, searcher)
9
- new(query, searcher).find
10
- end
11
-
12
- def find
13
- return tests_found_by_absolute_path if query.match(/^\//)
14
-
15
- return tests_found_by_name unless tests_found_by_name.empty?
16
-
17
- return tests_found_by_file_name unless tests_found_by_file_name.empty?
18
-
19
- return tests_found_by_full_regex unless tests_found_by_full_regex.empty?
20
-
21
- []
22
- end
23
-
24
- private
25
-
26
- def tests_found_by_absolute_path
27
- relative_file_path = query.sub(Dir.pwd, '').sub(/^\//, '')
28
- [ {file: relative_file_path} ]
29
- end
30
-
31
- def tests_found_by_name
32
- @tests_found_by_name ||= full_regex_search("^\s*def .*#{query}.*")
33
- end
34
-
35
- def tests_found_by_file_name
36
- @tests_found_by_file_name ||= searcher.find_files(query).select { |f| f.match(/_test\.rb/) }.map {|f| {file: f} }
37
- end
38
-
39
- def tests_found_by_full_regex
40
- # we ignore the matched line since we don't know what to do with it
41
- @tests_found_by_full_regex ||= full_regex_search(query).map {|t| {file: t[:file]} }
42
- end
43
-
44
- def full_regex_search(regex)
45
- searcher.grep(regex, file_pattern: '*_test.rb')
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,23 +0,0 @@
1
- require "test_launcher/tests/minitest/wrappers/single_root"
2
- require "test_launcher/tests/minitest/wrappers/multiple_roots"
3
-
4
- module TestLauncher
5
- module Tests
6
- module Minitest
7
- module Wrappers
8
- module MultipleFiles
9
-
10
- def self.wrap(files, shell)
11
- wrapper = MultipleRoots.new(files, shell)
12
-
13
- if wrapper.roots.size > 1
14
- wrapper
15
- else
16
- wrapper.roots.first
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,23 +0,0 @@
1
- require "test_launcher/utils/path"
2
-
3
- module TestLauncher
4
- module Tests
5
- module Minitest
6
- module Wrappers
7
- class MultipleRoots
8
-
9
- attr_reader :roots, :shell
10
-
11
- def initialize(files, shell)
12
- @shell = shell
13
- @roots = files.map {|f| SingleFile.new(f)}.group_by {|f| f.app_root}.map {|root, _files| SingleRoot.new(_files, shell)}
14
- end
15
-
16
- def to_command
17
- roots.map(&:to_command).join("; cd -;\n\n")
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,29 +0,0 @@
1
- require "test_launcher/utils/path"
2
-
3
- module TestLauncher
4
- module Tests
5
- module Minitest
6
- module Wrappers
7
- class SingleFile < Struct.new(:file)
8
-
9
- def to_command
10
- %{cd #{File.join(app_root)} && ruby -I test #{File.join(relative_test_path)}}
11
- end
12
-
13
- def app_root
14
- exploded_path = Utils::Path.split(file)
15
-
16
- path = exploded_path[0...exploded_path.rindex("test")]
17
- File.join(path)
18
- end
19
-
20
- def relative_test_path
21
- exploded_path = Utils::Path.split(file)
22
- path = exploded_path[exploded_path.rindex("test")..-1]
23
- File.join(path)
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,27 +0,0 @@
1
- require "test_launcher/utils/path"
2
-
3
- module TestLauncher
4
- module Tests
5
- module Minitest
6
- module Wrappers
7
- class SingleRoot
8
-
9
- attr_reader :files, :shell
10
-
11
- def initialize(files, shell)
12
- @shell = shell
13
- @files = files.map {|f| f.is_a?(SingleFile) ? f : SingleFile.new(f)}
14
- end
15
-
16
- def to_command
17
- %{cd #{app_root} && ruby -I test -e 'ARGV.each { |file| require(Dir.pwd + "/" + file) }' #{files.map(&:relative_test_path).join(" ")}}
18
- end
19
-
20
- def app_root
21
- files.first.app_root
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,37 +0,0 @@
1
- require "test_launcher/utils/path"
2
-
3
- module TestLauncher
4
- module Tests
5
- module Minitest
6
- module Wrappers
7
- class SingleTest
8
-
9
- attr_reader :file, :name
10
- private :file, :name
11
-
12
- def initialize(file:, line:)
13
- @file = file
14
- @name = line[/\s*def\s+(.*)/, 1]
15
- end
16
-
17
- def to_command
18
- %{cd #{app_root} && ruby -I test #{relative_test_path} --name=/#{name}/}
19
- end
20
-
21
- def app_root
22
- exploded_path = Utils::Path.split(file)
23
-
24
- path = exploded_path[0...exploded_path.rindex("test")]
25
- File.join(path)
26
- end
27
-
28
- def relative_test_path
29
- exploded_path = Utils::Path.split(file)
30
- path = exploded_path[exploded_path.rindex("test")..-1]
31
- File.join(path)
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,32 +0,0 @@
1
- require "pathname"
2
-
3
- module TestLauncher
4
- module Utils
5
- module Path
6
-
7
- def self.split(filename)
8
- self.prepend_pwd(Pathname.new(filename).each_filename.to_a)
9
- end
10
-
11
- def self.path_for(filename)
12
- self.split(File.split(file)[0])
13
- end
14
-
15
- def self.join(*array)
16
- File.join(*array)
17
- end
18
-
19
- def self.prepend_pwd(dirs)
20
- if dirs[0] == "."
21
- dirs
22
- else
23
- ["."] + dirs
24
- end
25
- end
26
-
27
- def self.relative_join(array)
28
- join(prepend_pwd(array))
29
- end
30
- end
31
- end
32
- end
@@ -1,14 +0,0 @@
1
- module TestLauncher
2
- module Utils
3
- module Pluralize
4
- def pluralize(count, singular)
5
- phrase = "#{count} #{singular}"
6
- if count == 1
7
- phrase
8
- else
9
- "#{phrase}s"
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,50 +0,0 @@
1
- require "test_helper"
2
- require "test_launcher/searchers/git_searcher"
3
-
4
- module TestLauncher
5
- module Searchers
6
- class MockShell
7
- def run(cmd)
8
- if cmd == "git ls-files '*file_pattern*'"
9
- [
10
- "file/path/one.rb",
11
- "another_file/path/two.rb",
12
- ]
13
- elsif cmd == "git grep --untracked 'regex' -- 'file_pattern'"
14
- [
15
- "file/path/one.rb: some_lines(of_code)",
16
- "another_file/path/two.rb: Class::Thing::Stuff.new",
17
- ]
18
- else
19
- raise ArgumentError.new("unmocked command")
20
- end
21
- end
22
- end
23
-
24
- class GitSearcherTest < TestCase
25
-
26
- def test_find_files
27
- searcher = GitSearcher.new(MockShell.new)
28
-
29
- assert_equal ["file/path/one.rb", "another_file/path/two.rb"], searcher.find_files("file_pattern")
30
- end
31
-
32
- def test_grep
33
- searcher = GitSearcher.new(MockShell.new)
34
-
35
- expected = [
36
- {
37
- file: "file/path/one.rb",
38
- line: "some_lines(of_code)",
39
- },
40
- {
41
- file: "another_file/path/two.rb",
42
- line: "Class::Thing::Stuff.new",
43
- }
44
- ]
45
-
46
- assert_equal expected, searcher.grep("regex", file_pattern: "file_pattern")
47
- end
48
- end
49
- end
50
- end