Skip to content

Commit

Permalink
fixing a bug in concurrent run if a single feature file is given
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdeepv committed Oct 2, 2015
1 parent d7f3aa1 commit 3216e79
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
16 changes: 11 additions & 5 deletions lib/parallel_calabash/feature_grouper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/parallel_calabash/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ParallelCalabash
VERSION = "0.2.2"
VERSION = "0.2.3"
end
5 changes: 5 additions & 0 deletions spec/lib/parallel_calabash/feature_grouper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3216e79

Please sign in to comment.