fluff 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/fluff +66 -0
- data/fluff.gemspec +27 -0
- data/lib/fluff/rspec/formatter.rb +92 -0
- data/lib/fluff/rspec.rb +4 -0
- data/lib/fluff/version.rb +3 -0
- data/lib/fluff.rb +4 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2228e74e64c9513968c16272c53c7328b1c434df
|
4
|
+
data.tar.gz: 5d5abd50bfa3153939aed808450d9879937177ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae565838b259c17c407213d35dd088dead5163b17ed025d3e98fa7b067a134d85afc14e416adfb08911cf94fff3e13cab6fe8868ef50b11139ac0811aa3c74ca
|
7
|
+
data.tar.gz: 640a12c0852d4623300efff8c5d9820ea4b416d465fd33cadeabb98a03048a37376a54bd040b75042329609c66aef92698a1733f7ec2d0042f496c1279020e4c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Levente Bagi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Fluff
|
2
|
+
|
3
|
+
Runs RSpec in parallel and optionally displays the results on a web UI.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fluff'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fluff
|
20
|
+
|
21
|
+
For instructions to install the Web UI, see: [fluff-display](https://github.com/bagilevi/fluff).
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Configure using the following environment variables.
|
26
|
+
|
27
|
+
Set the database template:
|
28
|
+
|
29
|
+
FLUFF_DB_URL_TEMPLATE=postgres://myuser:mypass@localhost/myapp_test_%{index}
|
30
|
+
|
31
|
+
Specify how many processes to run in parallel:
|
32
|
+
|
33
|
+
FLUFF_PARALLELISM=4
|
34
|
+
|
35
|
+
If you would like to see the failures in the Web UI then set the same Redis URL
|
36
|
+
you have configured for the Web UI. If you don't set this, RSpec will report using
|
37
|
+
the `progress` formatter.
|
38
|
+
|
39
|
+
FLUFF_REDIS_URL=redis://localhost:6379
|
40
|
+
|
41
|
+
## Development
|
42
|
+
|
43
|
+
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.
|
44
|
+
|
45
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bagilevi/fluff.
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fluff"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/fluff
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pp'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
|
6
|
+
command = (ARGV[0] if ARGV[0] && ARGV[0].start_with?('--'))
|
7
|
+
|
8
|
+
RUNNERS = ENV.fetch('FLUFF_PARALLELISM', 2).to_i
|
9
|
+
DB_URL_TEMPLATE = ENV.fetch('FLUFF_DB_URL_TEMPLATE')
|
10
|
+
|
11
|
+
case command
|
12
|
+
when 'setup'
|
13
|
+
puts "Preparing #{RUNNERS} DBs..."
|
14
|
+
|
15
|
+
(1 .. RUNNERS).map do |runner_num|
|
16
|
+
puts "Preparing DB #{runner_num}..."
|
17
|
+
db_url = DB_URL_TEMPLATE.gsub('%{index}', runner_num.to_s)
|
18
|
+
|
19
|
+
system("env DISABLE_SPRING=1 RAILS_ENV=test TEST_DATABASE_URL=#{db_url} bundle exec rails db:test:prepare")
|
20
|
+
end
|
21
|
+
|
22
|
+
else
|
23
|
+
require 'securerandom'
|
24
|
+
require 'json'
|
25
|
+
redis =
|
26
|
+
if (redis_url = ENV['FLUFF_REDIS_URL']).present?
|
27
|
+
require 'redis'
|
28
|
+
Redis.new(url: redis_url)
|
29
|
+
end
|
30
|
+
run_uuid = SecureRandom.uuid
|
31
|
+
|
32
|
+
paths = ARGV.reject { |a| a.start_with?('-') }
|
33
|
+
paths = ['spec'] if paths.empty?
|
34
|
+
|
35
|
+
spec_files = `find #{paths.join(' ')} | grep _spec.rb`.strip.split("\n")
|
36
|
+
|
37
|
+
groups = spec_files.to_enum.with_index.group_by { |s, index| index % RUNNERS }.map { |_, list| list.map { |s, _| s }}
|
38
|
+
|
39
|
+
redis.publish "fluff_shouts", JSON.generate(type: 'start_run', run_uuid: run_uuid) if redis
|
40
|
+
|
41
|
+
puts "Starting #{groups.size} runners..."
|
42
|
+
|
43
|
+
threads = (1 .. groups.size).map do |runner_num|
|
44
|
+
Thread.new(runner_num) do |runner_num|
|
45
|
+
spec_files = groups[runner_num - 1]
|
46
|
+
db_url = DB_URL_TEMPLATE.gsub('%{index}', runner_num.to_s)
|
47
|
+
cmd = "env "
|
48
|
+
cmd << "FLUFF_REDIS_URL=#{ENV.fetch('FLUFF_REDIS_URL')} " if redis
|
49
|
+
cmd << "FLUFF_RUN_UUID=#{run_uuid} "
|
50
|
+
cmd << "DISABLE_SPRING=1 "
|
51
|
+
cmd << "RAILS_ENV=test "
|
52
|
+
cmd << "TEST_DATABASE_URL=#{db_url} "
|
53
|
+
cmd << "bundle exec rspec "
|
54
|
+
cmd << "--format progress " if !redis
|
55
|
+
cmd << "--format Fluff::Rspec::Formatter " if redis
|
56
|
+
cmd << "#{spec_files.join(' ')}"
|
57
|
+
system(cmd)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
threads.each { |thr| thr.join }
|
62
|
+
|
63
|
+
redis.publish "fluff_shouts", JSON.generate(type: 'end_run', run_uuid: run_uuid) if redis
|
64
|
+
end
|
65
|
+
|
66
|
+
puts
|
data/fluff.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fluff/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluff"
|
8
|
+
spec.version = Fluff::VERSION
|
9
|
+
spec.authors = ["Levente Bagi"]
|
10
|
+
spec.email = ["bagilevi@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Run rspec in parallel and view results in a browser}
|
13
|
+
spec.description = %q{Run rspec in parallel and view results in a browser}
|
14
|
+
spec.homepage = "https://github.com/bagilevi/fluff-gem"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
RSpec::Support.require_rspec_core "formatters/base_formatter"
|
2
|
+
require 'json'
|
3
|
+
require 'redis'
|
4
|
+
|
5
|
+
module Fluff
|
6
|
+
module Rspec
|
7
|
+
class Formatter < RSpec::Core::Formatters::BaseFormatter
|
8
|
+
RSpec::Core::Formatters.register self, :start, :example_passed, :example_failed, :example_pending, :message, :dump_summary, :seed, :close
|
9
|
+
|
10
|
+
attr_reader :output_hash
|
11
|
+
|
12
|
+
def initialize(output)
|
13
|
+
super
|
14
|
+
@run_uuid = ENV.fetch('FLUFF_RUN_UUID', SecureRandom.uuid)
|
15
|
+
@summary_hash = {}
|
16
|
+
@redis = Redis.new(url: ENV.fetch('FLUFF_REDIS_URL'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def start(notification)
|
20
|
+
emit(
|
21
|
+
:type => 'start',
|
22
|
+
:version => RSpec::Core::Version::STRING
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def example_passed(notification)
|
27
|
+
emit format_example(notification.example)
|
28
|
+
end
|
29
|
+
|
30
|
+
def example_failed(notification)
|
31
|
+
emit format_example(notification.example)
|
32
|
+
end
|
33
|
+
|
34
|
+
def example_pending(notification)
|
35
|
+
emit format_example(notification.example)
|
36
|
+
end
|
37
|
+
|
38
|
+
def message(notification)
|
39
|
+
emit :type => 'message', :message => notification.message
|
40
|
+
end
|
41
|
+
|
42
|
+
def dump_summary(summary)
|
43
|
+
@summary_hash.merge!(
|
44
|
+
:type => 'summary',
|
45
|
+
:duration => summary.duration,
|
46
|
+
:example_count => summary.example_count,
|
47
|
+
:failure_count => summary.failure_count,
|
48
|
+
:pending_count => summary.pending_count
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def seed(notification)
|
53
|
+
return unless notification.seed_used?
|
54
|
+
@summary_hash[:seed] = notification.seed
|
55
|
+
end
|
56
|
+
|
57
|
+
def close(_notification)
|
58
|
+
emit @summary_hash
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def emit(payload)
|
64
|
+
payload = { :run_uuid => @run_uuid }.merge(payload)
|
65
|
+
# puts JSON.pretty_generate(payload)
|
66
|
+
@redis.publish "fluff_shouts", JSON.generate(payload)
|
67
|
+
end
|
68
|
+
|
69
|
+
def format_example(example)
|
70
|
+
payload = {
|
71
|
+
:type => 'example_result',
|
72
|
+
:id => example.id,
|
73
|
+
:description => example.description,
|
74
|
+
:full_description => example.full_description,
|
75
|
+
:status => example.execution_result.status.to_s,
|
76
|
+
:file_path => example.metadata[:file_path],
|
77
|
+
:line_number => example.metadata[:line_number],
|
78
|
+
:run_time => example.execution_result.run_time,
|
79
|
+
:pending_message => example.execution_result.pending_message,
|
80
|
+
}
|
81
|
+
if (e = example.exception)
|
82
|
+
payload[:exception] = {
|
83
|
+
:class => e.class.name,
|
84
|
+
:message => e.message,
|
85
|
+
:backtrace => e.backtrace,
|
86
|
+
}
|
87
|
+
end
|
88
|
+
payload
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/fluff/rspec.rb
ADDED
data/lib/fluff.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Levente Bagi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-30 00:00:00.000000000 Z
|
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.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Run rspec in parallel and view results in a browser
|
56
|
+
email:
|
57
|
+
- bagilevi@gmail.com
|
58
|
+
executables:
|
59
|
+
- fluff
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- exe/fluff
|
73
|
+
- fluff.gemspec
|
74
|
+
- lib/fluff.rb
|
75
|
+
- lib/fluff/rspec.rb
|
76
|
+
- lib/fluff/rspec/formatter.rb
|
77
|
+
- lib/fluff/version.rb
|
78
|
+
homepage: https://github.com/bagilevi/fluff-gem
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.6.8
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Run rspec in parallel and view results in a browser
|
102
|
+
test_files: []
|