implement ConfigureOp#check_d_import
This commit is contained in:
parent
85b0111a6e
commit
6078cb0977
3
build_tests/configure/check_d_import_failure.rb
Normal file
3
build_tests/configure/check_d_import_failure.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
configure do
|
||||||
|
check_d_import "not.found"
|
||||||
|
end
|
3
build_tests/configure/check_d_import_no_fail.rb
Normal file
3
build_tests/configure/check_d_import_no_fail.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
configure do
|
||||||
|
check_d_import "not.found", fail: false
|
||||||
|
end
|
3
build_tests/configure/check_d_import_success.rb
Normal file
3
build_tests/configure/check_d_import_success.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
configure do
|
||||||
|
check_d_import "std.stdio"
|
||||||
|
end
|
@ -104,6 +104,11 @@ module Rscons
|
|||||||
co.check_cxx_header(*cch)
|
co.check_cxx_header(*cch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if cdis = @script.check_d_imports
|
||||||
|
cdis.each do |cdi|
|
||||||
|
co.check_d_import(*cdi)
|
||||||
|
end
|
||||||
|
end
|
||||||
rescue ConfigureOp::ConfigureFailure
|
rescue ConfigureOp::ConfigureFailure
|
||||||
rv = 1
|
rv = 1
|
||||||
end
|
end
|
||||||
|
@ -140,6 +140,27 @@ module Rscons
|
|||||||
common_config_checks(status, options)
|
common_config_checks(status, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check for a D import.
|
||||||
|
def check_d_import(d_import, options = {})
|
||||||
|
$stdout.write("Checking for D import '#{d_import}'... ")
|
||||||
|
File.open("#{@work_dir}/cfgtest.d", "wb") do |fh|
|
||||||
|
fh.puts <<-EOF
|
||||||
|
import #{d_import};
|
||||||
|
int main() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
end
|
||||||
|
vars = {
|
||||||
|
"LD" => "${DC}",
|
||||||
|
"_SOURCES" => "#{@work_dir}/cfgtest.d",
|
||||||
|
"_TARGET" => "#{@work_dir}/cfgtest.exe",
|
||||||
|
}
|
||||||
|
command = @env.build_command("${LDCMD}", vars)
|
||||||
|
_, _, status = log_and_test_command(command)
|
||||||
|
common_config_checks(status, options)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Test a C compiler.
|
# Test a C compiler.
|
||||||
|
@ -1672,6 +1672,32 @@ EOF
|
|||||||
expect(result.stdout).to match /Checking for C\+\+ header 'not___found\.h'... not found/
|
expect(result.stdout).to match /Checking for C\+\+ header 'not___found\.h'... not found/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "check_d_import" do
|
||||||
|
it "succeeds when the requested import is found" do
|
||||||
|
test_dir "configure"
|
||||||
|
result = run_rscons(rsconsfile: "check_d_import_success.rb", op: "configure")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.status).to eq 0
|
||||||
|
expect(result.stdout).to match /Checking for D import 'std\.stdio'... found/
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails when the requested import is not found" do
|
||||||
|
test_dir "configure"
|
||||||
|
result = run_rscons(rsconsfile: "check_d_import_failure.rb", op: "configure")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.status).to_not eq 0
|
||||||
|
expect(result.stdout).to match /Checking for D import 'not\.found'... not found/
|
||||||
|
end
|
||||||
|
|
||||||
|
it "succeeds when the requested import is not found but :fail is set to false" do
|
||||||
|
test_dir "configure"
|
||||||
|
result = run_rscons(rsconsfile: "check_d_import_no_fail.rb", op: "configure")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.status).to eq 0
|
||||||
|
expect(result.stdout).to match /Checking for D import 'not\.found'... not found/
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user