-
Notifications
You must be signed in to change notification settings - Fork 495
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
Option to output feature files to texts grouped by process. #637
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,18 +63,24 @@ def run_tests_in_parallel(num_processes, options) | |
groups.reject! &:empty? | ||
|
||
test_results = if options[:only_group] | ||
groups_to_run = options[:only_group].collect{|i| groups[i - 1]}.compact | ||
report_number_of_tests(groups_to_run) | ||
execute_in_parallel(groups_to_run, groups_to_run.size, options) do |group| | ||
run_tests(group, groups_to_run.index(group), 1, options) | ||
end | ||
else | ||
report_number_of_tests(groups) | ||
|
||
execute_in_parallel(groups, groups.size, options) do |group| | ||
run_tests(group, groups.index(group), num_processes, options) | ||
end | ||
end | ||
groups_to_run = options[:only_group].collect{|i| groups[i - 1]}.compact | ||
report_number_of_tests(groups_to_run) | ||
execute_in_parallel(groups_to_run, groups_to_run.size, options) do |group| | ||
run_tests(group, groups_to_run.index(group), 1, options) | ||
end | ||
else | ||
report_number_of_tests(groups) | ||
if options[:features_from_process] | ||
ran = [] | ||
for x in 0...num_processes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ran << File.expand_path(Dir.pwd) + "/features_from_process_#{x}.txt" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk why the expand_path is needed if it is added to pwd ... |
||
File.open(File.expand_path(Dir.pwd) + "/features_from_process_#{x}.txt", 'w+') { |file| groups[x].each{|feature| file.write("\n#{feature}")}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't build the path twice |
||
end | ||
end | ||
execute_in_parallel(groups, groups.size, options) do |group| | ||
run_tests(group, groups.index(group), num_processes, options) | ||
end | ||
end | ||
|
||
report_results(test_results, options) | ||
end | ||
|
@@ -85,6 +91,8 @@ def run_tests_in_parallel(num_processes, options) | |
def run_tests(group, process_number, num_processes, options) | ||
if group.empty? | ||
{:stdout => '', :exit_status => 0, :command => '', :seed => nil} | ||
elsif options[:features_from_process] | ||
@runner.run_tests_from_file(process_number, num_processes, options) | ||
else | ||
@runner.run_tests(group, process_number, num_processes, options) | ||
end | ||
|
@@ -216,6 +224,7 @@ def parse_options!(argv) | |
opts.on("--unknown-runtime [FLOAT]", Float, "Use given number as unknown runtime (otherwise use average time)") { |time| options[:unknown_runtime] = time } | ||
opts.on("--first-is-1", "Use \"1\" as TEST_ENV_NUMBER to not reuse the default test environment") { options[:first_is_1] = true } | ||
opts.on("--verbose", "Print more output") { options[:verbose] = true } | ||
opts.on("--features_from_process", "Write features to text file") { options[:features_from_process] = true } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the name does not really convey a purpose/feature to me and neither does the description ... |
||
opts.on("-v", "--version", "Show Version") { puts ParallelTests::VERSION; exit } | ||
opts.on("-h", "--help", "Show this.") { puts opts; exit } | ||
end.parse!(argv) | ||
|
@@ -272,21 +281,21 @@ def load_runner(type) | |
|
||
def execute_shell_command_in_parallel(command, num_processes, options) | ||
runs = if options[:only_group] | ||
options[:only_group].map{|g| g - 1} | ||
else | ||
(0...num_processes).to_a | ||
end | ||
options[:only_group].map{|g| g - 1} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2-space indent plz |
||
else | ||
(0...num_processes).to_a | ||
end | ||
results = if options[:non_parallel] | ||
ParallelTests.with_pid_file do | ||
runs.map do |i| | ||
ParallelTests::Test::Runner.execute_command(command, i, num_processes, options) | ||
end | ||
end | ||
else | ||
execute_in_parallel(runs, runs.size, options) do |i| | ||
ParallelTests::Test::Runner.execute_command(command, i, num_processes, options) | ||
end | ||
end.flatten | ||
ParallelTests.with_pid_file do | ||
runs.map do |i| | ||
ParallelTests::Test::Runner.execute_command(command, i, num_processes, options) | ||
end | ||
end | ||
else | ||
execute_in_parallel(runs, runs.size, options) do |i| | ||
ParallelTests::Test::Runner.execute_command(command, i, num_processes, options) | ||
end | ||
end.flatten | ||
|
||
abort if results.any? { |r| r[:exit_status] != 0 } | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,16 @@ def run_tests(test_files, process_number, num_processes, options) | |
execute_command(cmd, process_number, num_processes, options) | ||
end | ||
|
||
def run_tests_from_file(process_number, num_processes, options) | ||
cmd = [ | ||
executable, | ||
(runtime_logging if File.directory?(File.dirname(runtime_log))), | ||
cucumber_opts(options[:test_options]), | ||
"@features_from_process_#{process_number}.txt" | ||
].compact.reject(&:empty?).join(' ') | ||
execute_command(cmd, process_number, num_processes, options) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. try to reuse the execute_command above maybe with a shared method |
||
end | ||
|
||
def test_file_name | ||
@test_file_name || 'feature' | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2-space indent