spec/build_tests_spec.rb in rscons-1.3.0 vs spec/build_tests_spec.rb in rscons-1.4.0
- old
+ new
@@ -1,7 +1,16 @@
require 'fileutils'
+class Dir
+ class << self
+ alias_method :orig_bracket, :[]
+ end
+ def self.[](*args)
+ orig_bracket(*args).sort
+ end
+end
+
describe Rscons do
BUILD_TEST_RUN_DIR = "build_test_run"
before(:all) do
FileUtils.rm_rf(BUILD_TEST_RUN_DIR)
@@ -178,10 +187,27 @@
env.Program('build_dir', Dir['src/**/*.c'])
end
lines.should == ["CC build_root/src/one/one.o", "CC build_root/src/two/two.o", "LD build_dir"]
end
+ it "expands target and source paths starting with ^/ to be relative to the build root" do
+ test_dir('build_dir')
+ Rscons::Environment.new(echo: :command) do |env|
+ env.append('CPPPATH' => Dir['src/**/*/'])
+ env.build_root = "build_root"
+ FileUtils.mkdir_p(env.build_root)
+ FileUtils.mv("src/one/one.c", "build_root")
+ env.Object("^/one.o", "^/one.c")
+ env.Program('build_dir', Dir['src/**/*.c'] + ["^/one.o"])
+ end
+ lines.should == [
+ %q{gcc -c -o build_root/one.o -MMD -MF build_root/one.mf -Isrc/one/ -Isrc/two/ build_root/one.c},
+ %q{gcc -c -o build_root/src/two/two.o -MMD -MF build_root/src/two/two.mf -Isrc/one/ -Isrc/two/ src/two/two.c},
+ %q{gcc -o build_dir build_root/src/two/two.o build_root/one.o},
+ ]
+ end
+
it 'cleans built files' do
test_dir('build_dir')
Rscons::Environment.new do |env|
env.append('CPPPATH' => Dir['src/**/*/'])
env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/')
@@ -425,7 +451,37 @@
"gdc -c -o main.o main.d",
"gdc -o hello-d main.o",
]
`./hello-d`.rstrip.should == "Hello from D!"
end
+ end
+
+ it "supports disassembling object files" do
+ test_dir("simple")
+ Rscons::Environment.new do |env|
+ env.Object("simple.o", "simple.c")
+ env.Disassemble("simple.txt", "simple.o")
+ end
+ File.exists?("simple.txt").should be_true
+ File.read("simple.txt").should =~ /Disassembly of section .text:/
+ end
+
+ it "supports preprocessing C sources" do
+ test_dir("simple")
+ Rscons::Environment.new do |env|
+ env.Preprocess("simplepp.c", "simple.c")
+ env.Program("simple", "simplepp.c")
+ end
+ File.read("simplepp.c").should =~ /# \d+ "simple.c"/
+ `./simple`.should == "This is a simple C program\n"
+ end
+
+ it "supports preprocessing C++ sources" do
+ test_dir("simple_cc")
+ Rscons::Environment.new do |env|
+ env.Preprocess("simplepp.cc", "simple.cc")
+ env.Program("simple", "simplepp.cc")
+ end
+ File.read("simplepp.cc").should =~ /# \d+ "simple.cc"/
+ `./simple`.should == "This is a simple C++ program\n"
end
end