check_c_compiler: add integration test for finding second listed C compiler
This commit is contained in:
parent
bdeaec11ba
commit
daa90e431c
@ -25,7 +25,7 @@ describe Rscons do
|
|||||||
|
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@statics = {}
|
@statics = {}
|
||||||
@build_test_run_dir = "build_test_run"
|
@build_test_run_dir = File.expand_path("build_test_run")
|
||||||
@run_results = Struct.new(:stdout, :stderr, :status)
|
@run_results = Struct.new(:stdout, :stderr, :status)
|
||||||
@owd = Dir.pwd
|
@owd = Dir.pwd
|
||||||
rm_rf(@build_test_run_dir)
|
rm_rf(@build_test_run_dir)
|
||||||
@ -40,9 +40,18 @@ describe Rscons do
|
|||||||
Dir.chdir(@owd)
|
Dir.chdir(@owd)
|
||||||
rm_rf(@build_test_run_dir)
|
rm_rf(@build_test_run_dir)
|
||||||
FileUtils.cp_r("build_tests/#{build_test_directory}", @build_test_run_dir)
|
FileUtils.cp_r("build_tests/#{build_test_directory}", @build_test_run_dir)
|
||||||
|
FileUtils.mkdir("#{@build_test_run_dir}/_bin")
|
||||||
Dir.chdir(@build_test_run_dir)
|
Dir.chdir(@build_test_run_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_exe(exe_name, contents)
|
||||||
|
exe_file = "#{@build_test_run_dir}/_bin/#{exe_name}"
|
||||||
|
File.open(exe_file, "wb") do |fh|
|
||||||
|
fh.puts(contents)
|
||||||
|
end
|
||||||
|
FileUtils.chmod(0755, exe_file)
|
||||||
|
end
|
||||||
|
|
||||||
def file_sub(fname)
|
def file_sub(fname)
|
||||||
contents = File.read(fname)
|
contents = File.read(fname)
|
||||||
replaced = ''
|
replaced = ''
|
||||||
@ -104,7 +113,9 @@ EOF
|
|||||||
end
|
end
|
||||||
stdout, stderr, status = nil, nil, nil
|
stdout, stderr, status = nil, nil, nil
|
||||||
Bundler.with_clean_env do
|
Bundler.with_clean_env do
|
||||||
stdout, stderr, status = Open3.capture3(*command)
|
env = ENV.to_h
|
||||||
|
env["PATH"] = "#{@build_test_run_dir}/_bin#{File::PATH_SEPARATOR}#{env["PATH"]}"
|
||||||
|
stdout, stderr, status = Open3.capture3(env, *command)
|
||||||
end
|
end
|
||||||
# Remove output lines generated as a result of the test environment
|
# Remove output lines generated as a result of the test environment
|
||||||
stderr = stderr.lines.find_all do |line|
|
stderr = stderr.lines.find_all do |line|
|
||||||
@ -1498,6 +1509,15 @@ EOF
|
|||||||
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/
|
||||||
end
|
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/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user