2013-01-04 16:41:18 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "libv8 locations" do
|
|
|
|
before do
|
2013-08-05 15:34:35 -04:00
|
|
|
@context = double(:CompilationContext)
|
2013-01-04 16:41:18 -05:00
|
|
|
end
|
2015-04-09 06:23:43 -04:00
|
|
|
|
2013-01-04 16:41:18 -05:00
|
|
|
describe "the system location" do
|
|
|
|
before do
|
|
|
|
@location = Libv8::Location::System.new
|
|
|
|
@context.stub(:dir_config)
|
|
|
|
end
|
2015-04-09 06:23:43 -04:00
|
|
|
|
2013-01-04 16:41:18 -05:00
|
|
|
describe "configuring a compliation context with it" do
|
|
|
|
before do
|
|
|
|
@context.stub(:find_header) {true}
|
2015-01-21 20:24:26 -05:00
|
|
|
@context.stub(:have_library) {true}
|
2013-01-04 16:41:18 -05:00
|
|
|
@location.configure @context
|
|
|
|
end
|
2015-04-09 06:23:43 -04:00
|
|
|
|
2013-01-04 16:41:18 -05:00
|
|
|
it "adds the include path to the front of the include flags" do
|
2013-08-05 15:34:35 -04:00
|
|
|
@context.should have_received(:dir_config).with('v8').at_least(:once)
|
|
|
|
@context.should have_received(:find_header).with('v8.h').at_least(:once)
|
2015-01-21 20:24:26 -05:00
|
|
|
@context.should have_received(:have_library).with('v8').at_least(:once)
|
|
|
|
end
|
|
|
|
end
|
2015-04-09 06:23:43 -04:00
|
|
|
|
2015-01-21 20:24:26 -05:00
|
|
|
describe "when the v8 library cannot be found" do
|
|
|
|
before do
|
|
|
|
@context.stub(:find_header) {true}
|
|
|
|
@context.stub(:have_library) {false}
|
|
|
|
end
|
2015-04-09 06:23:43 -04:00
|
|
|
|
2015-01-21 20:24:26 -05:00
|
|
|
it "raises a NotFoundError" do
|
|
|
|
expect {@location.configure @context}.to raise_error Libv8::Location::System::NotFoundError
|
2013-01-04 16:41:18 -05:00
|
|
|
end
|
|
|
|
end
|
2015-04-09 06:23:43 -04:00
|
|
|
|
2013-01-04 16:41:18 -05:00
|
|
|
describe "when the v8.h header cannot be found" do
|
|
|
|
before do
|
|
|
|
@context.stub(:find_header) {false}
|
2015-01-21 20:24:26 -05:00
|
|
|
@context.stub(:have_library) {true}
|
2013-01-04 16:41:18 -05:00
|
|
|
end
|
2015-04-09 06:23:43 -04:00
|
|
|
|
2013-01-04 16:41:18 -05:00
|
|
|
it "raises a NotFoundError" do
|
|
|
|
expect {@location.configure @context}.to raise_error Libv8::Location::System::NotFoundError
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "the vendor location" do
|
|
|
|
before do
|
|
|
|
@location = Libv8::Location::Vendor.new
|
|
|
|
@context.stub(:incflags) {@incflags ||= "-I/usr/include -I/usr/local/include"}
|
|
|
|
@context.stub(:ldflags) {@ldflags ||= "-lobjc -lpthread"}
|
|
|
|
|
2015-04-09 06:33:03 -04:00
|
|
|
Libv8::Paths.stub(:vendored_source_path) {"/foo bar/v8"}
|
|
|
|
Libv8::Arch.stub(:libv8_arch) {'x64'}
|
2013-01-04 16:41:18 -05:00
|
|
|
@location.configure @context
|
|
|
|
end
|
|
|
|
|
|
|
|
it "prepends its own incflags before any pre-existing ones" do
|
2015-04-09 06:33:03 -04:00
|
|
|
@context.incflags.should eql "-I/foo\\ bar/v8/include -I/usr/include -I/usr/local/include"
|
2013-01-04 16:41:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "prepends the locations of any libv8 objects on the the ldflags" do
|
2015-04-09 06:33:03 -04:00
|
|
|
@context.ldflags.should eql "/foo\\ bar/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a /foo\\ bar/v8/out/x64.release/obj.target/tools/gyp/libv8_snapshot.a -lobjc -lpthread"
|
2013-01-04 16:41:18 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|