grosser/parallel_tests · error · RuntimeError

--group-by found and --single-process are not supported

Error message

--group-by found and --single-process are not supported

What it means

--group-by found distributes test files across processes in the order they are discovered on disk, which carries no size or weight information. -s/--single PATTERN depends on size-aware bin-packing to keep all matching files in one process, so parse_options! rejects the combination up front with a RuntimeError.

Source

Thrown at lib/parallel_tests/cli.rb:372

      files, remaining = extract_file_paths(argv)
      unless options[:execute]
        if files.empty?
          default_test_folder = @runner.default_test_folder
          if File.directory?(default_test_folder)
            files = [default_test_folder]
          else
            abort "Pass files or folders to run"
          end
        end
        options[:files] = files.map { |file_path| Pathname.new(file_path).cleanpath.to_s }
      end

      append_test_options(options, remaining)

      options[:group_by] ||= :filesize if options[:only_group]

      if options[:group_by] == :found && options[:single_process]
        raise "--group-by found and --single-process are not supported"
      end
      allowed = [:filesize, :runtime, :found]
      if !allowed.include?(options[:group_by]) && options[:only_group]
        raise "--group-by #{allowed.join(" or ")} is required for --only-group"
      end

      if options[:specify_groups] && options.keys.intersect?([:single_process, :isolate, :isolate_count])
        raise "Can't pass --specify-groups with any of these keys: --single, --isolate, or --isolate-n"
      end

      if options[:failure_exit_code] && options[:highest_exit_status]
        raise "Can't pass --failure-exit-code and --highest-exit-status"
      end

      options
    end

    def extract_file_paths(argv)

View on GitHub (pinned to a06047856d)

Solutions

  1. Drop -s/--single from the command -- 'found' grouping cannot honor it
  2. Switch --group-by to filesize (the default) or runtime so --single works
  3. If deterministic selection was the goal, keep --group-by found and use --only-group to pick group indexes instead of --single

Example fix

# before
parallel_test --group-by found --single spec/features

# after
parallel_test --group-by filesize --single spec/features
Defensive patterns

Strategy: validation

Validate before calling

opts = ENV.fetch('PARALLEL_TEST_OPTS', '').shellsplit
found = opts.include?('--group-by') && opts[opts.index('--group-by') + 1] == 'found'
has_single = opts.any? { |o| o == '-s' || o.start_with?('--single') }
if found && has_single
  abort 'parallel_tests: --group-by found cannot be combined with --single'
end

Type guard

def group_by_found_compatible?(argv)
  return true unless argv.each_slice(2).any? { |flag, v| flag == '--group-by' && v == 'found' }
  argv.none? { |a| a == '-s' || a.start_with?('--single') }
end

Try / catch

begin
  ParallelTests::CLI.new.run(args)
rescue RuntimeError => e
  abort "#{e.message} -- pick one grouping strategy or one placement flag"
end

Prevention

When it happens

Trigger: Any invocation pairing the two: `parallel_test --group-by found -s spec/features` or `--group-by found --single heavy_`; equally through rake, e.g. `rake parallel:spec PARALLEL_TEST_OPTS='--group-by found --single features'`.

Common situations: Switching the grouping strategy to 'found' for deterministic, reproducible distribution while keeping an existing --single flag for feature folders; copying a full flag set from another team's CI config without pruning incompatible parts.

Related errors


AI-assisted analysis of grosser/parallel_tests@a06047856d (2026-08-23). Data as JSON: /api/errors/e9b15affa572c83b. Report an issue: GitHub.