fuci 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/CHANGELOG.md +5 -1
- data/README.md +20 -4
- data/lib/fuci.rb +1 -6
- data/lib/fuci/cached_command_runner.rb +22 -0
- data/lib/fuci/cli_options.rb +15 -0
- data/lib/fuci/command_cache.rb +19 -0
- data/lib/fuci/rspec.rb +1 -1
- data/lib/fuci/runner.rb +13 -0
- data/lib/fuci/version.rb +1 -1
- data/spec/lib/fuci/cached_command_runner_spec.rb +35 -0
- data/spec/lib/fuci/cli_options_spec.rb +32 -0
- data/spec/lib/fuci/command_cache_spec.rb +33 -0
- data/spec/lib/fuci/runner_spec.rb +46 -6
- data/spec/lib/fuci_spec.rb +2 -12
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ac65a1e15ae2e4186b03e0988dc5fae93b789d
|
4
|
+
data.tar.gz: 19a5f43ed5018e7dc30491539b15e6948c35eef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec5f4d3c0008ab34b53769bc3e0fcb3e8548927e26a113d9ad7266b4c240f027ef0aa9582356f417b31975024c9988dccf3aa2bb629d13454353820741812c16
|
7
|
+
data.tar.gz: 2a5b14f07f033c41f3701260c344096efdf78d37db351c788936541e9da5737a07a7669b4cc47eee530218a3ce883d7e63859a10be51a3ebf0275cc7c61f088a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
### version 0.2.0 *July 31, 2013*
|
2
|
+
* Offers command-line option (`--last`, `-l`) which runs failed tests
|
3
|
+
from last call to `fuci`
|
4
|
+
|
1
5
|
### version 0.1.1 *July 30, 2013*
|
2
|
-
* Logs that no failure was detected by a plugin
|
6
|
+
* Logs that no failure was detected by a plugin
|
3
7
|
|
4
8
|
### version 0.1.0 *July 29, 2013*
|
5
9
|
* Initial release
|
data/README.md
CHANGED
@@ -7,11 +7,28 @@ A base gem providing the general case for running CI failures locally.
|
|
7
7
|
|
8
8
|
Add this line to your fuci extension's Gemspec:
|
9
9
|
|
10
|
-
|
10
|
+
```ruby
|
11
|
+
Gem::Specification.new do |spec|
|
12
|
+
...
|
13
|
+
spec.add_dependency 'fuci', '~> 0.2'
|
14
|
+
...
|
15
|
+
end
|
16
|
+
```
|
11
17
|
|
12
18
|
## Known server extensions
|
13
19
|
* [Fuci::Travis](https://github.com/davejachimiak/fuci-travis)
|
14
20
|
|
21
|
+
## Native command-line options
|
22
|
+
Run the failed tests from your last `fuci` command.
|
23
|
+
|
24
|
+
```sh
|
25
|
+
$ fuci --last
|
26
|
+
```
|
27
|
+
or
|
28
|
+
```sh
|
29
|
+
$ fuci -l
|
30
|
+
```
|
31
|
+
|
15
32
|
## Usage
|
16
33
|
### Creating server extensions
|
17
34
|
#### Configuring Fuci base with the server
|
@@ -48,13 +65,12 @@ details on what they should return.
|
|
48
65
|
#### The binstub
|
49
66
|
Server extensions should ship with their own binstub. `fuci` is
|
50
67
|
preffered. It's short and easy to type. To avoid possible conflicts
|
51
|
-
between local server extensions, prefer that users execute
|
52
|
-
|
68
|
+
between local server extensions, prefer that users execute `bundle
|
69
|
+
binstubs <server-extension>`.
|
53
70
|
|
54
71
|
Fuci binstubs should do the following:
|
55
72
|
* Require the extension
|
56
73
|
* Load a configuration file, if necessary
|
57
|
-
* Handle command-line arguments
|
58
74
|
* Call `Fuci.run`
|
59
75
|
|
60
76
|
### Creating tester extensions
|
data/lib/fuci.rb
CHANGED
@@ -9,15 +9,10 @@ module Fuci
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
attr_accessor :server
|
12
|
-
attr_writer :options
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.options
|
16
|
-
@options ||= {}
|
17
12
|
end
|
18
13
|
|
19
14
|
def self.run
|
20
|
-
Fuci::Runner.
|
15
|
+
Fuci::Runner.create.run
|
21
16
|
end
|
22
17
|
|
23
18
|
def self.add_testers *testers
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require 'fuci/command_cache'
|
3
|
+
|
4
|
+
module Fuci
|
5
|
+
class CachedCommandRunner
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
def_delegator :command_cache, :fetch, :cached_command
|
9
|
+
|
10
|
+
def run
|
11
|
+
puts 'Running specs from last call to fuci.'
|
12
|
+
|
13
|
+
IO.popen cached_command do |io|
|
14
|
+
io.each { |string| puts string }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def command_cache
|
19
|
+
@command_cache ||= CommandCache.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fuci
|
2
|
+
class CommandCache
|
3
|
+
CACHE_FILE_LOCATION = '/tmp/last_fuci_command'
|
4
|
+
|
5
|
+
def initialize command=nil
|
6
|
+
@command = command
|
7
|
+
end
|
8
|
+
|
9
|
+
def cache_command
|
10
|
+
file = File.new CACHE_FILE_LOCATION, 'w+'
|
11
|
+
file.write @command
|
12
|
+
file.close
|
13
|
+
end
|
14
|
+
|
15
|
+
def fetch
|
16
|
+
File.read CACHE_FILE_LOCATION
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/fuci/rspec.rb
CHANGED
data/lib/fuci/runner.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'fuci/command_cache'
|
2
|
+
require 'fuci/cached_command_runner'
|
3
|
+
require 'fuci/cli_options'
|
1
4
|
require 'forwardable'
|
2
5
|
|
3
6
|
module Fuci
|
@@ -15,9 +18,14 @@ module Fuci
|
|
15
18
|
check_build
|
16
19
|
fetch_log
|
17
20
|
detect_tester_failure
|
21
|
+
cache_tester_command
|
18
22
|
run_failures
|
19
23
|
end
|
20
24
|
|
25
|
+
def self.create
|
26
|
+
CliOptions.run_last_command? ? CachedCommandRunner.new : new
|
27
|
+
end
|
28
|
+
|
21
29
|
private
|
22
30
|
|
23
31
|
def check_build
|
@@ -46,6 +54,11 @@ module Fuci
|
|
46
54
|
end
|
47
55
|
end
|
48
56
|
|
57
|
+
def cache_tester_command
|
58
|
+
command = detected_tester.command log
|
59
|
+
CommandCache.new(command).cache_command
|
60
|
+
end
|
61
|
+
|
49
62
|
def run_failures
|
50
63
|
IO.popen detected_tester.command(log) do |io|
|
51
64
|
puts 'Running failed specs...'
|
data/lib/fuci/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/fuci/cached_command_runner'
|
3
|
+
|
4
|
+
stub_class 'IO'
|
5
|
+
stub_class 'Fuci::CommandCache'
|
6
|
+
|
7
|
+
describe Fuci::CachedCommandRunner do
|
8
|
+
before { @runner = Fuci::CachedCommandRunner.new }
|
9
|
+
|
10
|
+
describe '#run' do
|
11
|
+
it 'runs the command cached' do
|
12
|
+
@runner.expects(:puts).with 'Running specs from last call to fuci.'
|
13
|
+
@runner.stubs(:cached_command).returns command = mock
|
14
|
+
IO.expects(:popen).with command
|
15
|
+
|
16
|
+
@runner.run
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#cached_command' do
|
21
|
+
it 'delegates to command cache' do
|
22
|
+
@runner.stubs(:command_cache).returns command_cache = mock
|
23
|
+
command_cache.stubs(:fetch).returns cached_command = 'command'
|
24
|
+
|
25
|
+
expect(@runner.cached_command).to_equal cached_command
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#command_cache' do
|
30
|
+
it 'caches and command cache object' do
|
31
|
+
Fuci::CommandCache.stubs(:new).returns command_cache = mock
|
32
|
+
expect(@runner.command_cache).to_equal command_cache
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/fuci/cli_options'
|
3
|
+
|
4
|
+
describe Fuci::CliOptions do
|
5
|
+
describe '.run_last_command?' do
|
6
|
+
before { @argv = Fuci::CliOptions.stubs(:argv) }
|
7
|
+
|
8
|
+
describe 'when argv contains --last' do
|
9
|
+
before { @argv.returns ['--last'] }
|
10
|
+
|
11
|
+
it 'returns true' do
|
12
|
+
expect(Fuci::CliOptions.run_last_command?).to_equal true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'when argv contains -l' do
|
17
|
+
before { @argv.returns ['-l'] }
|
18
|
+
|
19
|
+
it 'returns true' do
|
20
|
+
expect(Fuci::CliOptions.run_last_command?).to_equal true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'when argv contains neither of the above' do
|
25
|
+
before { @argv.returns [] }
|
26
|
+
|
27
|
+
it 'returns true' do
|
28
|
+
expect(Fuci::CliOptions.run_last_command?).to_equal false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/fuci/command_cache'
|
3
|
+
|
4
|
+
stub_class 'File'
|
5
|
+
|
6
|
+
describe Fuci::CommandCache do
|
7
|
+
before do
|
8
|
+
@command = 'command'
|
9
|
+
@command_cache = Fuci::CommandCache.new @command
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#cache_command' do
|
13
|
+
it 'writes the command to last_fuci_command file' do
|
14
|
+
File.stubs(:new).with('/tmp/last_fuci_command', 'w+').
|
15
|
+
returns file = mock
|
16
|
+
file.expects(:write).with @command
|
17
|
+
file.expects :close
|
18
|
+
|
19
|
+
@command_cache.cache_command
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#fetch' do
|
24
|
+
it 'fetches the cached command' do
|
25
|
+
cached_command = 'cached command'
|
26
|
+
File.stubs(:read).
|
27
|
+
with('/tmp/last_fuci_command').
|
28
|
+
returns cached_command
|
29
|
+
|
30
|
+
expect(@command_cache.fetch).to_equal cached_command
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -2,6 +2,8 @@ require_relative '../../spec_helper'
|
|
2
2
|
require_relative '../../../lib/fuci/runner'
|
3
3
|
|
4
4
|
stub_class 'IO'
|
5
|
+
stub_class 'Fuci::CommandCache'
|
6
|
+
stub_class 'Fuci::CachedCommandRunner'
|
5
7
|
|
6
8
|
describe Fuci::Runner do
|
7
9
|
before { @runner = Fuci::Runner.new }
|
@@ -13,33 +15,57 @@ describe Fuci::Runner do
|
|
13
15
|
@runner.expects :check_build
|
14
16
|
@runner.expects :fetch_log
|
15
17
|
@runner.expects :detect_tester_failure
|
18
|
+
@runner.expects :cache_tester_command
|
16
19
|
@runner.expects :run_failures
|
17
20
|
end
|
18
21
|
|
19
22
|
it 'initializes the testers, ' +
|
20
23
|
'initializes the server, ' +
|
24
|
+
'checks the build, ' +
|
21
25
|
'fetches the log, ' +
|
22
26
|
'detects which tester has the failure, ' +
|
27
|
+
'caches the tester command, ' +
|
23
28
|
'and runs the failures.' do
|
24
29
|
@runner.run
|
25
30
|
end
|
26
31
|
end
|
27
32
|
|
28
|
-
describe '.
|
33
|
+
describe '.create' do
|
34
|
+
before { @run_last_command = Fuci::CliOptions.stubs :run_last_command? }
|
35
|
+
|
36
|
+
describe 'when the cli options say to run the last command' do
|
37
|
+
it 'returns a cached command runner' do
|
38
|
+
Fuci::CachedCommandRunner.stubs(:new).
|
39
|
+
returns cached_command_runner = mock
|
40
|
+
@run_last_command.returns true
|
41
|
+
expect(Fuci::Runner.create).to_equal cached_command_runner
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'when a last command flag is not passed' do
|
46
|
+
it 'returns a cached command runner' do
|
47
|
+
Fuci::Runner.stubs(:new).returns runner = mock
|
48
|
+
@run_last_command.returns false
|
49
|
+
expect(Fuci::Runner.create).to_equal runner
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#initialize_server' do
|
29
55
|
it 'initializes the server' do
|
30
56
|
Fuci.expects :initialize_server!
|
31
57
|
@runner.send :initialize_server!
|
32
58
|
end
|
33
59
|
end
|
34
60
|
|
35
|
-
describe '
|
61
|
+
describe '#initialize_testers' do
|
36
62
|
it 'initializes the testers' do
|
37
63
|
Fuci.expects :initialize_testers!
|
38
64
|
@runner.send :initialize_testers!
|
39
65
|
end
|
40
66
|
end
|
41
67
|
|
42
|
-
describe '
|
68
|
+
describe '#fetch_log' do
|
43
69
|
it 'logs fetching; sets the log with delegation to the server' do
|
44
70
|
@runner.expects(:puts).with "Fetching log from build..."
|
45
71
|
@runner.stubs(:server).returns server = mock
|
@@ -51,7 +77,7 @@ describe Fuci::Runner do
|
|
51
77
|
end
|
52
78
|
end
|
53
79
|
|
54
|
-
describe '
|
80
|
+
describe '#detect_tester_failure' do
|
55
81
|
describe 'a failure is detected by a tester plugin' do
|
56
82
|
it 'detects the first tester failure in the log' do
|
57
83
|
rspec, konacha, cucumber = mock, mock, mock
|
@@ -80,7 +106,21 @@ describe Fuci::Runner do
|
|
80
106
|
end
|
81
107
|
end
|
82
108
|
|
83
|
-
describe '
|
109
|
+
describe '#cache_tester_command' do
|
110
|
+
it 'calls #cache on CommandCache' do
|
111
|
+
@runner.stubs(:log).returns log = mock
|
112
|
+
@runner.stubs(:detected_tester).returns tester = mock
|
113
|
+
tester.stubs(:command).with(log).returns command = mock
|
114
|
+
Fuci::CommandCache.stubs(:new).
|
115
|
+
with(command).
|
116
|
+
returns cache = mock
|
117
|
+
cache.expects :cache_command
|
118
|
+
|
119
|
+
@runner.send :cache_tester_command
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#run_failures' do
|
84
124
|
it 'runs the failrues locally' do
|
85
125
|
@runner.stubs(:detected_tester).returns detected_tester = mock
|
86
126
|
@runner.stubs(:log).returns log = mock
|
@@ -94,7 +134,7 @@ describe Fuci::Runner do
|
|
94
134
|
end
|
95
135
|
end
|
96
136
|
|
97
|
-
describe '
|
137
|
+
describe '#check_build' do
|
98
138
|
describe 'status is green' do
|
99
139
|
before { @runner.stubs(:build_status).returns :green }
|
100
140
|
|
data/spec/lib/fuci_spec.rb
CHANGED
@@ -7,8 +7,8 @@ require_relative '../../lib/fuci'
|
|
7
7
|
|
8
8
|
describe Fuci do
|
9
9
|
describe '.run' do
|
10
|
-
it 'calls #run on an
|
11
|
-
Fuci::Runner.stubs(:
|
10
|
+
it 'calls #run on an instance on runner' do
|
11
|
+
Fuci::Runner.stubs(:create).returns runner = mock
|
12
12
|
runner.expects :run
|
13
13
|
|
14
14
|
Fuci.run
|
@@ -24,16 +24,6 @@ describe Fuci do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe '.options/=' do
|
28
|
-
after { Fuci.options = {} }
|
29
|
-
|
30
|
-
it 'is an accessor' do
|
31
|
-
expect(Fuci.options).to_equal({})
|
32
|
-
Fuci.options = options = { options: :yup }
|
33
|
-
expect(Fuci.options).to_equal options
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
27
|
describe '.testers' do
|
38
28
|
after { Fuci.instance_variable_set :@testers, [] }
|
39
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Jachimiak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest-spec-expect
|
@@ -82,6 +82,9 @@ files:
|
|
82
82
|
- Rakefile
|
83
83
|
- fuci.gemspec
|
84
84
|
- lib/fuci.rb
|
85
|
+
- lib/fuci/cached_command_runner.rb
|
86
|
+
- lib/fuci/cli_options.rb
|
87
|
+
- lib/fuci/command_cache.rb
|
85
88
|
- lib/fuci/configurable.rb
|
86
89
|
- lib/fuci/git.rb
|
87
90
|
- lib/fuci/rspec.rb
|
@@ -89,6 +92,9 @@ files:
|
|
89
92
|
- lib/fuci/server.rb
|
90
93
|
- lib/fuci/tester.rb
|
91
94
|
- lib/fuci/version.rb
|
95
|
+
- spec/lib/fuci/cached_command_runner_spec.rb
|
96
|
+
- spec/lib/fuci/cli_options_spec.rb
|
97
|
+
- spec/lib/fuci/command_cache_spec.rb
|
92
98
|
- spec/lib/fuci/configurable_spec.rb
|
93
99
|
- spec/lib/fuci/git_spec.rb
|
94
100
|
- spec/lib/fuci/rspec_spec.rb
|
@@ -124,6 +130,9 @@ summary: Fuci is a library that covers the general case for running recent failu
|
|
124
130
|
from recent CI (continuous integration) builds locally. It includes interfaces for
|
125
131
|
server (e.g. Travis, TeamCity) and tester (e.g. RSpec, Cucumber) extensions.
|
126
132
|
test_files:
|
133
|
+
- spec/lib/fuci/cached_command_runner_spec.rb
|
134
|
+
- spec/lib/fuci/cli_options_spec.rb
|
135
|
+
- spec/lib/fuci/command_cache_spec.rb
|
127
136
|
- spec/lib/fuci/configurable_spec.rb
|
128
137
|
- spec/lib/fuci/git_spec.rb
|
129
138
|
- spec/lib/fuci/rspec_spec.rb
|