koine-test_runner 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -2
- data/.travis.yml +1 -0
- data/README.md +14 -13
- data/koine-test_runner.gemspec +2 -1
- data/lib/koine/test_runner/adapters/base_adapter.rb +1 -3
- data/lib/koine/test_runner/adapters/{base_regexp_adapter.rb → base_regexp.rb} +1 -1
- data/lib/koine/test_runner/adapters/custom.rb +41 -0
- data/lib/koine/test_runner/adapters/{last_command_adapter.rb → last_command.rb} +1 -1
- data/lib/koine/test_runner/adapters/{null_adapter.rb → null.rb} +1 -1
- data/lib/koine/test_runner/adapters/phpunit.rb +1 -1
- data/lib/koine/test_runner/adapters/rspec.rb +1 -1
- data/lib/koine/test_runner/adapters.rb +2 -2
- data/lib/koine/test_runner/builder.rb +9 -4
- data/lib/koine/test_runner/configuration.rb +1 -1
- data/lib/koine/test_runner/file_matcher.rb +2 -2
- data/lib/koine/test_runner/version.rb +1 -1
- data/lib/koine/test_runner.rb +4 -3
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3afa12768cac1b4e38bc04ca4a126bfca0820a6ebf177afd7b3a1c5c4bb4aa43
|
4
|
+
data.tar.gz: 5e7d634096d91b84989f27eda80fd6478e49269ff16043555f106dd84ccde05a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 160955b9b2280d0de4b90f26641a89c46537390c43bbab4eddc426fbced9180582bfe46c304b339eedee3c5e17075a5034481709b0b2762f413b816b349f372c
|
7
|
+
data.tar.gz: d77b6ccc215804d6f5a664fcbc69e0c5239fede453045da085c9110bf2bb8c60ab91b3a8c08fa8494867ad2c91747f5fa2578b7fc9a35c286cd2579e34c946bd
|
data/.rubocop.yml
CHANGED
@@ -18,13 +18,16 @@ Metrics/MethodLength:
|
|
18
18
|
Metrics/CyclomaticComplexity:
|
19
19
|
Max: 7
|
20
20
|
|
21
|
+
Style/SpecialGlobalVars:
|
22
|
+
Enabled: false
|
23
|
+
|
21
24
|
Style/GuardClause:
|
22
25
|
Enabled: false
|
23
26
|
|
24
27
|
Style/IfUnlessModifier:
|
25
28
|
Enabled: false
|
26
29
|
|
27
|
-
|
30
|
+
Naming/PredicateName:
|
28
31
|
NamePrefix:
|
29
32
|
- is_
|
30
33
|
- has_
|
@@ -46,5 +49,5 @@ AllCops:
|
|
46
49
|
Exclude:
|
47
50
|
- Gemfile
|
48
51
|
|
49
|
-
|
52
|
+
Layout/ExtraSpacing:
|
50
53
|
AllowForAlignment: true
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -43,27 +43,28 @@ bundle exec run_test some/file_spec.custom
|
|
43
43
|
# .test_runner.yml
|
44
44
|
|
45
45
|
adapters:
|
46
|
-
minitest:
|
47
|
-
adapter: Koine\TestRunner\Adapter\Ruby\Minitest
|
48
|
-
file_pattern: "*_test.rb"
|
49
|
-
|
50
46
|
rspec:
|
51
|
-
adapter:
|
47
|
+
adapter: rspec
|
52
48
|
file_pattern: "*_spec.rb"
|
53
49
|
|
54
50
|
phpunit:
|
55
|
-
adapter:
|
51
|
+
adapter: phpunit
|
56
52
|
file_pattern: "*Test.php"
|
57
53
|
|
58
|
-
codeception:
|
59
|
-
adapter: Koine\TestRunner\Adapter\Php\Codeception
|
60
|
-
file_pattern: "*Spec.php"
|
61
|
-
|
62
54
|
jest:
|
63
|
-
adapter:
|
64
|
-
file_pattern: "
|
65
|
-
|
55
|
+
adapter: custom
|
56
|
+
file_pattern: "client/.*.spec.js"
|
57
|
+
command: "./node_modules/.bin/jest"
|
58
|
+
commands:
|
59
|
+
all: "{command}"
|
60
|
+
file: "{command} {file}"
|
61
|
+
# oops, jest does not really filter by line
|
62
|
+
line: "{command} {file}"
|
63
|
+
|
64
|
+
# TODO
|
66
65
|
My::CustoAdapter:
|
66
|
+
require:
|
67
|
+
- some/file
|
67
68
|
adapter: MyCustomAdapter
|
68
69
|
suffix: '_spec.custom'
|
69
70
|
```
|
data/koine-test_runner.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path('
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
|
4
4
|
require 'koine/test_runner'
|
@@ -35,5 +35,6 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency 'object_comparator', '~> 0.1.3'
|
36
36
|
spec.add_development_dependency 'rake', '~> 10.0'
|
37
37
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
+
spec.add_development_dependency 'rubocop', '~> 0.53.0'
|
38
39
|
spec.add_development_dependency 'simplecov', '~> 0.14.1'
|
39
40
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class Adapters
|
4
|
+
class Custom < BaseRegexp
|
5
|
+
def initialize(file_pattern:, command: nil, commands: {})
|
6
|
+
super(file_pattern: file_pattern)
|
7
|
+
@command = command
|
8
|
+
@commands = {}.tap do |hash|
|
9
|
+
commands.each do |key, value|
|
10
|
+
hash[key.to_sym] = value
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def all_tests(config)
|
18
|
+
command(command_for(:all), config)
|
19
|
+
end
|
20
|
+
|
21
|
+
def single_file_command(config)
|
22
|
+
command(command_for(:file), config)
|
23
|
+
end
|
24
|
+
|
25
|
+
def file_line_command(config)
|
26
|
+
command(command_for(:line), config)
|
27
|
+
end
|
28
|
+
|
29
|
+
def command_for(type)
|
30
|
+
@commands.fetch(type).to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
def command(template, config)
|
34
|
+
template.sub('{command}', @command)
|
35
|
+
.sub('{file}', config.file_path.to_s)
|
36
|
+
.sub('{line}', config.line.to_s)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Koine
|
2
2
|
class TestRunner
|
3
3
|
class Adapters
|
4
|
-
def initialize(adapters = [], fallback:
|
4
|
+
def initialize(adapters = [], fallback: LastCommand.new)
|
5
5
|
adapters = adapters.dup
|
6
6
|
|
7
7
|
adapters.unshift(fallback)
|
8
|
-
adapters.push(Adapters::
|
8
|
+
adapters.push(Adapters::Null.new)
|
9
9
|
|
10
10
|
adapters.inject do |previous, adapter|
|
11
11
|
previous.next_adapter = adapter
|
@@ -22,20 +22,25 @@ module Koine
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def build_adapter(config)
|
25
|
-
|
25
|
+
adapter_name = config.delete('adapter')
|
26
|
+
adapter_class = adapter_name
|
26
27
|
|
27
|
-
if
|
28
|
-
adapter_class = "Koine::TestRunner::Adapters::#{
|
28
|
+
if adapter_class.downcase == adapter_class.to_s
|
29
|
+
adapter_class = "Koine::TestRunner::Adapters::#{classify(adapter_class)}"
|
29
30
|
end
|
30
31
|
|
31
32
|
unless Object.const_defined?(adapter_class)
|
32
|
-
raise ArgumentError, "Cannot locate adapter #{
|
33
|
+
raise ArgumentError, "Cannot locate adapter #{adapter_name} => #{adapter_class}"
|
33
34
|
end
|
34
35
|
|
35
36
|
klass = Object.const_get(adapter_class)
|
36
37
|
klass.new(symbolize_keys(config))
|
37
38
|
end
|
38
39
|
|
40
|
+
def classify(klass)
|
41
|
+
klass.to_s.split('_').map(&:capitalize).join('')
|
42
|
+
end
|
43
|
+
|
39
44
|
def symbolize_keys(hash)
|
40
45
|
{}.tap do |new_hash|
|
41
46
|
hash.each do |key, value|
|
@@ -27,7 +27,7 @@ module Koine
|
|
27
27
|
def config_file
|
28
28
|
return @options[:config_file] if @options[:config_file]
|
29
29
|
return '.test_runner.yml' if File.exist?('.test_runner.yml')
|
30
|
-
File.expand_path('
|
30
|
+
File.expand_path('../../../config/default.yml', __dir__)
|
31
31
|
end
|
32
32
|
|
33
33
|
def run_options
|
@@ -11,8 +11,8 @@ module Koine
|
|
11
11
|
length = @lines.length
|
12
12
|
slice = length - line
|
13
13
|
lines = @lines.reverse.slice(slice, length)
|
14
|
-
lines.each do |
|
15
|
-
match = regexp.match(
|
14
|
+
lines.each do |file_line|
|
15
|
+
match = regexp.match(file_line)
|
16
16
|
return match if match
|
17
17
|
end
|
18
18
|
|
data/lib/koine/test_runner.rb
CHANGED
@@ -4,15 +4,16 @@ require 'koine/test_runner/configuration'
|
|
4
4
|
require 'koine/test_runner/builder'
|
5
5
|
require 'koine/test_runner/adapters'
|
6
6
|
require 'koine/test_runner/adapters/base_adapter'
|
7
|
-
require 'koine/test_runner/adapters/
|
8
|
-
require 'koine/test_runner/adapters/
|
7
|
+
require 'koine/test_runner/adapters/base_regexp'
|
8
|
+
require 'koine/test_runner/adapters/custom'
|
9
|
+
require 'koine/test_runner/adapters/null'
|
10
|
+
require 'koine/test_runner/adapters/last_command'
|
9
11
|
|
10
12
|
module Koine
|
11
13
|
class TestRunner
|
12
14
|
autoload :FileMatcher, 'koine/test_runner/file_matcher'
|
13
15
|
|
14
16
|
class Adapters
|
15
|
-
autoload :BaseRegexpAdapter, 'koine/test_runner/adapters/base_regexp_adapter'
|
16
17
|
autoload :Rspec, 'koine/test_runner/adapters/rspec'
|
17
18
|
autoload :Phpunit, 'koine/test_runner/adapters/phpunit'
|
18
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koine-test_runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Jacobus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.53.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.53.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: simplecov
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,9 +134,10 @@ files:
|
|
120
134
|
- lib/koine/test_runner.rb
|
121
135
|
- lib/koine/test_runner/adapters.rb
|
122
136
|
- lib/koine/test_runner/adapters/base_adapter.rb
|
123
|
-
- lib/koine/test_runner/adapters/
|
124
|
-
- lib/koine/test_runner/adapters/
|
125
|
-
- lib/koine/test_runner/adapters/
|
137
|
+
- lib/koine/test_runner/adapters/base_regexp.rb
|
138
|
+
- lib/koine/test_runner/adapters/custom.rb
|
139
|
+
- lib/koine/test_runner/adapters/last_command.rb
|
140
|
+
- lib/koine/test_runner/adapters/null.rb
|
126
141
|
- lib/koine/test_runner/adapters/phpunit.rb
|
127
142
|
- lib/koine/test_runner/adapters/rspec.rb
|
128
143
|
- lib/koine/test_runner/builder.rb
|