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

(PDK-429) Fix --tests to pass through to unit test handler. #351

Merged
merged 1 commit into from
Nov 16, 2017
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
7 changes: 4 additions & 3 deletions lib/pdk/tests/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
module PDK
module Test
class Unit
def self.cmd(_tests, opts = {})
# TODO: test selection
opts.key?(:parallel) ? 'parallel_spec' : 'spec'
def self.cmd(tests, opts = {})
rake_args = opts.key?(:parallel) ? 'parallel_spec' : 'spec'
rake_args += "[#{tests}]" unless tests.nil?
rake_args
end

def self.rake_bin
Expand Down
16 changes: 16 additions & 0 deletions spec/unit/pdk/cli/test/unit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@
}
end
end

context 'with specific tests passed in' do
let(:tests) { '/path/to/file1,/path/to/file2' }

before(:each) do
expect(PDK::CLI::Util::OptionValidator).to receive(:comma_separated_list?).with(tests).and_return(true)
end

it do
expect {
test_unit_cmd.run_this(["--tests=#{tests}"])
}.to raise_error(SystemExit) { |e|
expect(e.status).to eq 0
}
end
end
end

context 'when tests fail' do
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/pdk/test/unit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@
expect(cmd).to eq('spec')
end
end

context 'when run with tests option' do
it 'passes file paths to rake' do
cmd = described_class.cmd('/path/to/test1,/path/to/test2')

expect(cmd).to eq('spec[/path/to/test1,/path/to/test2]')
end
end
end

describe '.parse_output' do
Expand Down