koine-test_runner 0.1.0.pre.delete → 0.2.3

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
- SHA1:
3
- metadata.gz: 7b54239c3ff6932ff3e2b474ecbcf97a37bd726c
4
- data.tar.gz: d50e654912ccc8d4359cc6ded5ba5e2c3f487eb2
2
+ SHA256:
3
+ metadata.gz: d6202ad8a17627d65b8bcf5fec92a7cda2325aa95abcd8ef7f85f9cec4eb0b15
4
+ data.tar.gz: 2a95e8bd6208b76294e0ba9cc471195abccc109f442039023e1d3f5a97ebb2d7
5
5
  SHA512:
6
- metadata.gz: e2799618c081fc14eb419cb8a55d4050fbf0a155b6b19d68fe2a8712c8d163a86938fb874a221e0719c0c5e62b56b220e4afa1d60eab6ab5ed165b03eb826680
7
- data.tar.gz: db122c0afe2fa47e5d510e23d1aaef9d7e12c3816ad78b012f1e7b08fc62a7ca51147e363e79452f3bdb5591834051d122a42689666c31f03ce630d795c2fc2b
6
+ metadata.gz: 5aaa35b7ee18e6d1ebd4d4103d96155301b82a21e944c1ae585dcae679c2da15ccca6852b880ecad2243a21b0c4f3cc6536f6595b4cdffe1a1e676c58199b0b4
7
+ data.tar.gz: ff09fc980406648efe34e9379a997c643ee611bb685f4cf81fbba40298ad74de88d3a12e66371ec0493bff854b72b67a3555169e87a0cfd213bc094af1fd04df
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+ .cache
@@ -0,0 +1,53 @@
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/SpecialGlobalVars:
22
+ Enabled: false
23
+
24
+ Style/GuardClause:
25
+ Enabled: false
26
+
27
+ Style/IfUnlessModifier:
28
+ Enabled: false
29
+
30
+ Naming/PredicateName:
31
+ NamePrefix:
32
+ - is_
33
+ - has_
34
+
35
+ NamePrefixBlacklist:
36
+ - is_
37
+ - has_
38
+
39
+ Metrics/AbcSize:
40
+ Max: 45
41
+
42
+ Metrics/PerceivedComplexity:
43
+ Max: 10
44
+
45
+ Documentation:
46
+ Enabled: false
47
+
48
+ AllCops:
49
+ Exclude:
50
+ - Gemfile
51
+
52
+ Layout/ExtraSpacing:
53
+ AllowForAlignment: true
@@ -1,5 +1,18 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3.0
7
+ - 2.4.0
8
+ - 2.4.3
9
+ - 2.5.0
10
+ - 2.6.0
11
+ - 2.7.0
12
+ - 3.0.0
5
13
  before_install: gem install bundler -v 1.14.6
14
+
15
+ script:
16
+ - bundle exec rspec
17
+ # - ./tests/integration_tests.sh
18
+ # - bundle exec rubocop
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/koine-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
- [![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
 
@@ -44,27 +43,28 @@ bundle exec run_test some/file_spec.custom
44
43
  # .test_runner.yml
45
44
 
46
45
  adapters:
47
- minitest:
48
- adapter: Koine\TestRunner\Adapter\Ruby\Minitest
49
- file_pattern: "*_test.rb"
50
-
51
46
  rspec:
52
- adapter: Koine\TestRunner\Adapter\Ruby\RSpec
47
+ adapter: rspec
53
48
  file_pattern: "*_spec.rb"
54
49
 
55
50
  phpunit:
56
- adapter: Koine\TestRunner\Adapter\Php\PHPUnit
51
+ adapter: phpunit
57
52
  file_pattern: "*Test.php"
58
53
 
59
- codeception:
60
- adapter: Koine\TestRunner\Adapter\Php\Codeception
61
- file_pattern: "*Spec.php"
62
-
63
54
  jest:
64
- adapter: Koine\TestRunner\Adapter\Javascript\Jest
65
- file_pattern: "*_(test|spec).(js|jsx)"
66
-
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
67
65
  My::CustoAdapter:
66
+ require:
67
+ - some/file
68
68
  adapter: MyCustomAdapter
69
69
  suffix: '_spec.custom'
70
70
  ```
@@ -76,18 +76,11 @@ module My
76
76
  @suffix = suffix
77
77
  end
78
78
 
79
- def matches?(file_path)
80
- file_path.end_with?(@suffix)
81
- end
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}"
79
+ # return nil if you do not want to deal with it
80
+ def test_command(config)
81
+ if config.file_path.end_with?(@suffix)
82
+ return "./bin/test #{config.file_path}"
88
83
  end
89
-
90
- cmd.join(' ')
91
84
  end
92
85
  end
93
86
  end
@@ -99,6 +92,20 @@ Now you can run:
99
92
  bundle exec run_test some/file_spec.custom
100
93
  ```
101
94
 
95
+ ## Running the last test
96
+
97
+ Either run a file that does not get caught by any adapter
98
+
99
+ ```bash
100
+ bundle exec run_test some/file_spec.unkown # run last test
101
+ ```
102
+
103
+ Or
104
+
105
+ ```bash
106
+ bundle exec run_test --last
107
+ ```
108
+
102
109
  ## Development
103
110
 
104
111
  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
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "test_runner"
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 "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -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)"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path('lib', __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'koine/test_runner'
6
+ require 'yaml'
7
+
8
+ configuration = Koine::TestRunner::Configuration.new(ARGV)
9
+ runner = Koine::TestRunner::Builder.new(configuration).build
10
+ runner.run(configuration)
@@ -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
@@ -1,39 +1,39 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
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 = "koine-test_runner"
7
+ spec.name = 'koine-test_runner'
9
8
  spec.version = TestRunner::VERSION
10
- spec.authors = ["Marcelo Jacobus"]
11
- spec.email = ["marcelo.jacobus@gmail.com"]
9
+ spec.authors = ['Marcelo Jacobus']
10
+ spec.email = ['marcelo.jacobus@gmail.com']
12
11
 
13
- spec.summary = %q{Easy test runner}
14
- spec.description = %q{Easy test runner}
15
- spec.homepage = "https://github.com/mjacobus/test_runner"
16
- spec.license = "MIT"
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'] = "https://rubygems.org"
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
22
21
  else
23
- raise "RubyGems 2.0 or newer is required to protect against " \
24
- "public gem pushes."
22
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
23
+ 'public gem pushes.'
25
24
  end
26
25
 
27
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
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 = "exe"
29
+ spec.bindir = 'exe'
31
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
- spec.require_paths = ["lib"]
31
+ spec.require_paths = ['lib']
33
32
 
34
- spec.add_development_dependency "bundler", "~> 1.14"
35
- spec.add_development_dependency "rake", "~> 10.0"
36
- spec.add_development_dependency "rspec", "~> 3.0"
37
- spec.add_development_dependency "simplecov", "~> 0.14.1"
38
- spec.add_development_dependency "coveralls", "~> 0.8.21"
33
+ spec.add_development_dependency 'coveralls', '~> 0.8.21'
34
+ spec.add_development_dependency 'object_comparator', '~> 0.1.3'
35
+ spec.add_development_dependency 'rake', '~> 10.0'
36
+ spec.add_development_dependency 'rspec', '~> 3.0'
37
+ spec.add_development_dependency 'rubocop', '~> 0.53.0'
38
+ spec.add_development_dependency 'simplecov', '~> 0.14.1'
39
39
  end
@@ -1,4 +1,36 @@
1
- require "koine/test_runner/version"
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/base_regexp'
8
+ require 'koine/test_runner/adapters/custom'
9
+ require 'koine/test_runner/adapters/null'
10
+ require 'koine/test_runner/adapters/last_command'
2
11
 
3
- module TestRunner
12
+ module Koine
13
+ class TestRunner
14
+ autoload :FileMatcher, 'koine/test_runner/file_matcher'
15
+
16
+ class Adapters
17
+ autoload :Rspec, 'koine/test_runner/adapters/rspec'
18
+ autoload :Phpunit, 'koine/test_runner/adapters/phpunit'
19
+ end
20
+
21
+ def initialize(adapters = [])
22
+ @adapters = Adapters.new(adapters)
23
+ end
24
+
25
+ def run(configuration)
26
+ test_command = @adapters.test_command(configuration)
27
+ executer = CommandExecuter.new
28
+
29
+ if test_command
30
+ return executer.execute_and_exit(test_command)
31
+ end
32
+
33
+ executer.fail('No tests run')
34
+ end
35
+ end
4
36
  end
@@ -0,0 +1,23 @@
1
+ module Koine
2
+ class TestRunner
3
+ class Adapters
4
+ def initialize(adapters = [], fallback: LastCommand.new)
5
+ adapters = adapters.dup
6
+
7
+ adapters.unshift(fallback)
8
+ adapters.push(Adapters::Null.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,53 @@
1
+ module Koine
2
+ class TestRunner
3
+ class Adapters
4
+ class BaseAdapter
5
+ # attr_writer :next_adapter
6
+
7
+ attr_writer :next_adapter
8
+
9
+ def next_adapter
10
+ @next_adapter || raise("next_adapter is not set for #{self.class}")
11
+ end
12
+
13
+ def test_command(config)
14
+ unless accept?(config)
15
+ return next_adapter.test_command(config)
16
+ end
17
+
18
+ if config.all?
19
+ return all_tests(config)
20
+ end
21
+
22
+ if config.line?
23
+ return file_line_command(config)
24
+ end
25
+
26
+ single_file_command(config)
27
+ end
28
+
29
+ private
30
+
31
+ def accept?(_config)
32
+ false
33
+ end
34
+
35
+ def all_tests(config)
36
+ script_for(config)
37
+ end
38
+
39
+ def file_line_command(config)
40
+ [single_file_command(config), config.line].join(':')
41
+ end
42
+
43
+ def single_file_command(config)
44
+ [script_for(config), config.file_path].join(' ')
45
+ end
46
+
47
+ def script_for(_config)
48
+ raise 'Not implemented'
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,17 @@
1
+ module Koine
2
+ class TestRunner
3
+ class Adapters
4
+ class BaseRegexp < 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,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
@@ -0,0 +1,44 @@
1
+ module Koine
2
+ class TestRunner
3
+ class Adapters
4
+ class LastCommand < 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,11 @@
1
+ module Koine
2
+ class TestRunner
3
+ class Adapters
4
+ class Null
5
+ def test_command(_config)
6
+ nil
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,37 @@
1
+ module Koine
2
+ class TestRunner
3
+ class Adapters
4
+ class Phpunit < BaseRegexp
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 < BaseRegexp
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,53 @@
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_name = config.delete('adapter')
26
+ adapter_class = adapter_name
27
+
28
+ if adapter_class.downcase == adapter_class.to_s
29
+ adapter_class = "Koine::TestRunner::Adapters::#{classify(adapter_class)}"
30
+ end
31
+
32
+ unless Object.const_defined?(adapter_class)
33
+ raise ArgumentError, "Cannot locate adapter #{adapter_name} => #{adapter_class}"
34
+ end
35
+
36
+ klass = Object.const_get(adapter_class)
37
+ klass.new(**symbolize_keys(config))
38
+ end
39
+
40
+ def classify(klass)
41
+ klass.to_s.split('_').map(&:capitalize).join('')
42
+ end
43
+
44
+ def symbolize_keys(hash)
45
+ {}.tap do |new_hash|
46
+ hash.each do |key, value|
47
+ new_hash[key.to_sym] = value
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ 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', __dir__)
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 |file_line|
15
+ match = regexp.match(file_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
- module TestRunner
2
- VERSION = "0.1.0-delete"
1
+ class TestRunner
2
+ VERSION = '0.2.3'.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,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koine-test_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.delete
4
+ version: 0.2.3
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: 2017-07-13 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: coveralls
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.14'
19
+ version: 0.8.21
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.14'
26
+ version: 0.8.21
27
+ - !ruby/object:Gem::Dependency
28
+ name: object_comparator
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.3
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.3
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,42 +67,44 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '3.0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: simplecov
70
+ name: rubocop
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 0.14.1
75
+ version: 0.53.0
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 0.14.1
82
+ version: 0.53.0
69
83
  - !ruby/object:Gem::Dependency
70
- name: coveralls
84
+ name: simplecov
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 0.8.21
89
+ version: 0.14.1
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 0.8.21
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,15 +113,31 @@ 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.rb
124
+ - lib/koine/test_runner/adapters/custom.rb
125
+ - lib/koine/test_runner/adapters/last_command.rb
126
+ - lib/koine/test_runner/adapters/null.rb
127
+ - lib/koine/test_runner/adapters/phpunit.rb
128
+ - lib/koine/test_runner/adapters/rspec.rb
129
+ - lib/koine/test_runner/builder.rb
130
+ - lib/koine/test_runner/command_executer.rb
131
+ - lib/koine/test_runner/configuration.rb
132
+ - lib/koine/test_runner/file_matcher.rb
102
133
  - lib/koine/test_runner/version.rb
134
+ - tests/integration_tests.sh
103
135
  homepage: https://github.com/mjacobus/test_runner
104
136
  licenses:
105
137
  - MIT
106
138
  metadata:
107
139
  allowed_push_host: https://rubygems.org
108
- post_install_message:
140
+ post_install_message:
109
141
  rdoc_options: []
110
142
  require_paths:
111
143
  - lib
@@ -116,13 +148,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
148
  version: '0'
117
149
  required_rubygems_version: !ruby/object:Gem::Requirement
118
150
  requirements:
119
- - - ">"
151
+ - - ">="
120
152
  - !ruby/object:Gem::Version
121
- version: 1.3.1
153
+ version: '0'
122
154
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.6.11
125
- signing_key:
155
+ rubygems_version: 3.2.3
156
+ signing_key:
126
157
  specification_version: 4
127
158
  summary: Easy test runner
128
159
  test_files: []