From 697db2a987d2c9366764644b36713e5fe2bc4cfa Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 6 Nov 2018 22:39:13 -0500 Subject: [PATCH] specs: check_c_compiler: also test when no arguments are given --- build_tests/configure/check_c_compiler.rb | 3 ++ spec/build_tests_spec.rb | 43 +++++++++++++++-------- 2 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 build_tests/configure/check_c_compiler.rb diff --git a/build_tests/configure/check_c_compiler.rb b/build_tests/configure/check_c_compiler.rb new file mode 100644 index 0000000..44522a9 --- /dev/null +++ b/build_tests/configure/check_c_compiler.rb @@ -0,0 +1,3 @@ +configure do + check_c_compiler +end diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 4dbd648..5fa0560 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -1502,21 +1502,36 @@ EOF end context "check_c_compiler" do - it "finds the first listed C compiler" do - test_dir "configure" - result = run_rscons(rsconsfile: "check_c_compiler_find_first.rb", op: "configure") - expect(result.stderr).to eq "" - expect(result.status).to eq 0 - expect(result.stdout).to match /Checking for C compiler\.\.\. gcc/ - end + {"check_c_compiler.rb" => "when no arguments are given", + "check_c_compiler_find_first.rb" => "when arguments are given"}.each_pair do |rsconsfile, desc| + context desc do + it "finds the first listed C compiler" do + test_dir "configure" + result = run_rscons(rsconsfile: rsconsfile, op: "configure") + expect(result.stderr).to eq "" + expect(result.status).to eq 0 + expect(result.stdout).to match /Checking for C compiler\.\.\. gcc/ + end - it "finds the second listed C compiler" do - test_dir "configure" - create_exe "gcc", "exit 1" - result = run_rscons(rsconsfile: "check_c_compiler_find_first.rb", op: "configure") - expect(result.stderr).to eq "" - expect(result.status).to eq 0 - expect(result.stdout).to match /Checking for C compiler\.\.\. clang/ + it "finds the second listed C compiler" do + test_dir "configure" + create_exe "gcc", "exit 1" + result = run_rscons(rsconsfile: rsconsfile, op: "configure") + expect(result.stderr).to eq "" + expect(result.status).to eq 0 + expect(result.stdout).to match /Checking for C compiler\.\.\. clang/ + end + + it "fails to configure when it cannot find a C compiler" do + test_dir "configure" + create_exe "gcc", "exit 1" + create_exe "clang", "exit 1" + result = run_rscons(rsconsfile: rsconsfile, op: "configure") + expect(result.stderr).to eq "" + expect(result.status).to_not eq 0 + expect(result.stdout).to match /Checking for C compiler\.\.\. not found/ + end + end end end end