Option to output feature files to texts grouped by process. #637
Option to output feature files to texts grouped by process. #637Timbyhider wants to merge 1 commit intogrosser:masterfrom
Conversation
| else | ||
| (0...num_processes).to_a | ||
| end | ||
| options[:only_group].map{|g| g - 1} |
| 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) | ||
| if options[:features_from_process] | ||
| ran = [] | ||
| for x in 0...num_processes |
There was a problem hiding this comment.
num_processes.times do |process_number| ?
| ran = [] | ||
| for x in 0...num_processes | ||
| ran << File.expand_path(Dir.pwd) + "/features_from_process_#{x}.txt" | ||
| File.open(File.expand_path(Dir.pwd) + "/features_from_process_#{x}.txt", 'w+') { |file| groups[x].each{|feature| file.write("\n#{feature}")}} |
| ran = [] | ||
| for x in 0...num_processes | ||
| ran << File.expand_path(Dir.pwd) + "/features_from_process_#{x}.txt" | ||
| File.open(File.expand_path(Dir.pwd) + "/features_from_process_#{x}.txt", 'w+') { |file| groups[x].each{|feature| file.write("\n#{feature}")}} |
| if options[:features_from_process] | ||
| ran = [] | ||
| for x in 0...num_processes | ||
| ran << File.expand_path(Dir.pwd) + "/features_from_process_#{x}.txt" |
There was a problem hiding this comment.
idk why the expand_path is needed if it is added to pwd ...
prefer not dumping tempfiles into local directory it messes with git ...
can dump into tmp/ maybe even use Tempfile to get a truly unique file
| 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.
the name does not really convey a purpose/feature to me and neither does the description ...
| 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.
try to reuse the execute_command above maybe with a shared method
|
yeah I heard about that too many files problem before :( ideally it would auto-detect the need for this hackery somehow (on windows + >xyz chars) any idea if this "read from file" logic would work for other test runners too ? needs at least a minimal cli test so I don't break it later on :) |
@grosser
First of all. Thank you for your work on this gem! It has vastly increased the speed of our scripts.
My changes were made in an effort to solve a few issues we were having running test scripts in parallel with our Ruby/Cucumber/Gherkin test suite. I am open to suggestions and happy to add whatever is necessary to get this included and will do my best to support the functionality. These changes give the user the ability to add the --features_by_process option to their job. Once the tests are parsed and divided up they will be stored in .txt files in the project directory as 'features_from_process_<process_number>.txt'
This solves two issues we were having. By outputting the features to text files we are quickly able to rerun subsets of features should one process fail. Additionally, this can help users with large test suites. We have a large test suite and were unable to run the entirety of the suite on less than 8 cores/processes as the commands generated exceeded the character limit of windows commands. The commands generated will run the tests via the @features_from_process_<process_number>.txt format rather than by listing out the path and names of each feature.