koine-test_runner 0.1.1 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ec65d3c6a1db49c56ceea5afb66ee6b8398f3a94849e2833c7d547eb44ae735
4
- data.tar.gz: d68aced56021535a0ba39c885903f4a2e5d498781e361540594cded8ff70093b
3
+ metadata.gz: c20c221bf08b63af4131daba570080983aa281b677273ca446c6a641015d4eaa
4
+ data.tar.gz: 7ce54b0e3062d50f020ef82253fd73cd6a93c578609a60c2207b9523cf10b6a2
5
5
  SHA512:
6
- metadata.gz: 2d923060a8fa002b2355e0bce237c714896bc5cdb3093b68adab680e12584e25f017097212864419f4770cb920d1998f3ac9b419ee42f9c694c762df3e6248ac
7
- data.tar.gz: fde040a024de8232e46eea1db6f27e29e1bc2c1ccb473ac4dc1d1faae9a6b1291b615bdafe2fe5173f771c432c4440fff3ee98e8d01f70c995dc1b0d5e61c368
6
+ metadata.gz: 979398dc02a77d09779566ed86c35347551a546c72b46ba90e9202102761bc549a8a48cab1b075a34e0d90f0ad23d4a83302704f5c33f5d53cfdbb0fae964c7a
7
+ data.tar.gz: d1fb5229c2e75d193998066f4121d326cf3a69f9ab04a3394528750a328518995e0ac9c4cecc4ac0a8553dc9222bbbe5ec9148e4740a54e532c0a1119fa68454
@@ -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
- Style/PredicateName:
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
- Style/ExtraSpacing:
52
+ Layout/ExtraSpacing:
50
53
  AllowForAlignment: true
@@ -7,8 +7,12 @@ rvm:
7
7
  - 2.4.0
8
8
  - 2.4.3
9
9
  - 2.5.0
10
+ - 2.6.0
11
+ - 2.7.0
12
+ - 3.0.0
10
13
  before_install: gem install bundler -v 1.14.6
11
14
 
12
15
  script:
13
16
  - bundle exec rspec
14
17
  - ./tests/integration_tests.sh
18
+ # - bundle exec rubocop
data/README.md CHANGED
@@ -2,7 +2,7 @@
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/test_runner)
5
+ [![Build Status](https://travis-ci.com/mjacobus/test_runner.svg?branch=master)](https://travis-ci.com/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
7
  [![Code Climate](https://codeclimate.com/github/mjacobus/test_runner/badges/gpa.svg)](https://codeclimate.com/github/mjacobus/test_runner)
8
8
  [![Issue Count](https://codeclimate.com/github/mjacobus/test_runner/badges/issue_count.svg)](https://codeclimate.com/github/mjacobus/test_runner)
@@ -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: Koine\TestRunner\Adapter\Ruby\RSpec
47
+ adapter: rspec
52
48
  file_pattern: "*_spec.rb"
53
49
 
54
50
  phpunit:
55
- adapter: Koine\TestRunner\Adapter\Php\PHPUnit
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: Koine\TestRunner\Adapter\Javascript\Jest
64
- file_pattern: "*_(test|spec).(js|jsx)"
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
  ```
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'bundler/setup'
4
- require 'test_runner'
4
+ require 'koine/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.
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ lib = File.expand_path('lib', __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
2
4
 
3
- require 'bundler/setup'
4
5
  require 'koine/test_runner'
5
6
  require 'yaml'
6
7
 
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
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'
@@ -30,10 +30,10 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
32
 
33
- spec.add_development_dependency 'bundler', '~> 1.14'
34
33
  spec.add_development_dependency 'coveralls', '~> 0.8.21'
35
34
  spec.add_development_dependency 'object_comparator', '~> 0.1.3'
36
35
  spec.add_development_dependency 'rake', '~> 10.0'
37
36
  spec.add_development_dependency 'rspec', '~> 3.0'
37
+ spec.add_development_dependency 'rubocop', '~> 0.53.0'
38
38
  spec.add_development_dependency 'simplecov', '~> 0.14.1'
39
39
  end
@@ -1,18 +1,21 @@
1
+ require 'fileutils'
2
+
1
3
  require 'koine/test_runner/version'
2
4
  require 'koine/test_runner/command_executer'
3
5
  require 'koine/test_runner/configuration'
4
6
  require 'koine/test_runner/builder'
5
7
  require 'koine/test_runner/adapters'
6
8
  require 'koine/test_runner/adapters/base_adapter'
7
- require 'koine/test_runner/adapters/null_adapter'
8
- require 'koine/test_runner/adapters/last_command_adapter'
9
+ require 'koine/test_runner/adapters/base_regexp'
10
+ require 'koine/test_runner/adapters/custom'
11
+ require 'koine/test_runner/adapters/null'
12
+ require 'koine/test_runner/adapters/last_command'
9
13
 
10
14
  module Koine
11
15
  class TestRunner
12
16
  autoload :FileMatcher, 'koine/test_runner/file_matcher'
13
17
 
14
18
  class Adapters
15
- autoload :BaseRegexpAdapter, 'koine/test_runner/adapters/base_regexp_adapter'
16
19
  autoload :Rspec, 'koine/test_runner/adapters/rspec'
17
20
  autoload :Phpunit, 'koine/test_runner/adapters/phpunit'
18
21
  end
@@ -1,11 +1,11 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- def initialize(adapters = [], fallback: LastCommandAdapter.new)
4
+ def initialize(adapters = [], fallback: LastCommand.new)
5
5
  adapters = adapters.dup
6
6
 
7
7
  adapters.unshift(fallback)
8
- adapters.push(Adapters::NullAdapter.new)
8
+ adapters.push(Adapters::Null.new)
9
9
 
10
10
  adapters.inject do |previous, adapter|
11
11
  previous.next_adapter = adapter
@@ -4,9 +4,7 @@ module Koine
4
4
  class BaseAdapter
5
5
  # attr_writer :next_adapter
6
6
 
7
- def next_adapter=(adapter)
8
- @next_adapter = adapter
9
- end
7
+ attr_writer :next_adapter
10
8
 
11
9
  def next_adapter
12
10
  @next_adapter || raise("next_adapter is not set for #{self.class}")
@@ -1,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class BaseRegexpAdapter < BaseAdapter
4
+ class BaseRegexp < BaseAdapter
5
5
  def initialize(file_pattern:)
6
6
  @file_pattern = file_pattern.is_a?(Regexp) ? file_pattern : Regexp.new(file_pattern)
7
7
  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,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class LastCommandAdapter < BaseAdapter
4
+ class LastCommand < BaseAdapter
5
5
  def initialize(storage: Storage.new)
6
6
  @storage = storage
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class NullAdapter
4
+ class Null
5
5
  def test_command(_config)
6
6
  nil
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class Phpunit < BaseRegexpAdapter
4
+ class Phpunit < BaseRegexp
5
5
  DEFAULT_OPTIONS = [
6
6
  '--color'
7
7
  ].freeze
@@ -1,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class Rspec < BaseRegexpAdapter
4
+ class Rspec < BaseRegexp
5
5
  def initialize(file_pattern: /.*_spec.rb$/)
6
6
  super(file_pattern: file_pattern)
7
7
  end
@@ -22,18 +22,23 @@ module Koine
22
22
  end
23
23
 
24
24
  def build_adapter(config)
25
- adapter = config.delete('adapter')
25
+ adapter_name = config.delete('adapter')
26
+ adapter_class = adapter_name
26
27
 
27
- if adapter.downcase == adapter.to_s
28
- adapter_class = "Koine::TestRunner::Adapters::#{adapter.capitalize}"
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 #{adapter} => #{adapter_class}"
33
+ raise ArgumentError, "Cannot locate adapter #{adapter_name} => #{adapter_class}"
33
34
  end
34
35
 
35
36
  klass = Object.const_get(adapter_class)
36
- klass.new(symbolize_keys(config))
37
+ klass.new(**symbolize_keys(config))
38
+ end
39
+
40
+ def classify(klass)
41
+ klass.to_s.split('_').map(&:capitalize).join('')
37
42
  end
38
43
 
39
44
  def symbolize_keys(hash)
@@ -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('../../../../config/default.yml', __FILE__)
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 |line|
15
- match = regexp.match(line)
14
+ lines.each do |file_line|
15
+ match = regexp.match(file_line)
16
16
  return match if match
17
17
  end
18
18
 
@@ -1,3 +1,3 @@
1
1
  class TestRunner
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  end
@@ -5,7 +5,8 @@ set -v
5
5
 
6
6
  export SKIP_COVERAGE='true'
7
7
 
8
- ./exe/run_test spec/fixtures/FixturePhpUnitTest.php --line=30
8
+ bundle exec rake install
9
+ # ./exe/run_test spec/fixtures/FixturePhpUnitTest.php --line=30
9
10
  ./exe/run_test spec/koine/test_runner_spec.rb
10
11
  ./exe/run_test spec/koine/test_runner_spec.rb --line=9
11
12
  ./exe/run_test spec/koine/test_runner_spec.rb --last
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koine-test_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-16 00:00:00.000000000 Z
11
+ date: 2021-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.14'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.14'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: coveralls
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +66,20 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.53.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.53.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -115,14 +115,14 @@ files:
115
115
  - bin/setup
116
116
  - config/default.yml
117
117
  - exe/run_test
118
- - integration_test.sh
119
118
  - koine-test_runner.gemspec
120
119
  - lib/koine/test_runner.rb
121
120
  - lib/koine/test_runner/adapters.rb
122
121
  - 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
122
+ - lib/koine/test_runner/adapters/base_regexp.rb
123
+ - lib/koine/test_runner/adapters/custom.rb
124
+ - lib/koine/test_runner/adapters/last_command.rb
125
+ - lib/koine/test_runner/adapters/null.rb
126
126
  - lib/koine/test_runner/adapters/phpunit.rb
127
127
  - lib/koine/test_runner/adapters/rspec.rb
128
128
  - lib/koine/test_runner/builder.rb
@@ -136,7 +136,7 @@ licenses:
136
136
  - MIT
137
137
  metadata:
138
138
  allowed_push_host: https://rubygems.org
139
- post_install_message:
139
+ post_install_message:
140
140
  rdoc_options: []
141
141
  require_paths:
142
142
  - lib
@@ -151,9 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.7.6
156
- signing_key:
154
+ rubygems_version: 3.2.3
155
+ signing_key:
157
156
  specification_version: 4
158
157
  summary: Easy test runner
159
158
  test_files: []
@@ -1,9 +0,0 @@
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