Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ jobs:
strategy:
matrix:
rspec-minor-versions: [6, 7, 8, 9, 10, 11, 12, 13]
ruby-versions: ["3.1", "3.2", "3.3", "3.4"]
ruby-versions: ["3.1", "3.2", "3.3", "3.4", "4.0"]
exclude:
- ruby-versions: 4.0
rspec-minor-versions: 6
- ruby-versions: 4.0
rspec-minor-versions: 7
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rspec_3.${{ matrix.rspec-minor-versions }}.gemfile

Expand Down
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Style/FrozenStringLiteralComment:
Naming/FileName:
Exclude:
- lib/flatware-*.rb
Naming/PredicateMethod:
Exclude:
- lib/flatware/sink.rb
Style/Documentation:
Enabled: false
Metrics/BlockLength:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gemspec name: 'flatware-cucumber'

group :development do
gem 'appraisal'
gem 'aruba', '~> 0.14'
gem 'aruba'
gem 'logger'
gem 'ostruct'
gem 'pry'
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end
RuboCop::RakeTask.new :lint

Cucumber::Rake::Task.new :cucumber do |task|
task.cucumber_opts = ['--tags', 'not @wip']
task.cucumber_opts = ['--tags', 'not @wip', '--publish-quiet']
task.cucumber_opts += %w[-f progress] unless ENV['TRAVIS']
task.fork = false
end
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/flatware_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def duration(&block)
command = ['flatware', args, '-w', max_workers].flatten.compact.join(' ')

@duration = duration do
run_command_and_stop(command, fail_on_exit: false)
run_command_and_stop(command, fail_on_error: false)
end
end

Expand Down Expand Up @@ -113,7 +113,7 @@ def duration(&block)

Then 'the output contains a backtrace' do
trace = <<-TXT.gsub(/^ +/, '')
features/flunk.feature:4:in `Given flunk'
features/flunk.feature:4:in `flunk'
TXT

expect(flatware_process).to have_output Regexp.new Regexp.escape trace
Expand Down
5 changes: 3 additions & 2 deletions flatware-cucumber.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ Gem::Specification.new do |s|
)
s.homepage = 'http://github.com/briandunn/flatware'
s.licenses = ['MIT']
s.required_ruby_version = ['>= 2.6', '< 3.5']
s.required_ruby_version = ['>= 2.6', '< 4.1']
s.require_paths = ['lib']
s.add_dependency %(cucumber), '~> 3.0'
s.add_dependency %(cucumber), '>= 10.0'
s.add_dependency %(flatware), Flatware::VERSION
s.add_dependency %(ostruct)
# s.metadata['rubygems_mfa_required'] = 'true'
end
2 changes: 1 addition & 1 deletion flatware-rspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |s|
)
s.homepage = 'http://github.com/briandunn/flatware'
s.licenses = ['MIT']
s.required_ruby_version = ['>= 2.6', '< 3.5']
s.required_ruby_version = ['>= 2.6', '< 4.1']
s.require_paths = ['lib']
s.add_dependency %(flatware), Flatware::VERSION
s.add_dependency %(rspec), '>= 3.6'
Expand Down
4 changes: 3 additions & 1 deletion flatware.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ Gem::Specification.new do |s|
s.homepage = 'http://github.com/briandunn/flatware'

s.licenses = ['MIT']
s.required_ruby_version = ['>= 2.6', '< 3.5']
s.required_ruby_version = ['>= 2.6', '< 4.1']
s.require_paths = ['lib']
s.executables = ['flatware']
s.add_dependency %(benchmark)
s.add_dependency %(drb)
s.add_dependency %(logger)
s.add_dependency %(thor), '< 2.0'
# s.metadata['rubygems_mfa_required'] = 'true'
end
2 changes: 1 addition & 1 deletion gemfiles/rspec_3.10.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem "rspec", "3.10.0"

group :development do
gem "appraisal"
gem "aruba", "~> 0.14"
gem "aruba"
gem "pry"
gem "racc"
gem "rake"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rspec_3.11.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem "rspec", "3.11.0"

group :development do
gem "appraisal"
gem "aruba", "~> 0.14"
gem "aruba"
gem "pry"
gem "racc"
gem "rake"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rspec_3.12.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem "rspec", "3.12.0"

group :development do
gem "appraisal"
gem "aruba", "~> 0.14"
gem "aruba"
gem "pry"
gem "racc"
gem "rake"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rspec_3.13.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem "rspec", "3.13.0"

group :development do
gem "appraisal"
gem "aruba", "~> 0.14"
gem "aruba"
gem "pry"
gem "racc"
gem "rake"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rspec_3.6.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem "rspec", "3.6.0"

group :development do
gem "appraisal"
gem "aruba", "~> 0.14"
gem "aruba"
gem "pry"
gem "racc"
gem "rake"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rspec_3.7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem "rspec", "3.7.0"

group :development do
gem "appraisal"
gem "aruba", "~> 0.14"
gem "aruba"
gem "pry"
gem "racc"
gem "rake"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rspec_3.8.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem "rspec", "3.8.0"

group :development do
gem "appraisal"
gem "aruba", "~> 0.14"
gem "aruba"
gem "pry"
gem "racc"
gem "rake"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rspec_3.9.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem "rspec", "3.9.0"

group :development do
gem "appraisal"
gem "aruba", "~> 0.14"
gem "aruba"
gem "pry"
gem "racc"
gem "rake"
Expand Down
13 changes: 12 additions & 1 deletion lib/flatware/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,23 @@ def feature_files
def configure(args, out_stream = $stdout, error_stream = $stderr)
raw_args = args.dup
cli_config = ::Cucumber::Cli::Configuration.new(out_stream, error_stream)
cli_config.parse! args + %w[--format Flatware::Cucumber::Formatter]
cli_config.parse! args + %w[--format Flatware::Cucumber::Formatter --publish-quiet]
cucumber_config = ::Cucumber::Configuration.new cli_config
Config.new cucumber_config, raw_args
end

def run(feature_files, options)
# TODO: This will eventually stop working. This ensures step definitions are evaluated on each execution
# by using `load` instead of once per Ruby runtime using `require`.
#
# If we use the same runtime object and reconfigure it on each execution here, the wrong feature files will
# be evaluated since their memoized. Unfortunately, this means there's no straightforward way to both ensure
# step definitions are available on every runtime *and* also ensure Cucumber isn't memoizing the feature files
# to run.
#
# For now, the legacy autoloader is the only option to keep everything working properly.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am so happy you figured this out! Had me stuck. Also, I think we're gonna phase out cucumber support I don't think many are using it. (do you?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to help 😄

I've never used cucumber myself. I can't think of too many open-source projects I've seen that have used cucumber either. Based on the number of installs of flatware-cucumber, doesn't seem like there are that many folks who use both flatware and cucumber.

::Cucumber.use_legacy_autoloader ||= true

runtime(Array(feature_files) + options).run!
end

Expand Down
1 change: 1 addition & 0 deletions lib/flatware/cucumber/formatters/console/summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Formatters
class Console
class Summary
include ::Cucumber::Formatter::Console

attr_reader :io, :steps, :scenarios

def initialize(steps, scenarios = [], io = StringIO.new)
Expand Down
6 changes: 3 additions & 3 deletions lib/flatware/pid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def self.ps
.popen(['ps', *args])
.readlines
.map do |row|
fields = row.strip.split(/\s+/, 4)
new(*fields.take(3).map(&:to_i), fields.last)
end
fields = row.strip.split(/\s+/, 4)
new(*fields.take(3).map(&:to_i), fields.last)
end
end

def pids_of_group(group_pid)
Expand Down
12 changes: 6 additions & 6 deletions lib/flatware/rspec/formatters/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def spec_list(remaining)
remaining
.flat_map(&:id).sort.each_with_index
.map do |example, index|
format(
'%<index>4d) %<example>s',
index: index.next,
example: example
)
end.join("\n")
format(
'%<index>4d) %<example>s',
index: index.next,
example: example
)
end.join("\n")
end

def colorizer
Expand Down
36 changes: 19 additions & 17 deletions lib/flatware/rspec/job_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module RSpec
# and attempts to ballence the jobs accordingly.
class JobBuilder
extend Forwardable

attr_reader :args, :workers, :configuration

def_delegators(
Expand Down Expand Up @@ -54,12 +55,12 @@ def timed_and_untimed_files(seconds_per_file)
files_to_run
.map(&method(:normalize_path))
.reduce([[], []]) do |(timed, untimed), file|
if (time = seconds_per_file[file])
[timed + [[file, time]], untimed]
else
[timed, untimed + [file]]
if (time = seconds_per_file[file])
[timed + [[file, time]], untimed]
else
[timed, untimed + [file]]
end
end
end
end

def normalize_path(path)
Expand All @@ -73,14 +74,15 @@ def load_persisted_example_statuses
end

def sum_seconds(statuses)
statuses.select(&passing)
.map { |example| parse_example(**example) }
.reduce({}) do |times, example|
times.merge(
example.fetch(:file_name) => example.fetch(:seconds)
) do |_, old = 0, new|
old + new
end
statuses
.select(&passing)
.map { |example| parse_example(**example) }
.reduce({}) do |times, example|
times.merge(
example.fetch(:file_name) => example.fetch(:seconds)
) do |_, old = 0, new|
old + new
end
end
end

Expand Down Expand Up @@ -109,10 +111,10 @@ def balance_by(count, items, &block)
.sort_by(&block)
.reverse
.each do |entry|
groups.min_by do |group|
group.map(&block).reduce(:+) || 0
end.push(entry)
end
groups.min_by do |group|
group.map(&block).reduce(:+) || 0
end.push(entry)
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/flatware/sink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def group_jobs(jobs, worker_count)
.with_index { |_, i| i % worker_count }
.values
.map do |job_group|
Job.new(job_group.map(&:id).flatten, jobs.first.args)
end
Job.new(job_group.map(&:id).flatten, jobs.first.args)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/flatware/sink/signal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def send_signal(signal)
end

it 'tells the formatter to emit the signal message' do
expect(messages).to match([include(expected_message), 'done.'])
expect(messages).to match([match(expected_message), 'done.'])
end

it 'calls on_interrupt' do
Expand Down