specs: check_c_compiler: also test when no arguments are given

This commit is contained in:
Josh Holtrop 2018-11-06 22:39:13 -05:00
parent daa90e431c
commit 697db2a987
2 changed files with 32 additions and 14 deletions

View File

@ -0,0 +1,3 @@
configure do
check_c_compiler
end

View File

@ -1502,9 +1502,12 @@ EOF
end end
context "check_c_compiler" do context "check_c_compiler" do
{"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 it "finds the first listed C compiler" do
test_dir "configure" test_dir "configure"
result = run_rscons(rsconsfile: "check_c_compiler_find_first.rb", op: "configure") result = run_rscons(rsconsfile: rsconsfile, op: "configure")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(result.status).to eq 0 expect(result.status).to eq 0
expect(result.stdout).to match /Checking for C compiler\.\.\. gcc/ expect(result.stdout).to match /Checking for C compiler\.\.\. gcc/
@ -1513,11 +1516,23 @@ EOF
it "finds the second listed C compiler" do it "finds the second listed C compiler" do
test_dir "configure" test_dir "configure"
create_exe "gcc", "exit 1" create_exe "gcc", "exit 1"
result = run_rscons(rsconsfile: "check_c_compiler_find_first.rb", op: "configure") result = run_rscons(rsconsfile: rsconsfile, op: "configure")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(result.status).to eq 0 expect(result.status).to eq 0
expect(result.stdout).to match /Checking for C compiler\.\.\. clang/ expect(result.stdout).to match /Checking for C compiler\.\.\. clang/
end 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
end end