Fix up some configure tests

This commit is contained in:
Josh Holtrop 2022-01-26 21:46:07 -05:00
parent 7189a04299
commit 679c013eaa
8 changed files with 44 additions and 62 deletions

View File

@ -1,3 +1,4 @@
configure do
check_c_compiler "nope.nope"
end
default

View File

@ -1 +0,0 @@
autoconf false

View File

@ -1,3 +1,4 @@
configure do
check_c_compiler
end
default

View File

@ -1,3 +0,0 @@
Environment.new do |env|
env.Object("simple.o", "simple.cc")
end

View File

@ -41,22 +41,15 @@ module Rscons
#
# @param tasks [Array<String>]
# List of task(s) to execute.
# @param options [Hash]
# Optional parameters.
#
# @return [Integer]
# Process exit code (0 on success).
def run(tasks, options = {})
def run(tasks)
Cache.instance["failed_commands"] = []
begin
tasks.each do |task|
Task[task].check_execute
end
0
rescue RsconsError => e
Ansi.write($stderr, :red, e.message, :reset, "\n")
1
tasks.each do |task|
Task[task].check_execute
end
0
end
# Show the last failures.

View File

@ -118,39 +118,44 @@ module Rscons
end
end
# Load the build script.
if rsconscript
Rscons.application.script.load(rsconscript)
begin
# Load the build script.
if rsconscript
Rscons.application.script.load(rsconscript)
end
# Do help after loading the build script (if found) so that any
# script-defined tasks and task options can be displayed.
if do_help
puts usage
return 0
end
# Anything else requires a build script, so complain if we didn't find
# one.
unless rsconscript
$stderr.puts "Could not find the Rsconscript to execute."
$stderr.puts "Looked for: #{DEFAULT_RSCONSCRIPTS.join(", ")}"
return 1
end
# Parse the rest of the command line. This is done after loading the
# build script so that script-defined tasks and task options can be
# taken into account.
tasks = parse_tasks_and_params(argv)
# If no user specified tasks, run "default" task.
if tasks.empty?
tasks << "default"
end
# Finally, with the script fully loaded and command-line parsed, run
# the application to execute all required tasks.
Rscons.application.run(tasks)
rescue RsconsError => e
Ansi.write($stderr, :red, e.message, :reset, "\n")
1
end
# Do help after loading the build script (if found) so that any
# script-defined tasks and task options can be displayed.
if do_help
puts usage
return 0
end
# Anything else requires a build script, so complain if we didn't find
# one.
unless rsconscript
$stderr.puts "Could not find the Rsconscript to execute."
$stderr.puts "Looked for: #{DEFAULT_RSCONSCRIPTS.join(", ")}"
return 1
end
# Parse the rest of the command line. This is done after loading the
# build script so that script-defined tasks and task options can be
# taken into account.
tasks = parse_tasks_and_params(argv)
# If no user specified tasks, run "default" task.
if tasks.empty?
tasks << "default"
end
# Finally, with the script fully loaded and command-line parsed, run
# the application to execute all required tasks.
Rscons.application.run(tasks)
end
def usage

View File

@ -396,7 +396,7 @@ module Rscons
options[:on_fail].call
end
if should_fail
raise RsconsError.new
raise RsconsError.new("Configuration failed")
end
end
end

View File

@ -2365,13 +2365,6 @@ EOF
expect(result.stdout).to match /gcc.*-o.*\.o.*-DHAVE_MATH_H\s.*-DHAVE_STDIO_H/
end
it "exits with an error if the project is not configured and a build is requested and autoconf is false" do
test_dir "configure"
result = run_rscons(args: %w[-f autoconf_false.rb])
expect(result.stderr).to match /Project must be configured first, and autoconf is disabled/
expect(result.status).to_not eq 0
end
it "exits with an error code and message if configuration fails during autoconf" do
test_dir "configure"
result = run_rscons(args: %w[-f autoconf_fail.rb])
@ -2381,13 +2374,6 @@ EOF
expect(lines(result.stderr).last).to eq "Configuration failed"
end
it "exits with an error if configuration has not been performed before attempting to create an environment" do
test_dir "configure"
result = run_rscons(args: %w[-f error_env_construction_before_configure.rb])
expect(result.stderr).to match /Project must be configured before creating an Environment/
expect(result.status).to_not eq 0
end
it "does not rebuild after building with auto-configuration" do
test_dir "configure"
result = run_rscons(args: %w[-f autoconf_rebuild.rb])