From 0face546e396c403c2a897ffc061cdea167f95f8 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 15 Nov 2021 21:45:18 -0500 Subject: [PATCH] Clarify failed command error message indicating to run -F - close #133 --- lib/rscons/environment.rb | 2 +- lib/rscons/util.rb | 8 ++++++++ spec/build_tests_spec.rb | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 143ca64..4c53240 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -286,7 +286,7 @@ module Rscons unless @process_failures.empty? msg = @process_failures.join("\n") if Cache.instance["failed_commands"].size > 0 - msg += "\nUse -F to view the failed command log from the previous build operation" + msg += "\nUse `#{Util.command_to_execute_me} -F` to view the failed command log from the previous build operation" end raise RsconsError.new(msg) end diff --git a/lib/rscons/util.rb b/lib/rscons/util.rb index d5de077..120176c 100644 --- a/lib/rscons/util.rb +++ b/lib/rscons/util.rb @@ -217,6 +217,14 @@ module Rscons queue.pop end + # Command that can be run to execute this instance of rscons from the + # current working directory. + def command_to_execute_me + command = Pathname.new(File.expand_path($0)).relative_path_from(Dir.pwd).to_s + command = "./#{command}" unless command["/"] + command + end + private # Check if a directory contains a certain executable. diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index b364c55..696fd12 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -1066,7 +1066,7 @@ EOF result = run_rscons expect(result.stderr).to match /Failed to build/ - expect(result.stderr).to match /^Use.*-F.*to view the failed command log/ + expect(result.stderr).to match %r{^Use .*/rscons(\.rb)? -F.*to view the failed command log} expect(result.status).to_not eq 0 result = run_rscons(rscons_args: %w[-F])