Skip to content

Commit

Permalink
(PDK-429) Fix --tests to pass through to unit test handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmjen committed Nov 14, 2017
1 parent 5945270 commit 6ba8945
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
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

0 comments on commit 6ba8945

Please sign in to comment.