update builder messages - close #77

This commit is contained in:
Josh Holtrop 2019-02-18 22:30:11 -05:00
parent 658b73e4de
commit 983862a528
20 changed files with 140 additions and 101 deletions

View File

@ -3,7 +3,7 @@ class MyBuilder < Rscons::Builder
if @thread if @thread
true true
else else
@env.print_builder_run_message("#{name} #{target}", nil) print_run_message("#{name} #{target}", nil)
@thread = Thread.new do @thread = Thread.new do
sleep 2 sleep 2
FileUtils.touch(@target) FileUtils.touch(@target)

View File

@ -1,5 +1,5 @@
build do build do
Environment.new do |env| Environment.new(echo: :command) do |env|
tempdir = ENV["TEMP"] || ENV["TMP"] || "/tmp" tempdir = ENV["TEMP"] || ENV["TMP"] || "/tmp"
source_file = File.join(tempdir, "abs.c") source_file = File.join(tempdir, "abs.c")
File.open(source_file, "w") do |fh| File.open(source_file, "w") do |fh|

View File

@ -7,7 +7,7 @@ class MyObject < Rscons::Builder
false false
end end
else else
@env.print_builder_run_message("#{name} #{@target}", nil) print_run_message("#{name} #{@target}", nil)
@builder = @env.Object(@target, @sources, @vars) @builder = @env.Object(@target, @sources, @vars)
wait_for(@builder) wait_for(@builder)
end end

View File

@ -6,7 +6,7 @@ class TestBuilder < Rscons::Builder
fh.puts("hi") fh.puts("hi")
end end
msg = "#{name} #{@target}" msg = "#{name} #{@target}"
@env.print_builder_run_message(msg, msg) print_run_message(msg, msg)
@cache.register_build(@target, command, @sources, @env) @cache.register_build(@target, command, @sources, @env)
end end
true true

View File

@ -1,6 +1,6 @@
class MyBuilder < Rscons::Builder class MyBuilder < Rscons::Builder
def run(options) def run(options)
@env.print_builder_run_message("MyBuilder #{@target}", "MyBuilder #{@target} command") print_run_message("MyBuilder #{@target}", "MyBuilder #{@target} command")
true true
end end
end end

View File

@ -119,6 +119,19 @@ module Rscons
raise "This method must be overridden in a subclass" raise "This method must be overridden in a subclass"
end end
# Print the builder run message, depending on the Environment's echo mode.
#
# @param short_description [String]
# Builder short description, printed if the echo mode is :short, or if
# there is no command.
# @param command [Array<String>]
# Builder command, printed if the echo mode is :command.
#
# @return [void]
def print_run_message(short_description, command)
@env.print_builder_run_message(self, short_description, command)
end
# Create a {Command} object to execute the build command in a thread. # Create a {Command} object to execute the build command in a thread.
# #
# @param short_description [String] # @param short_description [String]
@ -138,7 +151,7 @@ module Rscons
if options[:stdout] if options[:stdout]
command_options[:system_options] = {out: options[:stdout]} command_options[:system_options] = {out: options[:stdout]}
end end
@env.print_builder_run_message(short_description, @command) print_run_message(short_description, @command)
wait_for(Command.new(command, self, command_options)) wait_for(Command.new(command, self, command_options))
end end

View File

@ -26,17 +26,18 @@ module Rscons
else else
@vars["_TARGET"] = @target @vars["_TARGET"] = @target
@vars["_SOURCES"] = @sources @vars["_SOURCES"] = @sources
cmd =
case case
when @sources.first.end_with?(*@env.expand_varref("${LEXSUFFIX}")) when @sources.first.end_with?(*@env.expand_varref("${LEXSUFFIX}"))
"LEX" cmd = "LEX"
message = "Generating lexer"
when @sources.first.end_with?(*@env.expand_varref("${YACCSUFFIX}")) when @sources.first.end_with?(*@env.expand_varref("${YACCSUFFIX}"))
"YACC" cmd = "YACC"
message = "Generating parser"
else else
raise "Unknown source file #{@sources.first.inspect} for CFile builder" raise "Unknown source file #{@sources.first.inspect} for CFile builder"
end end
command = @env.build_command("${#{cmd}_CMD}", @vars) command = @env.build_command("${#{cmd}_CMD}", @vars)
standard_command("#{cmd} #{@target}", command) standard_command("#{message} from #{Util.short_format_paths(@sources)} => #{@target}", command)
end end
end end

View File

@ -23,7 +23,7 @@ module Rscons
if @vars["CMD_STDOUT"] if @vars["CMD_STDOUT"]
options[:stdout] = @env.expand_varref("${CMD_STDOUT}", @vars) options[:stdout] = @env.expand_varref("${CMD_STDOUT}", @vars)
end end
standard_command("#{cmd_desc} #{@target}", command, options) standard_command("#{cmd_desc} => #{@target}", command, options)
end end
end end

View File

@ -11,7 +11,7 @@ module Rscons
Ansi.write($stderr, :red, "Error: `#{@target}' already exists and is not a directory", :reset, "\n") Ansi.write($stderr, :red, "Error: `#{@target}' already exists and is not a directory", :reset, "\n")
false false
else else
@env.print_builder_run_message("Directory #{@target}", nil) print_run_message("Creating directory => #{@target}", nil)
@cache.mkdir_p(@target) @cache.mkdir_p(@target)
true true
end end

View File

@ -16,7 +16,7 @@ module Rscons
else else
@vars["_SOURCES"] = @sources @vars["_SOURCES"] = @sources
command = @env.build_command("${DISASM_CMD}", @vars) command = @env.build_command("${DISASM_CMD}", @vars)
standard_command("Disassemble #{target}", command, stdout: @target) standard_command("Disassembling #{Util.short_format_paths(@sources)} => #{target}", command, stdout: @target)
end end
end end

View File

@ -34,7 +34,8 @@ module Rscons
# Check the cache and copy if necessary # Check the cache and copy if necessary
unless @cache.up_to_date?(dest, :Copy, [src], @env) unless @cache.up_to_date?(dest, :Copy, [src], @env)
unless printed_message unless printed_message
@env.print_builder_run_message("#{name} #{@target}", nil) message = "#{name} #{Util.short_format_paths(@sources)} => #{@target}"
print_run_message(message, nil)
printed_message = true printed_message = true
end end
@cache.mkdir_p(File.dirname(dest)) @cache.mkdir_p(File.dirname(dest))

View File

@ -27,7 +27,7 @@ module Rscons
@vars["_TARGET"] = @target @vars["_TARGET"] = @target
@vars["_SOURCES"] = @objects @vars["_SOURCES"] = @objects
command = @env.build_command("${ARCMD}", @vars) command = @env.build_command("${ARCMD}", @vars)
standard_command("AR #{@target}", command, sources: @objects) standard_command("Building static library archive => #{@target}", command, sources: @objects)
end end
end end

View File

@ -95,7 +95,9 @@ module Rscons
end.first end.first
command = @env.build_command("${#{com_prefix}CMD}", @vars) command = @env.build_command("${#{com_prefix}CMD}", @vars)
@env.produces(@target, @vars["_DEPFILE"]) @env.produces(@target, @vars["_DEPFILE"])
standard_command("#{com_prefix} #{@target}", command) verb = com_prefix == "AS" ? "Assembling" : "Compiling"
message = "#{verb} #{Util.short_format_paths(@sources)}"
standard_command(message, command)
end end
end end

View File

@ -35,7 +35,7 @@ module Rscons
@vars["_DEPFILE"] = Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", vars)) @vars["_DEPFILE"] = Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", vars))
command = @env.build_command("${CPP_CMD}", @vars) command = @env.build_command("${CPP_CMD}", @vars)
@env.produces(@target, @vars["_DEPFILE"]) @env.produces(@target, @vars["_DEPFILE"])
standard_command("#{name} #{@target}", command) standard_command("Preprocessing #{Util.short_format_paths(@sources)} => #{@target}", command)
end end
end end

View File

@ -59,7 +59,7 @@ module Rscons
@vars["_SOURCES"] = @objects @vars["_SOURCES"] = @objects
@vars["LD"] = ld @vars["LD"] = ld
command = @env.build_command("${LDCMD}", @vars) command = @env.build_command("${LDCMD}", @vars)
standard_command("LD #{@target}", command, sources: @objects) standard_command("Linking => #{@target}", command, sources: @objects)
end end
end end

View File

@ -60,7 +60,7 @@ module Rscons
@vars["_SOURCES"] = @objects @vars["_SOURCES"] = @objects
@vars["SHLD"] = ld @vars["SHLD"] = ld
command = @env.build_command("${SHLDCMD}", @vars) command = @env.build_command("${SHLDCMD}", @vars)
standard_command("SHLD #{@target}", command, sources: @objects) standard_command("Linking => #{@target}", command, sources: @objects)
end end
end end

View File

@ -80,7 +80,9 @@ module Rscons
end.first end.first
command = @env.build_command("${#{com_prefix}CMD}", @vars) command = @env.build_command("${#{com_prefix}CMD}", @vars)
@env.produces(@target, @vars["_DEPFILE"]) @env.produces(@target, @vars["_DEPFILE"])
standard_command("#{com_prefix} #{@target}", command) verb = com_prefix == "AS" ? "Assembling" : "Compiling"
message = "#{verb} #{Util.short_format_paths(@sources)}"
standard_command(message, command)
end end
end end

View File

@ -512,13 +512,16 @@ module Rscons
# Print the builder run message, depending on the Environment's echo mode. # Print the builder run message, depending on the Environment's echo mode.
# #
# @param builder [Builder]
# The {Builder} that is executing.
# @param short_description [String] # @param short_description [String]
# Builder short description, printed if the echo mode is :short. # Builder short description, printed if the echo mode is :short, or if
# there is no command.
# @param command [Array<String>] # @param command [Array<String>]
# Builder command, printed if the echo mode is :command. # Builder command, printed if the echo mode is :command.
# #
# @return [void] # @return [void]
def print_builder_run_message(short_description, command) def print_builder_run_message(builder, short_description, command)
case @echo case @echo
when :command when :command
if command.is_a?(Array) if command.is_a?(Array)

View File

@ -26,6 +26,23 @@ module Rscons
command.map { |c| c =~ /\s/ ? "'#{c}'" : c }.join(' ') command.map { |c| c =~ /\s/ ? "'#{c}'" : c }.join(' ')
end end
# Return a string showing the path specified, or if more than one, then
# the first path with a "(+D)" afterward, where D is the number of
# remaining paths.
#
# @param paths [Array<String>]
# Paths.
#
# @return [String]
# Condensed path readout.
def short_format_paths(paths)
if paths.size == 1
paths.first
else
"#{paths.first} (#{paths.size - 1})"
end
end
# Look for an executable. # Look for an executable.
# #
# @return [String, nil] # @return [String, nil]

View File

@ -188,8 +188,8 @@ EOF
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
'CC build/e.1/header.o', "Compiling header.c",
"LD header.exe", "Linking => header.exe",
] ]
end end
@ -217,8 +217,8 @@ EOF
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
'CC build/e.1/header.o', "Compiling header.c",
"LD header.exe", "Linking => header.exe",
] ]
expect(`./header.exe`).to eq "The value is 2\n" expect(`./header.exe`).to eq "The value is 2\n"
result = run_rscons result = run_rscons
@ -231,8 +231,8 @@ EOF
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
'CC build/e.1/header.o', "Compiling header.c",
"LD header.exe", "Linking => header.exe",
] ]
expect(`./header.exe`).to eq "The value is 2\n" expect(`./header.exe`).to eq "The value is 2\n"
sleep 0.05 sleep 0.05
@ -305,7 +305,7 @@ EOF
test_dir('custom_builder') test_dir('custom_builder')
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["CC build/e.1/program.o", "LD program.exe"] expect(lines(result.stdout)).to include *["Compiling program.c", "Linking => program.exe"]
expect(File.exists?('inc.h')).to be_truthy expect(File.exists?('inc.h')).to be_truthy
expect(`./program.exe`).to eq "The value is 5678\n" expect(`./program.exe`).to eq "The value is 5678\n"
end end
@ -315,7 +315,7 @@ EOF
result = run_rscons(rsconscript: "multiple_targets.rb") result = run_rscons(rsconscript: "multiple_targets.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
slines = lines(result.stdout) slines = lines(result.stdout)
expect(slines).to include("CHGen inc.c", "CC build/e.1/program.o", "CC build/e.1/inc.o", "LD program.exe") expect(slines).to include("CHGen inc.c", "Compiling program.c", "Compiling inc.c", "Linking => program.exe")
expect(File.exists?("inc.c")).to be_truthy expect(File.exists?("inc.c")).to be_truthy
expect(File.exists?("inc.h")).to be_truthy expect(File.exists?("inc.h")).to be_truthy
expect(`./program.exe`).to eq "The value is 42\n" expect(`./program.exe`).to eq "The value is 42\n"
@ -453,19 +453,19 @@ EOF
File.open("program.ld", "w") {|fh| fh.puts("1")} File.open("program.ld", "w") {|fh| fh.puts("1")}
result = run_rscons(rsconscript: "user_dependencies.rb") result = run_rscons(rsconscript: "user_dependencies.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["CC build/e.1/simple.o", "LD simple.exe"] expect(lines(result.stdout)).to include *["Compiling simple.c", "Linking => simple.exe"]
expect(File.exists?('build/e.1/simple.o')).to be_truthy expect(File.exists?('build/e.1/simple.o')).to be_truthy
expect(`./simple.exe`).to eq "This is a simple C program\n" expect(`./simple.exe`).to eq "This is a simple C program\n"
File.open("program.ld", "w") {|fh| fh.puts("2")} File.open("program.ld", "w") {|fh| fh.puts("2")}
result = run_rscons(rsconscript: "user_dependencies.rb") result = run_rscons(rsconscript: "user_dependencies.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["LD simple.exe"] expect(lines(result.stdout)).to include *["Linking => simple.exe"]
File.unlink("program.ld") File.unlink("program.ld")
result = run_rscons(rsconscript: "user_dependencies.rb") result = run_rscons(rsconscript: "user_dependencies.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["LD simple.exe"] expect(lines(result.stdout)).to include *["Linking => simple.exe"]
result = run_rscons(rsconscript: "user_dependencies.rb") result = run_rscons(rsconscript: "user_dependencies.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
@ -515,9 +515,9 @@ EOF
#expect(result.stderr).to eq "" #expect(result.stderr).to eq ""
slines = lines(result.stdout) slines = lines(result.stdout)
if RUBY_PLATFORM =~ /mingw/ if RUBY_PLATFORM =~ /mingw/
expect(slines).to include("SHLD mine.dll") expect(slines).to include("Linking => mine.dll")
else else
expect(slines).to include("SHLD libmine.so") expect(slines).to include("Linking => libmine.so")
end end
end end
end end
@ -561,7 +561,7 @@ EOF
test_dir('custom_builder') test_dir('custom_builder')
result = run_rscons(rsconscript: "cvar_expansion.rb") result = run_rscons(rsconscript: "cvar_expansion.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["CC build/e.1/program.o", "LD program.exe"] expect(lines(result.stdout)).to include *["Compiling program.c", "Linking => program.exe"]
expect(File.exists?('inc.h')).to be_truthy expect(File.exists?('inc.h')).to be_truthy
expect(`./program.exe`).to eq "The value is 678\n" expect(`./program.exe`).to eq "The value is 678\n"
end end
@ -625,11 +625,11 @@ EOF
result = run_rscons(rsconscript: "assuffix.rb") result = run_rscons(rsconscript: "assuffix.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC one.ssss", "Compiling one.c",
"CC two.sss", "Compiling two.c",
"AS build/e.1/one.o", "Assembling one.ssss",
"AS build/e.1/two.o", "Assembling two.sss",
"LD two_sources.exe", "Linking => two_sources.exe",
] ]
expect(File.exists?("two_sources.exe")).to be_truthy expect(File.exists?("two_sources.exe")).to be_truthy
expect(`./two_sources.exe`).to eq "This is a C program with two sources.\n" expect(`./two_sources.exe`).to eq "This is a C program with two sources.\n"
@ -650,7 +650,7 @@ EOF
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include "Preprocess pp" expect(lines(result.stdout)).to include "Preprocessing foo.h => pp"
expect(File.read("pp")).to match(%r{xyz42abc}m) expect(File.read("pp")).to match(%r{xyz42abc}m)
result = run_rscons result = run_rscons
@ -662,7 +662,7 @@ EOF
end end
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include "Preprocess pp" expect(lines(result.stdout)).to include "Preprocessing foo.h => pp"
expect(File.read("pp")).to match(%r{abc88xyz}m) expect(File.read("pp")).to match(%r{abc88xyz}m)
end end
@ -680,8 +680,8 @@ EOF
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(File.exists?("one.o")).to be_truthy expect(File.exists?("one.o")).to be_truthy
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC one.o", "Compiling src/one/one.c",
"CC one.o", "Compiling src/two/two.c",
] ]
end end
@ -692,8 +692,8 @@ EOF
expect(File.exists?("one.o")).to be_truthy expect(File.exists?("one.o")).to be_truthy
expect(File.exists?("two.o")).to be_truthy expect(File.exists?("two.o")).to be_truthy
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC one.o", "Compiling src/one/one.c",
"CC two.o", "Compiling src/two/two.c",
] ]
end end
@ -713,7 +713,7 @@ EOF
rscons_args: %w[-j1]) rscons_args: %w[-j1])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC two.o", "Compiling two.c",
] ]
end end
@ -722,8 +722,8 @@ EOF
result = run_rscons(rsconscript: "progsuffix.rb") result = run_rscons(rsconscript: "progsuffix.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC build/e.1/simple.o", "Compiling simple.c",
"LD simple.out", "Linking => simple.out",
] ]
end end
@ -732,8 +732,8 @@ EOF
result = run_rscons(rsconscript: "progsuffix2.rb") result = run_rscons(rsconscript: "progsuffix2.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC build/e.1/simple.o", "Compiling simple.c",
"LD simple.out", "Linking => simple.out",
] ]
end end
@ -742,8 +742,8 @@ EOF
result = run_rscons(rsconscript: "progsuffix3.rb") result = run_rscons(rsconscript: "progsuffix3.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC build/e.1/simple.o", "Compiling simple.c",
"LD simple.xyz", "Linking => simple.xyz",
] ]
end end
@ -752,8 +752,8 @@ EOF
result = run_rscons(rsconscript: "absolute_source_path.rb") result = run_rscons(rsconscript: "absolute_source_path.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
slines = lines(result.stdout) slines = lines(result.stdout)
expect(slines).to include a_string_matching %r{^CC build/e.1/.*/abs\.o$} expect(slines).to include a_string_matching %r{build/e.1/.*/abs\.o$}
expect(slines).to include "LD abs.exe" expect(slines).to include a_string_matching %r{\babs.exe\b}
end end
it "creates shared libraries" do it "creates shared libraries" do
@ -763,10 +763,10 @@ EOF
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
slines = lines(result.stdout) slines = lines(result.stdout)
if RUBY_PLATFORM =~ /mingw/ if RUBY_PLATFORM =~ /mingw/
expect(slines).to include("SHLD mine.dll") expect(slines).to include("Linking => mine.dll")
expect(File.exists?("mine.dll")).to be_truthy expect(File.exists?("mine.dll")).to be_truthy
else else
expect(slines).to include("SHLD libmine.so") expect(slines).to include("Linking => libmine.so")
expect(File.exists?("libmine.so")).to be_truthy expect(File.exists?("libmine.so")).to be_truthy
end end
@ -786,9 +786,9 @@ EOF
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
slines = lines(result.stdout) slines = lines(result.stdout)
if RUBY_PLATFORM =~ /mingw/ if RUBY_PLATFORM =~ /mingw/
expect(slines).to include("SHLD mine.dll") expect(slines).to include("Linking => mine.dll")
else else
expect(slines).to include("SHLD libmine.so") expect(slines).to include("Linking => libmine.so")
end end
result = run_rscons(rsconscript: "shared_library_cxx.rb") result = run_rscons(rsconscript: "shared_library_cxx.rb")
@ -842,7 +842,7 @@ EOF
result = run_rscons(rsconscript: "echo_command_ruby_builder.rb") result = run_rscons(rsconscript: "echo_command_ruby_builder.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["Install inst.exe"] expect(lines(result.stdout)).to include *["Install install.rb => inst.exe"]
end end
it "supports a string for a builder's echoed 'command' with Environment#print_builder_run_message" do it "supports a string for a builder's echoed 'command' with Environment#print_builder_run_message" do
@ -883,8 +883,8 @@ EOF
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"LEX lexer.c", "Generating lexer from lexer.l => lexer.c",
"YACC parser.c", "Generating parser from parser.y => parser.c",
] ]
result = run_rscons result = run_rscons
@ -906,7 +906,7 @@ EOF
result = run_rscons(rsconscript: "command_builder.rb") result = run_rscons(rsconscript: "command_builder.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["BuildIt simple.exe"] expect(lines(result.stdout)).to include *["BuildIt => simple.exe"]
expect(`./simple.exe`).to eq "This is a simple C program\n" expect(`./simple.exe`).to eq "This is a simple C program\n"
result = run_rscons(rsconscript: "command_builder.rb") result = run_rscons(rsconscript: "command_builder.rb")
@ -920,8 +920,8 @@ EOF
result = run_rscons(rsconscript: "command_redirect.rb") result = run_rscons(rsconscript: "command_redirect.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC simple.o", "Compiling simple.c",
"My Disassemble simple.txt", "My Disassemble => simple.txt",
] ]
expect(File.read("simple.txt")).to match /Disassembly of section .text:/ expect(File.read("simple.txt")).to match /Disassembly of section .text:/
end end
@ -932,7 +932,7 @@ EOF
test_dir("simple") test_dir("simple")
result = run_rscons(rsconscript: "directory.rb") result = run_rscons(rsconscript: "directory.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["Directory teh_dir"] expect(lines(result.stdout)).to include *["Creating directory => teh_dir"]
expect(File.directory?("teh_dir")).to be_truthy expect(File.directory?("teh_dir")).to be_truthy
end end
@ -941,7 +941,7 @@ EOF
FileUtils.mkdir("teh_dir") FileUtils.mkdir("teh_dir")
result = run_rscons(rsconscript: "directory.rb") result = run_rscons(rsconscript: "directory.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to_not include a_string_matching /Directory/ expect(lines(result.stdout)).to_not include a_string_matching /Creating directory/
expect(File.directory?("teh_dir")).to be_truthy expect(File.directory?("teh_dir")).to be_truthy
end end
@ -959,7 +959,7 @@ EOF
result = run_rscons(rsconscript: "install.rb") result = run_rscons(rsconscript: "install.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["Install inst.exe"] expect(lines(result.stdout)).to include *["Install install.rb => inst.exe"]
result = run_rscons(rsconscript: "install.rb") result = run_rscons(rsconscript: "install.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
@ -971,7 +971,7 @@ EOF
FileUtils.rm("inst.exe") FileUtils.rm("inst.exe")
result = run_rscons(rsconscript: "install.rb") result = run_rscons(rsconscript: "install.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["Install inst.exe"] expect(lines(result.stdout)).to include *["Install install.rb => inst.exe"]
end end
it "operates the same as a Copy builder" do it "operates the same as a Copy builder" do
@ -979,7 +979,7 @@ EOF
result = run_rscons(rsconscript: "copy.rb") result = run_rscons(rsconscript: "copy.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["Copy inst.exe"] expect(lines(result.stdout)).to include *["Copy copy.rb => inst.exe"]
result = run_rscons(rsconscript: "copy.rb") result = run_rscons(rsconscript: "copy.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
@ -991,7 +991,7 @@ EOF
FileUtils.rm("inst.exe") FileUtils.rm("inst.exe")
result = run_rscons(rsconscript: "copy.rb") result = run_rscons(rsconscript: "copy.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["Copy inst.exe"] expect(lines(result.stdout)).to include *["Copy copy.rb => inst.exe"]
end end
it "copies a file to the target directory name" do it "copies a file to the target directory name" do
@ -999,7 +999,7 @@ EOF
result = run_rscons(rsconscript: "install_directory.rb") result = run_rscons(rsconscript: "install_directory.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include("Install inst") expect(lines(result.stdout)).to include("Install install_directory.rb => inst")
expect(File.exists?("inst/install_directory.rb")).to be_truthy expect(File.exists?("inst/install_directory.rb")).to be_truthy
expect(File.read("inst/install_directory.rb", mode: "rb")).to eq(File.read("install_directory.rb", mode: "rb")) expect(File.read("inst/install_directory.rb", mode: "rb")).to eq(File.read("install_directory.rb", mode: "rb"))
@ -1012,7 +1012,7 @@ EOF
test_dir("typical") test_dir("typical")
result = run_rscons(rsconscript: "install_directory.rb") result = run_rscons(rsconscript: "install_directory.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include("Install noexist/src") expect(lines(result.stdout)).to include("Install src => noexist/src")
%w[src/one/one.c src/two/two.c src/two/two.h].each do |f| %w[src/one/one.c src/two/two.c src/two/two.h].each do |f|
expect(File.exists?("noexist/#{f}")).to be_truthy expect(File.exists?("noexist/#{f}")).to be_truthy
expect(File.read("noexist/#{f}", mode: "rb")).to eq(File.read(f, mode: "rb")) expect(File.read("noexist/#{f}", mode: "rb")).to eq(File.read(f, mode: "rb"))
@ -1023,7 +1023,7 @@ EOF
test_dir("typical") test_dir("typical")
result = run_rscons(rsconscript: "install_directory.rb") result = run_rscons(rsconscript: "install_directory.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include("Install exist/src") expect(lines(result.stdout)).to include("Install src => exist/src")
%w[src/one/one.c src/two/two.c src/two/two.h].each do |f| %w[src/one/one.c src/two/two.c src/two/two.h].each do |f|
expect(File.exists?("exist/#{f}")).to be_truthy expect(File.exists?("exist/#{f}")).to be_truthy
expect(File.read("exist/#{f}", mode: "rb")).to eq(File.read(f, mode: "rb")) expect(File.read("exist/#{f}", mode: "rb")).to eq(File.read(f, mode: "rb"))
@ -1038,8 +1038,8 @@ EOF
result = run_rscons(rsconscript: "phony_target.rb") result = run_rscons(rsconscript: "phony_target.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC build/e.1/simple.o", "Compiling simple.c",
"LD simple.exe", "Linking => simple.exe",
"Checker simple.exe", "Checker simple.exe",
] ]
@ -1065,7 +1065,7 @@ EOF
test_dir("simple") test_dir("simple")
result = run_rscons(rsconscript: "clear_targets.rb") result = run_rscons(rsconscript: "clear_targets.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to_not include a_string_matching %r{LD} expect(lines(result.stdout)).to_not include a_string_matching %r{Linking}
end end
end end
@ -1128,14 +1128,14 @@ EOF
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC build/e.1/simple.o", "Compiling simple.c",
"LD simple.exe", "Linking => simple.exe",
] ]
result = run_rscons(rsconscript: "cache_command_change.rb") result = run_rscons(rsconscript: "cache_command_change.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"LD simple.exe", "Linking => simple.exe",
] ]
end end
@ -1145,14 +1145,14 @@ EOF
result = run_rscons(rsconscript: "cache_new_dep1.rb") result = run_rscons(rsconscript: "cache_new_dep1.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC simple.o", "Compiling simple.c",
"LD simple.exe", "Linking => simple.exe",
] ]
result = run_rscons(rsconscript: "cache_new_dep2.rb") result = run_rscons(rsconscript: "cache_new_dep2.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"LD simple.exe", "Linking => simple.exe",
] ]
end end
@ -1161,14 +1161,14 @@ EOF
result = run_rscons(rsconscript: "cache_dep_checksum_change.rb") result = run_rscons(rsconscript: "cache_dep_checksum_change.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["Copy simple.copy"] expect(lines(result.stdout)).to include *["Copy simple.c => simple.copy"]
File.open("simple.c", "wb") do |fh| File.open("simple.c", "wb") do |fh|
fh.write("hi") fh.write("hi")
end end
result = run_rscons(rsconscript: "cache_dep_checksum_change.rb") result = run_rscons(rsconscript: "cache_dep_checksum_change.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *["Copy simple.copy"] expect(lines(result.stdout)).to include *["Copy simple.c => simple.copy"]
end end
it "forces a rebuild with strict_deps=true when dependency order changes" do it "forces a rebuild with strict_deps=true when dependency order changes" do
@ -1201,15 +1201,15 @@ EOF
result = run_rscons(rsconscript: "cache_user_dep.rb") result = run_rscons(rsconscript: "cache_user_dep.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC build/e.1/simple.o", "Compiling simple.c",
"LD simple.exe", "Linking => simple.exe",
] ]
File.open("user_deps", "wb") {|fh| fh.write("foo")} File.open("user_deps", "wb") {|fh| fh.write("foo")}
result = run_rscons(rsconscript: "cache_user_dep.rb") result = run_rscons(rsconscript: "cache_user_dep.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"LD simple.exe", "Linking => simple.exe",
] ]
end end
@ -1221,8 +1221,8 @@ EOF
result = run_rscons(rsconscript: "cache_user_dep.rb") result = run_rscons(rsconscript: "cache_user_dep.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"CC build/e.1/simple.o", "Compiling simple.c",
"LD simple.exe", "Linking => simple.exe",
] ]
result = run_rscons(rsconscript: "cache_user_dep.rb") result = run_rscons(rsconscript: "cache_user_dep.rb")
@ -1233,7 +1233,7 @@ EOF
result = run_rscons(rsconscript: "cache_user_dep.rb") result = run_rscons(rsconscript: "cache_user_dep.rb")
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(lines(result.stdout)).to include *[ expect(lines(result.stdout)).to include *[
"LD simple.exe", "Linking => simple.exe",
] ]
end end
@ -1378,9 +1378,9 @@ EOF
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
slines = lines(result.stdout) slines = lines(result.stdout)
if RUBY_PLATFORM =~ /mingw/ if RUBY_PLATFORM =~ /mingw/
expect(slines).to include("SHLD mine.dll") expect(slines).to include("Linking => mine.dll")
else else
expect(slines).to include("SHLD libmine.so") expect(slines).to include("Linking => libmine.so")
end end
end end
end end
@ -1934,7 +1934,7 @@ EOF
test_dir('simple') test_dir('simple')
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(result.stdout).to match /CC .*simple\.o/ expect(result.stdout).to match /Compiling.*simple\.c/
end end
it "echoes commands by default with -v" do it "echoes commands by default with -v" do