From 679c013eaabeeed28e35b11f6444aacba75506b9 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 26 Jan 2022 21:46:07 -0500 Subject: [PATCH] Fix up some configure tests --- build_tests/configure/autoconf_fail.rb | 1 + build_tests/configure/autoconf_false.rb | 1 - build_tests/configure/check_c_compiler.rb | 1 + ...error_env_construction_before_configure.rb | 3 - lib/rscons/application.rb | 15 ++-- lib/rscons/cli.rb | 69 ++++++++++--------- lib/rscons/configure_op.rb | 2 +- spec/build_tests_spec.rb | 14 ---- 8 files changed, 44 insertions(+), 62 deletions(-) delete mode 100644 build_tests/configure/autoconf_false.rb delete mode 100644 build_tests/configure/error_env_construction_before_configure.rb diff --git a/build_tests/configure/autoconf_fail.rb b/build_tests/configure/autoconf_fail.rb index 6caedf6..d72e071 100644 --- a/build_tests/configure/autoconf_fail.rb +++ b/build_tests/configure/autoconf_fail.rb @@ -1,3 +1,4 @@ configure do check_c_compiler "nope.nope" end +default diff --git a/build_tests/configure/autoconf_false.rb b/build_tests/configure/autoconf_false.rb deleted file mode 100644 index d630ac1..0000000 --- a/build_tests/configure/autoconf_false.rb +++ /dev/null @@ -1 +0,0 @@ -autoconf false diff --git a/build_tests/configure/check_c_compiler.rb b/build_tests/configure/check_c_compiler.rb index 44522a9..fcfcafc 100644 --- a/build_tests/configure/check_c_compiler.rb +++ b/build_tests/configure/check_c_compiler.rb @@ -1,3 +1,4 @@ configure do check_c_compiler end +default diff --git a/build_tests/configure/error_env_construction_before_configure.rb b/build_tests/configure/error_env_construction_before_configure.rb deleted file mode 100644 index 83e7703..0000000 --- a/build_tests/configure/error_env_construction_before_configure.rb +++ /dev/null @@ -1,3 +0,0 @@ -Environment.new do |env| - env.Object("simple.o", "simple.cc") -end diff --git a/lib/rscons/application.rb b/lib/rscons/application.rb index ba6e959..33d8c9e 100644 --- a/lib/rscons/application.rb +++ b/lib/rscons/application.rb @@ -41,22 +41,15 @@ module Rscons # # @param tasks [Array] # 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. diff --git a/lib/rscons/cli.rb b/lib/rscons/cli.rb index 00198a6..29f9b60 100644 --- a/lib/rscons/cli.rb +++ b/lib/rscons/cli.rb @@ -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 diff --git a/lib/rscons/configure_op.rb b/lib/rscons/configure_op.rb index 9e59722..d4cdea1 100644 --- a/lib/rscons/configure_op.rb +++ b/lib/rscons/configure_op.rb @@ -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 diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 659ff90..89fea88 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -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])