Skip to content

Fix flatware rspec spec/foo sometimes running the entire test suite#111

Open
jdelStrother wants to merge 3 commits intobriandunn:masterfrom
jdelStrother:job-groups
Open

Fix flatware rspec spec/foo sometimes running the entire test suite#111
jdelStrother wants to merge 3 commits intobriandunn:masterfrom
jdelStrother:job-groups

Conversation

@jdelStrother
Copy link
Contributor

@jdelStrother jdelStrother commented Dec 11, 2025

When there's a mix of timed_files & untimed_files, the previous behaviour could produce a list of job groups with some empty elements in JobBuilder#balancer_jobs.

This could cause, eg, flatware rspec ./spec/mailers to send an empty file list to one of the spawned workers, causing that worker to run every single spec under ./spec.

I've also updated Cucumber::CLI & RSpec::CLI so that it doesn't spawn unnecessary workers if there's not enough jobs to fill them.

WDYT?

Comment on lines 18 to +34
def cucumber(*args)
config = Cucumber.configure args
jobs = load_jobs(args)

ensure_jobs(config)
formatter = Flatware::Cucumber::Formatters::Console.new($stdout, $stderr)

Flatware.verbose = options[:log]
sink = options['sink-endpoint']
Worker.spawn(count: workers, runner: Cucumber, sink: sink)
start_sink(
jobs: config.jobs,
workers: workers,
formatter: Flatware::Cucumber::Formatters::Console.new($stdout, $stderr)
)

spawn_count = [workers, jobs].min
Worker.spawn(count: spawn_count, runner: Cucumber, sink: options['sink-endpoint'])
start_sink(jobs: jobs, workers: spawn_count, formatter: formatter)
end

private

def ensure_jobs(config)
return if config.jobs.any?
def load_jobs(args)
config = Cucumber.configure args
return config.jobs if config.jobs.any?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed more than strictly necessary here, just so that the Flatware::Cucumber::CLI#cucumber method looks more like Flatware::RSpec::CLI#rspec.

I don't use cucumber myself so would welcome some extra testing here

@jdelStrother jdelStrother force-pushed the job-groups branch 3 times, most recently from d5d7c4e to e4f111b Compare January 10, 2026 12:21
@jdelStrother
Copy link
Contributor Author

rebased onto the latest master

@jdelStrother
Copy link
Contributor Author

Anything I can help clear up on this?

When there's a mix of timed & untimed files, the previous behaviour
could produce a list of job groups with some empty elements.
This could cause, eg, `flatware rspec ./spec/mailers` to send an empty
file list to one of the spawned workers, causing that worker to run
every single spec under ./spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant