Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding parser to extract files from cucumber profile #576

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/parallel_tests/cli.rb
Expand Up @@ -211,6 +211,7 @@ def parse_options!(argv)

files, remaining = extract_file_paths(argv)
unless options[:execute]
files = extract_files_from_cucumber_profile(options) if files.empty?
abort "Pass files or folders to run" unless files.any?
options[:files] = files
end
Expand All @@ -228,6 +229,17 @@ def parse_options!(argv)
options
end

def extract_files_from_cucumber_profile(options)
return unless @runner.name == 'cucumber'
profile = nil
if options.key?(:test_options)
OptionParser.new do |opts|
opts.on("-p", "--profile [PROFILE]") { |option| profile = option }
end.parse!(options[:test_options].split(' '))
end
@runner.files_from_profile(profile) if profile
end

def extract_file_paths(argv)
dash_index = argv.rindex("--")
file_args_at = (dash_index || -1) + 1
Expand Down
6 changes: 6 additions & 0 deletions lib/parallel_tests/cucumber/runner.rb
@@ -1,4 +1,5 @@
require "parallel_tests/gherkin/runner"
require 'cucumber'

module ParallelTests
module Cucumber
Expand Down Expand Up @@ -28,6 +29,11 @@ def summarize_results(results)
output.join("\n\n")
end


Copy link
Owner

Choose a reason for hiding this comment

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

remove extra line

def files_from_profile(name)
::Cucumber::Cli::ProfileLoader.new.args_from(name).grep(self.test_suffix)
Copy link
Owner

Choose a reason for hiding this comment

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

don't need the self.

end

def command_with_seed(cmd, seed)
clean = cmd.sub(/\s--order\s+random(:\d+)?\b/, '')
"#{clean} --order random:#{seed}"
Expand Down