koine-test_runner 0.1.0.pre.delete → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +50 -0
- data/.travis.yml +10 -1
- data/README.md +20 -14
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/config/default.yml +16 -0
- data/exe/run_test +9 -0
- data/integration_test.sh +9 -0
- data/koine-test_runner.gemspec +19 -19
- data/lib/koine/test_runner.rb +33 -2
- data/lib/koine/test_runner/adapters.rb +23 -0
- data/lib/koine/test_runner/adapters/base_adapter.rb +55 -0
- data/lib/koine/test_runner/adapters/base_regexp_adapter.rb +17 -0
- data/lib/koine/test_runner/adapters/last_command_adapter.rb +44 -0
- data/lib/koine/test_runner/adapters/null_adapter.rb +11 -0
- data/lib/koine/test_runner/adapters/phpunit.rb +37 -0
- data/lib/koine/test_runner/adapters/rspec.rb +19 -0
- data/lib/koine/test_runner/builder.rb +48 -0
- data/lib/koine/test_runner/command_executer.rb +20 -0
- data/lib/koine/test_runner/configuration.rb +70 -0
- data/lib/koine/test_runner/file_matcher.rb +23 -0
- data/lib/koine/test_runner/version.rb +2 -2
- data/tests/integration_tests.sh +12 -0
- metadata +49 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9ec65d3c6a1db49c56ceea5afb66ee6b8398f3a94849e2833c7d547eb44ae735
|
4
|
+
data.tar.gz: d68aced56021535a0ba39c885903f4a2e5d498781e361540594cded8ff70093b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d923060a8fa002b2355e0bce237c714896bc5cdb3093b68adab680e12584e25f017097212864419f4770cb920d1998f3ac9b419ee42f9c694c762df3e6248ac
|
7
|
+
data.tar.gz: fde040a024de8232e46eea1db6f27e29e1bc2c1ccb473ac4dc1d1faae9a6b1291b615bdafe2fe5173f771c432c4440fff3ee98e8d01f70c995dc1b0d5e61c368
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
Lint/AmbiguousBlockAssociation:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Metrics/BlockLength:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Max: 100
|
9
|
+
|
10
|
+
Metrics/ClassLength:
|
11
|
+
CountComments: false
|
12
|
+
Max: 250
|
13
|
+
|
14
|
+
Metrics/MethodLength:
|
15
|
+
CountComments: false
|
16
|
+
Max: 30
|
17
|
+
|
18
|
+
Metrics/CyclomaticComplexity:
|
19
|
+
Max: 7
|
20
|
+
|
21
|
+
Style/GuardClause:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/IfUnlessModifier:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/PredicateName:
|
28
|
+
NamePrefix:
|
29
|
+
- is_
|
30
|
+
- has_
|
31
|
+
|
32
|
+
NamePrefixBlacklist:
|
33
|
+
- is_
|
34
|
+
- has_
|
35
|
+
|
36
|
+
Metrics/AbcSize:
|
37
|
+
Max: 45
|
38
|
+
|
39
|
+
Metrics/PerceivedComplexity:
|
40
|
+
Max: 10
|
41
|
+
|
42
|
+
Documentation:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
AllCops:
|
46
|
+
Exclude:
|
47
|
+
- Gemfile
|
48
|
+
|
49
|
+
Style/ExtraSpacing:
|
50
|
+
AllowForAlignment: true
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,8 @@
|
|
2
2
|
|
3
3
|
Easy test runner customization
|
4
4
|
|
5
|
-
[![Build Status](https://travis-ci.org/mjacobus/test_runner.svg?branch=master)](https://travis-ci.org/mjacobus/
|
5
|
+
[![Build Status](https://travis-ci.org/mjacobus/test_runner.svg?branch=master)](https://travis-ci.org/mjacobus/test_runner)
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/github/mjacobus/test_runner/badge.svg?branch=master)](https://coveralls.io/github/mjacobus/test_runner?branch=master)
|
7
|
-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mjacobus/test_runner/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mjacobus/test_runner/?branch=master)
|
8
7
|
[![Code Climate](https://codeclimate.com/github/mjacobus/test_runner/badges/gpa.svg)](https://codeclimate.com/github/mjacobus/test_runner)
|
9
8
|
[![Issue Count](https://codeclimate.com/github/mjacobus/test_runner/badges/issue_count.svg)](https://codeclimate.com/github/mjacobus/test_runner)
|
10
9
|
|
@@ -34,7 +33,7 @@ bundle exec run_test some/file_spec.rb --line=55
|
|
34
33
|
bundle exec run_test some/file.php
|
35
34
|
|
36
35
|
# unknown file
|
37
|
-
bundle exec run_test some/file_spec.custom
|
36
|
+
bundle exec run_test some/file_spec.custom
|
38
37
|
# => error: No test runner found for file 'some/file_spec.custom'
|
39
38
|
```
|
40
39
|
|
@@ -76,18 +75,11 @@ module My
|
|
76
75
|
@suffix = suffix
|
77
76
|
end
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
def test_command_for_file(file_path: line: nil)
|
84
|
-
cmd = ["/usr/bin/my_test --file=#{file_path}"]
|
85
|
-
|
86
|
-
if line
|
87
|
-
cmd << "--line=#{line}"
|
78
|
+
# return nil if you do not want to deal with it
|
79
|
+
def test_command(config)
|
80
|
+
if config.file_path.end_with?(@suffix)
|
81
|
+
return "./bin/test #{config.file_path}"
|
88
82
|
end
|
89
|
-
|
90
|
-
cmd.join(' ')
|
91
83
|
end
|
92
84
|
end
|
93
85
|
end
|
@@ -99,6 +91,20 @@ Now you can run:
|
|
99
91
|
bundle exec run_test some/file_spec.custom
|
100
92
|
```
|
101
93
|
|
94
|
+
## Running the last test
|
95
|
+
|
96
|
+
Either run a file that does not get caught by any adapter
|
97
|
+
|
98
|
+
```bash
|
99
|
+
bundle exec run_test some/file_spec.unkown # run last test
|
100
|
+
```
|
101
|
+
|
102
|
+
Or
|
103
|
+
|
104
|
+
```bash
|
105
|
+
bundle exec run_test --last
|
106
|
+
```
|
107
|
+
|
102
108
|
## Development
|
103
109
|
|
104
110
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'test_runner'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "test_runner"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/config/default.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
adapters:
|
2
|
+
rspec:
|
3
|
+
adapter: rspec
|
4
|
+
file_pattern: ".*_spec.rb$"
|
5
|
+
|
6
|
+
phpunit:
|
7
|
+
adapter: phpunit
|
8
|
+
file_pattern: ".*Test.php$"
|
9
|
+
#
|
10
|
+
# codeception:
|
11
|
+
# adapter: Koine\TestRunner\Adapter\Php\Codeception
|
12
|
+
# file_pattern: "*Spec.php"
|
13
|
+
#
|
14
|
+
# jest:
|
15
|
+
# adapter: Koine\TestRunner\Adapter\Javascript\Jest
|
16
|
+
# file_pattern: "*_(test|spec).(js|jsx)"
|
data/exe/run_test
ADDED
data/integration_test.sh
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
set -v
|
5
|
+
|
6
|
+
./exe/run_test spec/fixtures/FixturePhpUnitTest.php --line=30
|
7
|
+
./exe/run_test spec/koine/test_runner_spec.rb
|
8
|
+
./exe/run_test spec/koine/test_runner_spec.rb --line=9
|
9
|
+
./exe/run_test spec/koine/test_runner_spec.rb --all
|
data/koine-test_runner.gemspec
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
|
5
4
|
require 'koine/test_runner'
|
6
5
|
|
7
6
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
7
|
+
spec.name = 'koine-test_runner'
|
9
8
|
spec.version = TestRunner::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
9
|
+
spec.authors = ['Marcelo Jacobus']
|
10
|
+
spec.email = ['marcelo.jacobus@gmail.com']
|
12
11
|
|
13
|
-
spec.summary =
|
14
|
-
spec.description =
|
15
|
-
spec.homepage =
|
16
|
-
spec.license =
|
12
|
+
spec.summary = 'Easy test runner'
|
13
|
+
spec.description = 'Easy test runner'
|
14
|
+
spec.homepage = 'https://github.com/mjacobus/test_runner'
|
15
|
+
spec.license = 'MIT'
|
17
16
|
|
18
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
19
|
if spec.respond_to?(:metadata)
|
21
|
-
spec.metadata['allowed_push_host'] =
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
22
21
|
else
|
23
|
-
raise
|
24
|
-
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
25
24
|
end
|
26
25
|
|
27
|
-
spec.files
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
28
27
|
f.match(%r{^(test|spec|features)/})
|
29
28
|
end
|
30
|
-
spec.bindir =
|
29
|
+
spec.bindir = 'exe'
|
31
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
-
spec.require_paths = [
|
31
|
+
spec.require_paths = ['lib']
|
33
32
|
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
38
|
-
spec.add_development_dependency
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
34
|
+
spec.add_development_dependency 'coveralls', '~> 0.8.21'
|
35
|
+
spec.add_development_dependency 'object_comparator', '~> 0.1.3'
|
36
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
37
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
+
spec.add_development_dependency 'simplecov', '~> 0.14.1'
|
39
39
|
end
|
data/lib/koine/test_runner.rb
CHANGED
@@ -1,4 +1,35 @@
|
|
1
|
-
require
|
1
|
+
require 'koine/test_runner/version'
|
2
|
+
require 'koine/test_runner/command_executer'
|
3
|
+
require 'koine/test_runner/configuration'
|
4
|
+
require 'koine/test_runner/builder'
|
5
|
+
require 'koine/test_runner/adapters'
|
6
|
+
require 'koine/test_runner/adapters/base_adapter'
|
7
|
+
require 'koine/test_runner/adapters/null_adapter'
|
8
|
+
require 'koine/test_runner/adapters/last_command_adapter'
|
2
9
|
|
3
|
-
module
|
10
|
+
module Koine
|
11
|
+
class TestRunner
|
12
|
+
autoload :FileMatcher, 'koine/test_runner/file_matcher'
|
13
|
+
|
14
|
+
class Adapters
|
15
|
+
autoload :BaseRegexpAdapter, 'koine/test_runner/adapters/base_regexp_adapter'
|
16
|
+
autoload :Rspec, 'koine/test_runner/adapters/rspec'
|
17
|
+
autoload :Phpunit, 'koine/test_runner/adapters/phpunit'
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(adapters = [])
|
21
|
+
@adapters = Adapters.new(adapters)
|
22
|
+
end
|
23
|
+
|
24
|
+
def run(configuration)
|
25
|
+
test_command = @adapters.test_command(configuration)
|
26
|
+
executer = CommandExecuter.new
|
27
|
+
|
28
|
+
if test_command
|
29
|
+
return executer.execute_and_exit(test_command)
|
30
|
+
end
|
31
|
+
|
32
|
+
executer.fail('No tests run')
|
33
|
+
end
|
34
|
+
end
|
4
35
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class Adapters
|
4
|
+
def initialize(adapters = [], fallback: LastCommandAdapter.new)
|
5
|
+
adapters = adapters.dup
|
6
|
+
|
7
|
+
adapters.unshift(fallback)
|
8
|
+
adapters.push(Adapters::NullAdapter.new)
|
9
|
+
|
10
|
+
adapters.inject do |previous, adapter|
|
11
|
+
previous.next_adapter = adapter
|
12
|
+
adapter
|
13
|
+
end
|
14
|
+
|
15
|
+
@chain = adapters.first
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_command(config)
|
19
|
+
@chain.test_command(config)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class Adapters
|
4
|
+
class BaseAdapter
|
5
|
+
# attr_writer :next_adapter
|
6
|
+
|
7
|
+
def next_adapter=(adapter)
|
8
|
+
@next_adapter = adapter
|
9
|
+
end
|
10
|
+
|
11
|
+
def next_adapter
|
12
|
+
@next_adapter || raise("next_adapter is not set for #{self.class}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_command(config)
|
16
|
+
unless accept?(config)
|
17
|
+
return next_adapter.test_command(config)
|
18
|
+
end
|
19
|
+
|
20
|
+
if config.all?
|
21
|
+
return all_tests(config)
|
22
|
+
end
|
23
|
+
|
24
|
+
if config.line?
|
25
|
+
return file_line_command(config)
|
26
|
+
end
|
27
|
+
|
28
|
+
single_file_command(config)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def accept?(_config)
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
def all_tests(config)
|
38
|
+
script_for(config)
|
39
|
+
end
|
40
|
+
|
41
|
+
def file_line_command(config)
|
42
|
+
[single_file_command(config), config.line].join(':')
|
43
|
+
end
|
44
|
+
|
45
|
+
def single_file_command(config)
|
46
|
+
[script_for(config), config.file_path].join(' ')
|
47
|
+
end
|
48
|
+
|
49
|
+
def script_for(_config)
|
50
|
+
raise 'Not implemented'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class Adapters
|
4
|
+
class BaseRegexpAdapter < BaseAdapter
|
5
|
+
def initialize(file_pattern:)
|
6
|
+
@file_pattern = file_pattern.is_a?(Regexp) ? file_pattern : Regexp.new(file_pattern)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def accept?(config)
|
12
|
+
!@file_pattern.match(config.file_path).nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class Adapters
|
4
|
+
class LastCommandAdapter < BaseAdapter
|
5
|
+
def initialize(storage: Storage.new)
|
6
|
+
@storage = storage
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_command(config)
|
10
|
+
command = next_adapter.test_command(config)
|
11
|
+
|
12
|
+
unless command
|
13
|
+
return @storage.retrieve
|
14
|
+
end
|
15
|
+
|
16
|
+
@storage.store(command)
|
17
|
+
command
|
18
|
+
end
|
19
|
+
|
20
|
+
class Storage
|
21
|
+
def initialize(file_path: '.cache/koine/last-test-command.cache')
|
22
|
+
@file_path = file_path
|
23
|
+
end
|
24
|
+
|
25
|
+
def retrieve
|
26
|
+
if File.exist?(@file_path)
|
27
|
+
File.read(@file_path).strip
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def store(value)
|
32
|
+
folder = File.dirname(@file_path)
|
33
|
+
|
34
|
+
unless File.exist?(folder)
|
35
|
+
FileUtils.mkdir_p(folder)
|
36
|
+
end
|
37
|
+
|
38
|
+
File.open(@file_path, 'w') { |f| f.puts(value) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class Adapters
|
4
|
+
class Phpunit < BaseRegexpAdapter
|
5
|
+
DEFAULT_OPTIONS = [
|
6
|
+
'--color'
|
7
|
+
].freeze
|
8
|
+
|
9
|
+
def initialize(file_pattern: /.*Test.php$/, options: nil)
|
10
|
+
super(file_pattern: file_pattern)
|
11
|
+
@options = Array(options || DEFAULT_OPTIONS)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def file_line_command(config)
|
17
|
+
regexp = /public function ([^\(]+)/
|
18
|
+
matcher = FileMatcher.new(file_path: config.file_path)
|
19
|
+
match = matcher.above_line(config.line, regexp: regexp)[1]
|
20
|
+
[single_file_command(config), '--filter', "'/\\b#{match}\\b/'"].join(' ')
|
21
|
+
end
|
22
|
+
|
23
|
+
def script_for(_config)
|
24
|
+
if File.exist?('vendor/bin/phpunit')
|
25
|
+
return with_options('./vendor/bin/phpunit')
|
26
|
+
end
|
27
|
+
|
28
|
+
with_options('phpunit')
|
29
|
+
end
|
30
|
+
|
31
|
+
def with_options(script)
|
32
|
+
[script, @options].flatten.join(' ')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class Adapters
|
4
|
+
class Rspec < BaseRegexpAdapter
|
5
|
+
def initialize(file_pattern: /.*_spec.rb$/)
|
6
|
+
super(file_pattern: file_pattern)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def script_for(_config)
|
12
|
+
return './bin/rspec' if File.exist?('bin/rspec')
|
13
|
+
|
14
|
+
'bundle exec rspec'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Koine
|
4
|
+
class TestRunner
|
5
|
+
class Builder
|
6
|
+
def initialize(arguments)
|
7
|
+
initialize_from_yaml_config(arguments.config_file)
|
8
|
+
end
|
9
|
+
|
10
|
+
def build
|
11
|
+
TestRunner.new(@adapters)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def initialize_from_yaml_config(config_file)
|
17
|
+
config = YAML.load_file(config_file)
|
18
|
+
|
19
|
+
@adapters = config['adapters'].map do |adapter_config|
|
20
|
+
build_adapter(adapter_config.last)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_adapter(config)
|
25
|
+
adapter = config.delete('adapter')
|
26
|
+
|
27
|
+
if adapter.downcase == adapter.to_s
|
28
|
+
adapter_class = "Koine::TestRunner::Adapters::#{adapter.capitalize}"
|
29
|
+
end
|
30
|
+
|
31
|
+
unless Object.const_defined?(adapter_class)
|
32
|
+
raise ArgumentError, "Cannot locate adapter #{adapter} => #{adapter_class}"
|
33
|
+
end
|
34
|
+
|
35
|
+
klass = Object.const_get(adapter_class)
|
36
|
+
klass.new(symbolize_keys(config))
|
37
|
+
end
|
38
|
+
|
39
|
+
def symbolize_keys(hash)
|
40
|
+
{}.tap do |new_hash|
|
41
|
+
hash.each do |key, value|
|
42
|
+
new_hash[key.to_sym] = value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class CommandExecuter
|
4
|
+
def execute(command)
|
5
|
+
system(command.to_s)
|
6
|
+
$?.exitstatus
|
7
|
+
end
|
8
|
+
|
9
|
+
def fail(reason)
|
10
|
+
puts reason
|
11
|
+
exit(1)
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute_and_exit(command)
|
15
|
+
puts command
|
16
|
+
exit(execute(command))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class Configuration
|
4
|
+
attr_reader :file_path
|
5
|
+
|
6
|
+
def initialize(attributes = [])
|
7
|
+
initialize_options(attributes.dup)
|
8
|
+
initialize_attributes(attributes.dup)
|
9
|
+
end
|
10
|
+
|
11
|
+
def line
|
12
|
+
@options[:line].to_i if line?
|
13
|
+
end
|
14
|
+
|
15
|
+
def line?
|
16
|
+
@options[:line].to_s.tr('true', '').strip != ''
|
17
|
+
end
|
18
|
+
|
19
|
+
def all?
|
20
|
+
@options[:all]
|
21
|
+
end
|
22
|
+
|
23
|
+
def last?
|
24
|
+
@options[:last]
|
25
|
+
end
|
26
|
+
|
27
|
+
def config_file
|
28
|
+
return @options[:config_file] if @options[:config_file]
|
29
|
+
return '.test_runner.yml' if File.exist?('.test_runner.yml')
|
30
|
+
File.expand_path('../../../../config/default.yml', __FILE__)
|
31
|
+
end
|
32
|
+
|
33
|
+
def run_options
|
34
|
+
{ file_path: file_path, line: line }
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def initialize_attributes(arguments)
|
40
|
+
@file_path = arguments.reject { |arg| arg =~ /^--/ }.shift
|
41
|
+
|
42
|
+
if require_file_name? && @file_path.nil?
|
43
|
+
raise ArgumentError, 'file name was not given'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def require_file_name?
|
48
|
+
!last?
|
49
|
+
end
|
50
|
+
|
51
|
+
def initialize_options(data)
|
52
|
+
@options = { all: false }
|
53
|
+
|
54
|
+
data = data.select { |arg| arg =~ /^--([a-z-]+)/ }.map do |arg|
|
55
|
+
arg.split('--').last.split('=')
|
56
|
+
end
|
57
|
+
|
58
|
+
data.each do |values|
|
59
|
+
key = values.first
|
60
|
+
value = values.length == 2 ? values.last : true
|
61
|
+
@options[normalize_key(key)] = value
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def normalize_key(key)
|
66
|
+
key.tr('-', '_').to_sym
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Koine
|
2
|
+
class TestRunner
|
3
|
+
class FileMatcher
|
4
|
+
NoMatchError = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
def initialize(file_path:)
|
7
|
+
@lines = File.readlines(file_path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def above_line(line, regexp:)
|
11
|
+
length = @lines.length
|
12
|
+
slice = length - line
|
13
|
+
lines = @lines.reverse.slice(slice, length)
|
14
|
+
lines.each do |line|
|
15
|
+
match = regexp.match(line)
|
16
|
+
return match if match
|
17
|
+
end
|
18
|
+
|
19
|
+
raise NoMatchError
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION =
|
1
|
+
class TestRunner
|
2
|
+
VERSION = '0.1.1'.freeze
|
3
3
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
set -v
|
5
|
+
|
6
|
+
export SKIP_COVERAGE='true'
|
7
|
+
|
8
|
+
./exe/run_test spec/fixtures/FixturePhpUnitTest.php --line=30
|
9
|
+
./exe/run_test spec/koine/test_runner_spec.rb
|
10
|
+
./exe/run_test spec/koine/test_runner_spec.rb --line=9
|
11
|
+
./exe/run_test spec/koine/test_runner_spec.rb --last
|
12
|
+
./exe/run_test spec/koine/test_runner_spec.rb --all
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Jacobus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,70 +25,86 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.14'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: coveralls
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.8.21
|
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:
|
40
|
+
version: 0.8.21
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: object_comparator
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.1.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.1.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
61
|
+
version: '10.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
68
|
+
version: '10.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '3.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.14.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.14.1
|
83
97
|
description: Easy test runner
|
84
98
|
email:
|
85
99
|
- marcelo.jacobus@gmail.com
|
86
|
-
executables:
|
100
|
+
executables:
|
101
|
+
- run_test
|
87
102
|
extensions: []
|
88
103
|
extra_rdoc_files: []
|
89
104
|
files:
|
90
105
|
- ".gitignore"
|
91
106
|
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
92
108
|
- ".travis.yml"
|
93
109
|
- CODE_OF_CONDUCT.md
|
94
110
|
- Gemfile
|
@@ -97,9 +113,24 @@ files:
|
|
97
113
|
- Rakefile
|
98
114
|
- bin/console
|
99
115
|
- bin/setup
|
116
|
+
- config/default.yml
|
117
|
+
- exe/run_test
|
118
|
+
- integration_test.sh
|
100
119
|
- koine-test_runner.gemspec
|
101
120
|
- lib/koine/test_runner.rb
|
121
|
+
- lib/koine/test_runner/adapters.rb
|
122
|
+
- lib/koine/test_runner/adapters/base_adapter.rb
|
123
|
+
- lib/koine/test_runner/adapters/base_regexp_adapter.rb
|
124
|
+
- lib/koine/test_runner/adapters/last_command_adapter.rb
|
125
|
+
- lib/koine/test_runner/adapters/null_adapter.rb
|
126
|
+
- lib/koine/test_runner/adapters/phpunit.rb
|
127
|
+
- lib/koine/test_runner/adapters/rspec.rb
|
128
|
+
- lib/koine/test_runner/builder.rb
|
129
|
+
- lib/koine/test_runner/command_executer.rb
|
130
|
+
- lib/koine/test_runner/configuration.rb
|
131
|
+
- lib/koine/test_runner/file_matcher.rb
|
102
132
|
- lib/koine/test_runner/version.rb
|
133
|
+
- tests/integration_tests.sh
|
103
134
|
homepage: https://github.com/mjacobus/test_runner
|
104
135
|
licenses:
|
105
136
|
- MIT
|
@@ -116,12 +147,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
147
|
version: '0'
|
117
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
149
|
requirements:
|
119
|
-
- - "
|
150
|
+
- - ">="
|
120
151
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
152
|
+
version: '0'
|
122
153
|
requirements: []
|
123
154
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.6
|
155
|
+
rubygems_version: 2.7.6
|
125
156
|
signing_key:
|
126
157
|
specification_version: 4
|
127
158
|
summary: Easy test runner
|