From 9975eec16567c38fb44f1fb5b8afbea1e6ef6602 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 23 Nov 2018 22:23:01 -0500 Subject: [PATCH] add build test for check_cfg - close #59 --- build_tests/configure/check_cfg.rb | 7 +++++++ build_tests/configure/simple.c | 6 ++++++ lib/rscons/configure_op.rb | 2 +- spec/build_tests_spec.rb | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 build_tests/configure/check_cfg.rb create mode 100644 build_tests/configure/simple.c diff --git a/build_tests/configure/check_cfg.rb b/build_tests/configure/check_cfg.rb new file mode 100644 index 0000000..29243d3 --- /dev/null +++ b/build_tests/configure/check_cfg.rb @@ -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 diff --git a/build_tests/configure/simple.c b/build_tests/configure/simple.c new file mode 100644 index 0000000..ee61f1f --- /dev/null +++ b/build_tests/configure/simple.c @@ -0,0 +1,6 @@ +#include + +int main(int argc, char *argv[]) +{ + printf("This is a simple C program\n"); +} diff --git a/lib/rscons/configure_op.rb b/lib/rscons/configure_op.rb index 9171dcd..2f3fe5f 100644 --- a/lib/rscons/configure_op.rb +++ b/lib/rscons/configure_op.rb @@ -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] diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 52f4b1a..a14923c 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -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