From 3216e798e2fad2bd502cae19d8f0800fbf7b0567 Mon Sep 17 00:00:00 2001 From: Rajdeep Date: Fri, 2 Oct 2015 10:53:06 +0530 Subject: [PATCH] fixing a bug in concurrent run if a single feature file is given --- lib/parallel_calabash/feature_grouper.rb | 16 +++++++++++----- lib/parallel_calabash/version.rb | 2 +- .../parallel_calabash/feature_grouper_spec.rb | 5 +++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/parallel_calabash/feature_grouper.rb b/lib/parallel_calabash/feature_grouper.rb index 643fa92..49755a4 100644 --- a/lib/parallel_calabash/feature_grouper.rb +++ b/lib/parallel_calabash/feature_grouper.rb @@ -83,16 +83,22 @@ def generate_dry_run_report options %x( cucumber #{options[:cucumber_options]} --dry-run -f json --out parallel_calabash_dry_run.json #{options[:feature_folder].join(' ')} ) end - def feature_files_in_folder(feature_dir) - if File.directory?(feature_dir.first) - files = Dir[File.join(feature_dir, "**{,/*/**}/*")].uniq + def feature_files_in_folder(feature_dir_or_file) + if File.directory?(feature_dir_or_file.first) + files = Dir[File.join(feature_dir_or_file, "**{,/*/**}/*")].uniq files.grep(/\.feature$/) - elsif File.file?(feature_dir.first) - scenarios = File.open(feature_dir.first).collect{ |line| line.split(' ') } + elsif feature_folder_has_single_feature?(feature_dir_or_file) + feature_dir_or_file + elsif File.file?(feature_dir_or_file.first) + scenarios = File.open(feature_dir_or_file.first).collect{ |line| line.split(' ') } scenarios.flatten end end + def feature_folder_has_single_feature?(feature_dir) + feature_dir.first.include?('.feature') + end + def weight_of_feature(feature_file, weighing_factor) content = File.read(feature_file) content.scan(/#{weighing_factor}\b/).size diff --git a/lib/parallel_calabash/version.rb b/lib/parallel_calabash/version.rb index 7f4a7ce..c3bb6c4 100644 --- a/lib/parallel_calabash/version.rb +++ b/lib/parallel_calabash/version.rb @@ -1,3 +1,3 @@ module ParallelCalabash - VERSION = "0.2.2" + VERSION = "0.2.3" end diff --git a/spec/lib/parallel_calabash/feature_grouper_spec.rb b/spec/lib/parallel_calabash/feature_grouper_spec.rb index f740e27..97ba2ae 100644 --- a/spec/lib/parallel_calabash/feature_grouper_spec.rb +++ b/spec/lib/parallel_calabash/feature_grouper_spec.rb @@ -54,6 +54,11 @@ ["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]] end + it 'should create 2 group for concurrent 2 processes if single feature file is given' do + expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder => ['spec/test_data/features/aaa.feature'], :concurrent => true}, 2)).to eq \ + [["spec/test_data/features/aaa.feature"], ["spec/test_data/features/aaa.feature"]] + end + end describe :feature_weight do