add Rscons.command_executer to determine command executer

Use "env" to execute commands when in MSYS on Windows
This commit is contained in:
josh committed 2014-06-12 11:07:09 -04:00
1 parent ef18c9da35
commit 9f75ea9d21
3 files changed
+74 -1

No files matched your search

+46
View File
@@ -66,4 +66,50 @@ describe Rscons do
expect(Rscons.get_system_shell).to eq(["sh", "-c"])
end
end
context "command executer" do
describe ".command_executer" do
before(:each) do
Rscons.class_variable_set(:@@command_executer, nil)
end
after(:each) do
Rscons.class_variable_set(:@@command_executer, nil)
end
it "returns ['env'] if mingw platform in MSYS and 'env' works" do
Object.should_receive(:const_get).and_return("x86-mingw")
ENV.should_receive(:keys).and_return(["MSYSCON"])
io = StringIO.new("success\n")
IO.should_receive(:popen).with(["env", "echo", "success"]).and_yield(io)
expect(Rscons.command_executer).to eq(["env"])
end
it "returns [] if mingw platform in MSYS and 'env' does not work" do
Object.should_receive(:const_get).and_return("x86-mingw")
ENV.should_receive(:keys).and_return(["MSYSCON"])
IO.should_receive(:popen).with(["env", "echo", "success"]).and_raise "ENOENT"
expect(Rscons.command_executer).to eq([])
end
it "returns [] if mingw platform not in MSYS" do
Object.should_receive(:const_get).and_return("x86-mingw")
ENV.should_receive(:keys).and_return(["COMSPEC"])
expect(Rscons.command_executer).to eq([])
end
it "returns [] if not mingw platform" do
Object.should_receive(:const_get).and_return("x86-linux")
expect(Rscons.command_executer).to eq([])
end
end
describe ".command_executer=" do
it "overrides the value of @@command_executer" do
Rscons.class_variable_set(:@@command_executer, ["env"])
Rscons.command_executer = []
expect(Rscons.class_variable_get(:@@command_executer)).to eq([])
end
end
end
end