diff --git a/Gemfile.lock b/Gemfile.lock index 7ea901b..3a119c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - parallel_cucumber (0.1.14) + parallel_cucumber (0.1.15) parallel (~> 1.6) GEM diff --git a/lib/parallel_cucumber/cli.rb b/lib/parallel_cucumber/cli.rb index 3de3bc2..e2808db 100644 --- a/lib/parallel_cucumber/cli.rb +++ b/lib/parallel_cucumber/cli.rb @@ -39,10 +39,6 @@ def parse_options!(argv) options[:thread_delay] = thread_delay end opts.on('-n [PROCESSES]', Integer, 'How many processes to use') { |n| options[:n] = n } - - opts.on('--workaround-for-profile-with-reporters "[OPTIONS]"') do |profile_with_reporters| - options[:profile_with_reporters] = profile_with_reporters - end end option_parser.parse!(argv) diff --git a/lib/parallel_cucumber/feature_grouper.rb b/lib/parallel_cucumber/feature_grouper.rb index 62d49e2..713d956 100644 --- a/lib/parallel_cucumber/feature_grouper.rb +++ b/lib/parallel_cucumber/feature_grouper.rb @@ -1,4 +1,6 @@ +require 'erb' require 'json' +require 'yaml' module ParallelCucumber class FeatureGrouper @@ -43,11 +45,9 @@ def scenario_groups(group_size, options) end def generate_dry_run_report(options) - cucumber_options = options[:cucumber_options].gsub(/(--format|-f|--output|-o)\s+[^\s]+/, '') - unless options[:profile_with_reporters].nil? - profile_with_reporters = options[:profile_with_reporters] - cucumber_options = cucumber_options.gsub(/(--profile|-p)\s+#{profile_with_reporters}(\s+|$)/, '') - end + cucumber_options = options[:cucumber_options] + cucumber_options = expand_profiles(cucumber_options) unless cucumber_config_file.nil? + cucumber_options = cucumber_options.gsub(/(--format|-f|--out|-o)\s+[^\s]+/, '') cmd = "cucumber #{cucumber_options} --dry-run --format json #{options[:cucumber_args].join(' ')}" dry_run_report = `#{cmd} 2>/dev/null` @@ -65,6 +65,31 @@ def generate_dry_run_report(options) end end + def cucumber_config_file + Dir.glob('{,.config/,config/}cucumber{.yml,.yaml}').first + end + + def expand_profiles(cucumber_options) + config = YAML.load(ERB.new(File.read(cucumber_config_file)).result) + _expand_profiles(cucumber_options, config) + end + + def _expand_profiles(options, config) + expand_next = false + options.split.map do |option| + case + when %w(-p --profile).include?(option) + expand_next = true + next + when expand_next + expand_next = false + _expand_profiles(config[option], config) + else + option + end + end.compact.join(' ') + end + def group_creator(groups_count, tasks) groups = Array.new(groups_count) { [] } diff --git a/lib/parallel_cucumber/version.rb b/lib/parallel_cucumber/version.rb index 3b6e172..dd779cd 100644 --- a/lib/parallel_cucumber/version.rb +++ b/lib/parallel_cucumber/version.rb @@ -1,3 +1,3 @@ module ParallelCucumber - VERSION = '0.1.14' + VERSION = '0.1.15' end # ParallelCucumber