test_changes 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/{.test_changes.yaml → .test-changes.yml} +3 -5
- data/.travis.yml +3 -1
- data/CHANGELOG.md +12 -0
- data/README.md +18 -18
- data/exe/test-changes +17 -0
- data/lib/test_changes.rb +3 -1
- data/lib/test_changes/argv_wrapper.rb +35 -4
- data/lib/test_changes/client.rb +6 -6
- data/lib/test_changes/config.rb +6 -10
- data/lib/test_changes/config_setup_service.rb +16 -14
- data/lib/test_changes/find_runner_service.rb +23 -0
- data/lib/test_changes/inferred_config.rb +1 -21
- data/lib/test_changes/runner.rb +13 -0
- data/lib/test_changes/version.rb +1 -1
- data/test_changes.gemspec +7 -5
- metadata +39 -9
- data/exe/test_changes +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2df6a30cc05c9b8f553a8669986694b2572ca420
|
4
|
+
data.tar.gz: 71c96602d2c338981e6afe322da2431165fb7ff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0743c92860832fca6d404bbae31c5b0faedb52df44616190052652eb3c410eabadab8c19236be295cc1a03ae070cac040b9c1ccc7e43f0c0d1a861be7a86f942
|
7
|
+
data.tar.gz: 701f39dd0669df793fc6d292f20cc88c2cfd161a12f10fbc0a0eea22a540727f0ca7a9a2051103538d90adc4c0ea567e3bbcf5086658507fbeb2d73c6503ec38
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## master
|
2
2
|
|
3
|
+
## 0.2.0
|
4
|
+
|
5
|
+
### Breaking changes
|
6
|
+
|
7
|
+
* Command line API changed. See README and `test-changes -h` for more information. #4
|
8
|
+
* Config file renamed to `test-changes.yml`. #4
|
9
|
+
* Config file format changed. See README for more info. #4
|
10
|
+
|
11
|
+
### New features
|
12
|
+
|
13
|
+
* You can now put multiple runners in the config file. #8
|
14
|
+
|
3
15
|
## 0.1.1
|
4
16
|
|
5
17
|
* Infer configuration automatically (#2 @rstacruz).
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Test files that have changed since a given commit.
|
4
4
|
|
5
|
+
[](https://travis-ci.org/gsmendoza/test_changes "See test builds")
|
6
|
+
|
5
7
|
## Requirements
|
6
8
|
|
7
9
|
* [Git](https://git-scm.com)
|
@@ -24,51 +26,49 @@ Or install it yourself as:
|
|
24
26
|
|
25
27
|
## Configuration
|
26
28
|
|
27
|
-
Add a `.
|
29
|
+
Add a `.test-changes.yml` configuration file to your repo. Example:
|
28
30
|
|
29
31
|
```yaml
|
30
32
|
---
|
31
|
-
|
32
|
-
|
33
|
-
finding_patterns:
|
33
|
+
rspec:
|
34
34
|
^lib/(.+)\.rb: spec/\1_spec.rb
|
35
35
|
^spec/(.+)_spec.rb: spec/\1_spec.rb
|
36
|
-
|
37
|
-
|
36
|
+
rubocop:
|
37
|
+
^(.+)\.rb: \1.rb
|
38
38
|
```
|
39
39
|
|
40
40
|
The options
|
41
41
|
|
42
|
-
*
|
43
|
-
Example: `rspec`, `zeus rspec`.
|
42
|
+
* The keys - The commands for running the tests.
|
43
|
+
Example: `rspec`, `zeus rspec`, `rubocop`.
|
44
44
|
|
45
|
-
*
|
46
|
-
`test_changes` will test the file's matching tests.
|
47
|
-
of tests:
|
45
|
+
* The values - The finding patterns. If the name of a changed file matches
|
46
|
+
the regular expression, `test_changes` will test the file's matching tests.
|
47
|
+
Can accept an array of tests:
|
48
48
|
|
49
49
|
```yaml
|
50
|
-
|
50
|
+
rspec:
|
51
51
|
^lib/test_changes\.rb:
|
52
52
|
- spec/test_changes_spec.rb
|
53
53
|
- spec/test_changes/client_spec.rb
|
54
54
|
```
|
55
55
|
|
56
|
-
* `verbose` - Set the verbose level of output.
|
57
|
-
|
58
56
|
## Usage
|
59
57
|
|
60
|
-
`
|
58
|
+
`test-changes -c [commit] -- [test_tool_arguments]`
|
61
59
|
|
62
60
|
* `test_tool_arguments` - Arguments that can be passed to the test tool.
|
63
61
|
|
64
62
|
* `commit` - Test change from this commit. Defaults to HEAD.
|
65
63
|
|
64
|
+
See `test-changes -h` for more options.
|
65
|
+
|
66
66
|
Examples:
|
67
67
|
|
68
68
|
```
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
test-changes
|
70
|
+
test-changes -c master
|
71
|
+
test-changes -c HEAD^ -- --format=documentation
|
72
72
|
```
|
73
73
|
|
74
74
|
## Known to work on
|
data/exe/test-changes
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test_changes/argv_wrapper'
|
4
|
+
require 'test_changes/client'
|
5
|
+
require 'test_changes/find_runner_service'
|
6
|
+
|
7
|
+
argv_wrapper = TestChanges::ARGVWrapper.new(ARGV)
|
8
|
+
runner = TestChanges::FindRunnerService.new(argv_wrapper).call
|
9
|
+
|
10
|
+
client = TestChanges::Client.new(
|
11
|
+
runner_name: runner.name,
|
12
|
+
finding_patterns: runner.finding_patterns,
|
13
|
+
commit: argv_wrapper.commit,
|
14
|
+
runner_call_options: argv_wrapper.runner_call_options,
|
15
|
+
verbose: argv_wrapper.verbose?)
|
16
|
+
|
17
|
+
client.call
|
data/lib/test_changes.rb
CHANGED
@@ -1,19 +1,50 @@
|
|
1
|
+
require 'slop'
|
2
|
+
require 'test_changes'
|
3
|
+
|
1
4
|
module TestChanges
|
2
5
|
class ARGVWrapper
|
6
|
+
attr_reader :argv
|
7
|
+
|
3
8
|
def initialize(argv)
|
4
9
|
@argv = argv
|
5
10
|
end
|
6
11
|
|
7
12
|
def commit
|
8
|
-
|
13
|
+
slop_options[:commit]
|
9
14
|
end
|
10
15
|
|
11
|
-
def
|
12
|
-
|
16
|
+
def runner_call_options
|
17
|
+
runner_call_options_delimiter_index = argv.index('--')
|
18
|
+
|
19
|
+
if runner_call_options_delimiter_index
|
20
|
+
argv.slice(runner_call_options_delimiter_index + 1, argv.size)
|
21
|
+
else
|
22
|
+
[]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def runner_name
|
27
|
+
slop_options[:runner]
|
28
|
+
end
|
29
|
+
|
30
|
+
def verbose?
|
31
|
+
!slop_options.quiet?
|
13
32
|
end
|
14
33
|
|
15
34
|
private
|
16
35
|
|
17
|
-
|
36
|
+
def slop_options
|
37
|
+
Slop.parse(argv, help: true, strict: true, banner: banner) do
|
38
|
+
on 'c', 'commit=', 'Git commit. Default: HEAD.', default: 'HEAD'
|
39
|
+
on 'q', 'quiet', 'Do not print output. Default: false.', default: false
|
40
|
+
|
41
|
+
on 'r', 'runner=',
|
42
|
+
'The test tool to run. Default: the first runner of the config file.'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def banner
|
47
|
+
"Usage: test-changes [options] -- [test tool arguments]"
|
48
|
+
end
|
18
49
|
end
|
19
50
|
end
|
data/lib/test_changes/client.rb
CHANGED
@@ -3,10 +3,10 @@ require 'test_changes/finding_pattern'
|
|
3
3
|
module TestChanges
|
4
4
|
class Client
|
5
5
|
def initialize(options)
|
6
|
-
@
|
6
|
+
@runner_name = options[:runner_name]
|
7
7
|
@finding_patterns = options[:finding_patterns]
|
8
8
|
@commit = options[:commit]
|
9
|
-
@
|
9
|
+
@runner_call_options = options[:runner_call_options]
|
10
10
|
@verbose = options[:verbose]
|
11
11
|
end
|
12
12
|
|
@@ -30,8 +30,8 @@ module TestChanges
|
|
30
30
|
|
31
31
|
attr_reader :commit,
|
32
32
|
:finding_patterns,
|
33
|
-
:
|
34
|
-
:
|
33
|
+
:runner_name,
|
34
|
+
:runner_call_options,
|
35
35
|
:verbose
|
36
36
|
|
37
37
|
def log(header, message)
|
@@ -52,8 +52,8 @@ module TestChanges
|
|
52
52
|
|
53
53
|
def test_tool_call
|
54
54
|
@test_tool_call ||= [
|
55
|
-
|
56
|
-
|
55
|
+
runner_name,
|
56
|
+
runner_call_options,
|
57
57
|
existing_matches
|
58
58
|
].flatten.compact.join(' ')
|
59
59
|
end
|
data/lib/test_changes/config.rb
CHANGED
@@ -11,16 +11,12 @@ module TestChanges
|
|
11
11
|
File.exist?(@config_path)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def verbose
|
23
|
-
config['verbose']
|
14
|
+
def runners
|
15
|
+
config.map do |runner_name, finding_pattern_maps|
|
16
|
+
Runner.new(
|
17
|
+
name: runner_name,
|
18
|
+
finding_patterns: FindingPattern.build(finding_pattern_maps))
|
19
|
+
end
|
24
20
|
end
|
25
21
|
|
26
22
|
private
|
@@ -1,9 +1,11 @@
|
|
1
|
+
require 'test_changes/config'
|
1
2
|
require 'test_changes/inferred_config'
|
2
3
|
|
3
4
|
module TestChanges
|
4
5
|
module ConfigSetupService
|
5
6
|
def self.call
|
6
|
-
|
7
|
+
config_file_name = '.test-changes.yml'
|
8
|
+
config = Config.new(config_file_name)
|
7
9
|
|
8
10
|
return config if config.exists?
|
9
11
|
|
@@ -13,31 +15,31 @@ module TestChanges
|
|
13
15
|
return use_testunit_rails('bundle exec ruby -Itest') if File.directory?('./test')
|
14
16
|
end
|
15
17
|
|
16
|
-
fail TestChanges::Error, "No
|
18
|
+
fail TestChanges::Error, "No #{config_file_name} found"
|
17
19
|
end
|
18
20
|
|
19
21
|
private
|
20
22
|
|
21
23
|
def self.use_rspec_rails(bin)
|
22
|
-
|
23
|
-
|
24
|
+
runner = Runner.new(
|
25
|
+
name: bin,
|
24
26
|
project_type_name: 'rspec_rails',
|
25
|
-
|
27
|
+
finding_patterns: FindingPattern.build(
|
26
28
|
'^app/(models)/(.+).rb' => 'spec/\1/\2_spec.rb',
|
27
|
-
'^app/(controller|helper|view)s/(.+).rb' => 'spec/controllers/\2_\1_spec.rb'
|
28
|
-
|
29
|
-
)
|
29
|
+
'^app/(controller|helper|view)s/(.+).rb' => 'spec/controllers/\2_\1_spec.rb'))
|
30
|
+
|
31
|
+
InferredConfig.new([runner])
|
30
32
|
end
|
31
33
|
|
32
34
|
def self.use_testunit_rails(bin)
|
33
|
-
|
34
|
-
|
35
|
+
runner = Runner.new(
|
36
|
+
name: bin,
|
35
37
|
project_type_name: 'testunit_rails',
|
36
|
-
|
38
|
+
finding_patterns: FindingPattern.build(
|
37
39
|
'^app/(models)/(.+).rb' => 'test/\1/\2_test.rb',
|
38
|
-
'^app/(controller|helper|view)s/(.+).rb' => 'test/controllers/\2_\1_test.rb'
|
39
|
-
|
40
|
-
)
|
40
|
+
'^app/(controller|helper|view)s/(.+).rb' => 'test/controllers/\2_\1_test.rb'))
|
41
|
+
|
42
|
+
InferredConfig.new([runner])
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_changes/config_setup_service'
|
2
|
+
require 'test_changes/runner'
|
3
|
+
|
4
|
+
module TestChanges
|
5
|
+
class FindRunnerService
|
6
|
+
def initialize(argv_wrapper)
|
7
|
+
@config = ConfigSetupService.call
|
8
|
+
@argv_wrapper = argv_wrapper
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
return config.runners.first unless argv_wrapper.runner_name
|
13
|
+
|
14
|
+
config.runners.find do |runner|
|
15
|
+
runner.name == argv_wrapper.runner_name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :config, :argv_wrapper
|
22
|
+
end
|
23
|
+
end
|
@@ -1,25 +1,5 @@
|
|
1
1
|
require 'test_changes/error'
|
2
2
|
|
3
3
|
module TestChanges
|
4
|
-
|
5
|
-
attr_reader :finding_patterns_map
|
6
|
-
attr_reader :test_tool_command
|
7
|
-
attr_reader :project_type_name
|
8
|
-
|
9
|
-
def initialize(test_tool_command: nil,
|
10
|
-
project_type_name: nil, finding_patterns_map: nil)
|
11
|
-
|
12
|
-
@test_tool_command = test_tool_command
|
13
|
-
@project_type_name = project_type_name
|
14
|
-
@finding_patterns_map = finding_patterns_map
|
15
|
-
end
|
16
|
-
|
17
|
-
def finding_patterns
|
18
|
-
FindingPattern.build finding_patterns_map
|
19
|
-
end
|
20
|
-
|
21
|
-
def verbose
|
22
|
-
true
|
23
|
-
end
|
24
|
-
end
|
4
|
+
InferredConfig = Struct.new(:runners)
|
25
5
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_changes/config_setup_service'
|
2
|
+
|
3
|
+
module TestChanges
|
4
|
+
class Runner
|
5
|
+
def initialize(name: nil, finding_patterns: nil, project_type_name: nil)
|
6
|
+
@name = name
|
7
|
+
@finding_patterns = finding_patterns
|
8
|
+
@project_type_name = project_type_name
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :name, :finding_patterns, :project_type_name
|
12
|
+
end
|
13
|
+
end
|
data/lib/test_changes/version.rb
CHANGED
data/test_changes.gemspec
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'test_changes'
|
4
5
|
require 'test_changes/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
@@ -9,10 +10,8 @@ Gem::Specification.new do |spec|
|
|
9
10
|
spec.authors = ["George Mendoza"]
|
10
11
|
spec.email = ["gsmendoza@gmail.com"]
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
|
14
|
-
spec.description =
|
15
|
-
%(Run only the tests affected by files changed since a given commit.)
|
13
|
+
spec.summary = TestChanges::SUMMARY
|
14
|
+
spec.description = TestChanges::DESCRIPTION
|
16
15
|
|
17
16
|
spec.homepage = "https://github.com/gsmendoza/test_changes"
|
18
17
|
spec.license = "MIT"
|
@@ -25,7 +24,10 @@ Gem::Specification.new do |spec|
|
|
25
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
25
|
spec.require_paths = ["lib"]
|
27
26
|
|
28
|
-
spec.
|
27
|
+
spec.add_dependency "slop", '~> 3.4.0'
|
28
|
+
|
29
|
+
spec.add_development_dependency "pry", '~> 0.10.1'
|
29
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
30
31
|
spec.add_development_dependency "rspec"
|
32
|
+
spec.add_development_dependency "rubocop"
|
31
33
|
end
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_changes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Mendoza
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: slop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.4.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.4.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: pry
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
33
|
+
version: 0.10.1
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
40
|
+
version: 0.10.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,11 +66,25 @@ dependencies:
|
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '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'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
description: Run only the tests affected by files changed since a given commit.
|
56
84
|
email:
|
57
85
|
- gsmendoza@gmail.com
|
58
86
|
executables:
|
59
|
-
-
|
87
|
+
- test-changes
|
60
88
|
extensions: []
|
61
89
|
extra_rdoc_files: []
|
62
90
|
files:
|
@@ -64,7 +92,7 @@ files:
|
|
64
92
|
- ".overcommit.yml"
|
65
93
|
- ".rspec"
|
66
94
|
- ".rubocop.yml"
|
67
|
-
- ".
|
95
|
+
- ".test-changes.yml"
|
68
96
|
- ".travis.yml"
|
69
97
|
- CHANGELOG.md
|
70
98
|
- CODE_OF_CONDUCT.md
|
@@ -74,15 +102,17 @@ files:
|
|
74
102
|
- Rakefile
|
75
103
|
- bin/console
|
76
104
|
- bin/setup
|
77
|
-
- exe/
|
105
|
+
- exe/test-changes
|
78
106
|
- lib/test_changes.rb
|
79
107
|
- lib/test_changes/argv_wrapper.rb
|
80
108
|
- lib/test_changes/client.rb
|
81
109
|
- lib/test_changes/config.rb
|
82
110
|
- lib/test_changes/config_setup_service.rb
|
83
111
|
- lib/test_changes/error.rb
|
112
|
+
- lib/test_changes/find_runner_service.rb
|
84
113
|
- lib/test_changes/finding_pattern.rb
|
85
114
|
- lib/test_changes/inferred_config.rb
|
115
|
+
- lib/test_changes/runner.rb
|
86
116
|
- lib/test_changes/version.rb
|
87
117
|
- test_changes.gemspec
|
88
118
|
homepage: https://github.com/gsmendoza/test_changes
|
data/exe/test_changes
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test_changes/argv_wrapper'
|
4
|
-
require 'test_changes/client'
|
5
|
-
require 'test_changes/config'
|
6
|
-
require 'test_changes/inferred_config'
|
7
|
-
require 'test_changes/config_setup_service'
|
8
|
-
|
9
|
-
argv_wrapper = TestChanges::ARGVWrapper.new(ARGV)
|
10
|
-
|
11
|
-
config = TestChanges::ConfigSetupService.call
|
12
|
-
|
13
|
-
client = TestChanges::Client.new(
|
14
|
-
test_tool_command: config.test_tool_command,
|
15
|
-
finding_patterns: config.finding_patterns,
|
16
|
-
commit: argv_wrapper.commit,
|
17
|
-
test_tool_call_options: argv_wrapper.test_tool_call_options,
|
18
|
-
verbose: config.verbose)
|
19
|
-
|
20
|
-
client.call
|