Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean file path from cli #748

Merged
merged 1 commit into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/parallel_tests/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'tempfile'
require 'parallel_tests'
require 'shellwords'
require 'pathname'

module ParallelTests
class CLI
Expand Down Expand Up @@ -239,7 +240,7 @@ def parse_options!(argv)
files, remaining = extract_file_paths(argv)
unless options[:execute]
abort "Pass files or folders to run" unless files.any?
options[:files] = files
options[:files] = files.map { |file_path| Pathname.new(file_path).cleanpath.to_s }
end

append_test_options(options, remaining)
Expand Down
6 changes: 5 additions & 1 deletion spec/parallel_tests/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def call(*args)
call(["-n3"])
end

it "cleanups file paths" do
expect(call(["./test"])).to eq(defaults)
end

it "parses execute" do
expect(call(["--exec", "echo"])).to eq(execute: "echo")
end
Expand Down Expand Up @@ -106,10 +110,10 @@ def call(*args)
context "when the -- option separator is used" do
it "interprets arguments as files/directories" do
expect(call(%w(-- test))).to eq( files: %w(test))
expect(call(%w(-- ./test))).to eq( files: %w(test))
expect(call(%w(-- test test2))).to eq( files: %w(test test2))
expect(call(%w(-- --foo test))).to eq( files: %w(--foo test))
expect(call(%w(-- test --foo test2))).to eq( files: %w(test --foo test2))

end

it "corectly handles arguments with spaces" do
Expand Down