add build test for check_cfg - close #59

This commit is contained in:
Josh Holtrop 2018-11-23 22:23:01 -05:00
parent 04c0a6a86f
commit 9975eec165
4 changed files with 30 additions and 1 deletions

View File

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

View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("This is a simple C program\n");
}

View File

@ -85,7 +85,7 @@ module Rscons
if package = options[:package]
Ansi.write($stdout, "Checking for package '", :cyan, package, :reset, "'... ")
elsif program = options[:program]
Ansi.write($stdout, "Checking ", :cyan, program, :reset, "... ")
Ansi.write($stdout, "Checking '", :cyan, program, :reset, "'... ")
end
program ||= "pkg-config"
args = options[:args] || %w[--cflags --libs]

View File

@ -1756,6 +1756,22 @@ EOF
expect(result.stdout).to match /Checking for program 'program-that-is-not-found'... not found/
end
end
context "check_cfg" do
it "stores flags and uses them during a build operation" do
test_dir "configure"
create_exe "my-config", "echo '-DMYCONFIG -lm'"
result = run_rscons(rsconsfile: "check_cfg.rb", op: "configure")
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(result.stdout).to match /Checking 'my-config'\.\.\. found/
result = run_rscons(rsconsfile: "check_cfg.rb", op: "build")
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(result.stdout).to match /gcc.*-o.*\.o.*-DMYCONFIG/
expect(result.stdout).to match /gcc.*-o myconfigtest.*-lm/
end
end
end
end