summaryrefslogtreecommitdiff
path: root/spec/mixlib/shellout/windows_spec.rb
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-04-02 20:54:49 -0400
committerHo-Sheng Hsiao <hosh@opscode.com>2012-05-10 14:51:43 -0400
commit37117fdc7fa08be7783b7f38abad7e5a771047eb (patch)
tree412c5237ad246cb77ede7b75d17106883b9356d5 /spec/mixlib/shellout/windows_spec.rb
parentec7dfe16926ebb7ecfefda365e5706954b761c3a (diff)
downloadmixlib-shellout-37117fdc7fa08be7783b7f38abad7e5a771047eb.tar.gz
[CHEF-2994][WINDOWS] Added edge cases to specs for Utils.should_run_under_cmd?()
Diffstat (limited to 'spec/mixlib/shellout/windows_spec.rb')
-rw-r--r--spec/mixlib/shellout/windows_spec.rb50
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