lib/parallel_tests/cli.rb in parallel_tests-3.5.2 vs lib/parallel_tests/cli.rb in parallel_tests-3.6.0
- old
+ new
@@ -103,17 +103,15 @@
end
end
def lock(lockfile)
File.open(lockfile) do |lock|
- begin
- lock.flock File::LOCK_EX
- yield
- ensure
- # This shouldn't be necessary, but appears to be
- lock.flock File::LOCK_UN
- end
+ lock.flock File::LOCK_EX
+ yield
+ ensure
+ # This shouldn't be necessary, but appears to be
+ lock.flock File::LOCK_UN
end
end
def report_results(test_results, options)
results = @runner.find_results(test_results.map { |result| result[:stdout] } * "")
@@ -226,16 +224,14 @@
opts.on("--only-group INT[,INT]", Array) { |groups| options[:only_group] = groups.map(&:to_i) }
opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUMBER']") { |path| options[:execute] = path }
opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = arg.lstrip }
opts.on("-t", "--type [TYPE]", "test(default) / rspec / cucumber / spinach") do |type|
- begin
- @runner = load_runner(type)
- rescue NameError, LoadError => e
- puts "Runner for `#{type}` type has not been found! (#{e})"
- abort
- end
+ @runner = load_runner(type)
+ rescue NameError, LoadError => e
+ puts "Runner for `#{type}` type has not been found! (#{e})"
+ abort
end
opts.on(
"--suffix [PATTERN]",
<<~TEXT.rstrip.split("\n").join("\n#{newline_padding}")
override built in test file pattern (should match suffix):
@@ -276,10 +272,17 @@
options[:non_parallel] = true
end
files, remaining = extract_file_paths(argv)
unless options[:execute]
- abort "Pass files or folders to run" unless files.any?
+ if files.empty?
+ default_test_folder = @runner.default_test_folder
+ if File.directory?(default_test_folder)
+ files = [default_test_folder]
+ else
+ abort "Pass files or folders to run"
+ end
+ end
options[:files] = files.map { |file_path| Pathname.new(file_path).cleanpath.to_s }
end
append_test_options(options, remaining)