add spec for check_cfg with a :package argument

This commit is contained in:
Josh Holtrop 2018-11-25 21:58:22 -05:00
parent b88131eb2f
commit 9e0ce5a55c
2 changed files with 37 additions and 12 deletions

View File

@ -0,0 +1,7 @@
configure do
check_cfg package: "mypackage"
end
Rscons::Environment.new(echo: :command) do |env|
env.Program("myconfigtest", "simple.c")
end

View File

@ -65,6 +65,7 @@ describe Rscons do
def create_exe(exe_name, contents)
exe_file = "#{@build_test_run_dir}/_bin/#{exe_name}"
File.open(exe_file, "wb") do |fh|
fh.puts("#!/bin/sh")
fh.puts(contents)
end
FileUtils.chmod(0755, exe_file)
@ -1790,6 +1791,22 @@ EOF
end
context "check_cfg" do
context "when passed a package" do
it "stores flags and uses them during a build operation" do
test_dir "configure"
create_exe "pkg-config", "echo '-DMYPACKAGE'"
result = run_rscons(rsconscript: "check_cfg_package.rb", op: "configure")
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(result.stdout).to match /Checking for package 'mypackage'\.\.\. found/
result = run_rscons(rsconscript: "check_cfg_package.rb", op: "build")
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(result.stdout).to match /gcc.*-o.*\.o.*-DMYPACKAGE/
end
end
context "when passed a program" do
it "stores flags and uses them during a build operation" do
test_dir "configure"
create_exe "my-config", "echo '-DMYCONFIG -lm'"
@ -1805,5 +1822,6 @@ EOF
end
end
end
end
end