test command echoing

This commit is contained in:
Josh Holtrop 2013-07-07 17:46:01 -04:00
parent 1eb9008885
commit 03f8f56858
2 changed files with 12 additions and 3 deletions

View File

@ -39,6 +39,7 @@ module Rscons
(@variables[:builders] || []).each do |builder| (@variables[:builders] || []).each do |builder|
add_builder(builder) add_builder(builder)
end end
@variables[:echo] ||= :command
end end
def add_builder(builder) def add_builder(builder)
@ -117,9 +118,9 @@ module Rscons
end end
end end
command = expand_varref.call(command.flatten).flatten command = expand_varref.call(command.flatten).flatten
if @echo == :command if @variables[:echo] == :command
puts command.map { |c| c =~ /\s/ ? "'#{c}'" : c }.join(' ') puts command.map { |c| c =~ /\s/ ? "'#{c}'" : c }.join(' ')
elsif @echo == :short elsif @variables[:echo] == :short
puts short_desc puts short_desc
end end
system(*command) system(*command)

View File

@ -13,7 +13,7 @@ describe Rscons do
def build_testdir def build_testdir
if File.exists?("build.rb") if File.exists?("build.rb")
system("ruby -I #{@owd}/lib -r rscons build.rb") system("ruby -I #{@owd}/lib -r rscons build.rb > build.out")
end end
end end
@ -44,6 +44,14 @@ describe Rscons do
`./simple`.should == "This is a simple C program\n" `./simple`.should == "This is a simple C program\n"
end end
it 'prints commands as they are executed' do
test_dir('simple')
File.read('build.out').should == <<EOF
gcc -c -o simple.o -MMD -MF simple.mf simple.c
gcc -o simple simple.o
EOF
end
it 'builds a C program with one source file and one header file' do it 'builds a C program with one source file and one header file' do
test_dir('header') test_dir('header')
File.exists?('header.o').should be_true File.exists?('header.o').should be_true