diff options
-rw-r--r-- | spec/mixlib/shellout/windows_spec.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/mixlib/shellout/windows_spec.rb b/spec/mixlib/shellout/windows_spec.rb index f35c398..9a5684d 100644 --- a/spec/mixlib/shellout/windows_spec.rb +++ b/spec/mixlib/shellout/windows_spec.rb @@ -37,6 +37,37 @@ describe 'Mixlib::ShellOut::Windows', :windows_only => true do with_command(%q{run.exe %A B% %1%}) { should be_false } with_command(%q{run.exe %A B% %PATH1%}) { should be_true } with_command(%q{run.exe %A B% %_PATH1%}) { should be_true } + + context 'when outside quotes' do + with_command(%q{ruby -e "exit 1" | ruby -e "exit 0"}) { should be_true } + with_command(%q{ruby -e "exit 1" > out.txt}) { should be_true } + with_command(%q{ruby -e "exit 1" > out.txt 2>&1}) { should be_true } + with_command(%q{ruby -e "exit 1" < in.txt}) { should be_true } + with_command(%q{ruby -e "exit 1" || ruby -e "exit 0"}) { should be_true } + with_command(%q{ruby -e "exit 1" && ruby -e "exit 0"}) { should be_true } + with_command(%q{@echo "TRUE"}) { should be_true } + + context 'with unclosed quote' do + with_command(%q{ruby -e "exit 1" | ruby -e "exit 0}) { should be_true } + with_command(%q{ruby -e "exit 1" > "out.txt}) { should be_true } + with_command(%q{ruby -e "exit 1" > "out.txt 2>&1}) { should be_true } + with_command(%q{ruby -e "exit 1" < "in.txt}) { should be_true } + with_command(%q{ruby -e "exit 1" || "ruby -e "exit 0"}) { should be_true } + with_command(%q{ruby -e "exit 1" && "ruby -e "exit 0"}) { should be_true } + with_command(%q{@echo "TRUE}) { should be_true } + + with_command(%q{echo "%PATH%}) { should be_true } + with_command(%q{run.exe "%A}) { should be_false } + with_command(%q{run.exe "B%}) { should be_false } + with_command(%q{run.exe "%A B%}) { should be_false } + with_command(%q{run.exe "%A B% %PATH%}) { should be_true } + with_command(%q{run.exe "%A B% %_PATH%}) { should be_true } + with_command(%q{run.exe "%A B% %PATH_EXT%}) { should be_true } + with_command(%q{run.exe "%A B% %1%}) { should be_false } + with_command(%q{run.exe "%A B% %PATH1%}) { should be_true } + with_command(%q{run.exe "%A B% %_PATH1%}) { should be_true } + end + end end context 'when quoted' do @@ -56,6 +87,25 @@ describe 'Mixlib::ShellOut::Windows', :windows_only => true do with_command(%q{run.exe "%A B% %1%"}) { should be_false } with_command(%q{run.exe "%A B% %PATH1%"}) { should be_true } with_command(%q{run.exe "%A B% %_PATH1%"}) { should be_true } + + context 'with unclosed quote' do + with_command(%q{run.exe "ruby -e 'exit 1' || ruby -e 'exit 0'}) { should be_false } + with_command(%q{run.exe "ruby -e 'exit 1' > out.txt}) { should be_false } + with_command(%q{run.exe "ruby -e 'exit 1' > out.txt 2>&1}) { should be_false } + with_command(%q{run.exe "ruby -e 'exit 1' < in.txt}) { should be_false } + with_command(%q{run.exe "ruby -e 'exit 1' || ruby -e 'exit 0'}) { should be_false } + with_command(%q{run.exe "ruby -e 'exit 1' && ruby -e 'exit 0'}) { should be_false } + with_command(%q{run.exe "%PATH%}) { should be_true } + with_command(%q{run.exe "%A}) { should be_false } + with_command(%q{run.exe "B%}) { should be_false } + with_command(%q{run.exe "%A B%}) { should be_false } + with_command(%q{run.exe "%A B% %PATH%}) { should be_true } + with_command(%q{run.exe "%A B% %_PATH%}) { should be_true } + with_command(%q{run.exe "%A B% %PATH_EXT%}) { should be_true } + with_command(%q{run.exe "%A B% %1%}) { should be_false } + with_command(%q{run.exe "%A B% %PATH1%}) { should be_true } + with_command(%q{run.exe "%A B% %_PATH1%}) { should be_true } + end end end end |