update build_tests_spec to invoke rscons in a subprocess for each test
This commit is contained in:
parent
2d8e08b493
commit
28e56251dd
5
build_tests/build_dir/Rsconsfile
Normal file
5
build_tests/build_dir/Rsconsfile
Normal file
@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.append('CPPPATH' => Dir['src/**/*/'].sort)
|
||||
env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/')
|
||||
env.Program('build_dir.exe', Dir['src/**/*.c'])
|
||||
end
|
6
build_tests/build_dir/build_dirs_and_root.rb
Normal file
6
build_tests/build_dir/build_dirs_and_root.rb
Normal file
@ -0,0 +1,6 @@
|
||||
env = Rscons::Environment.new do |env|
|
||||
env.append('CPPPATH' => Dir['src/**/*/'].sort)
|
||||
env.build_dir("src", "build")
|
||||
env.build_root = "build_root"
|
||||
env.Program('build_dir.exe', Dir['src/**/*.c'])
|
||||
end
|
12
build_tests/build_dir/build_hooks.rb
Normal file
12
build_tests/build_dir/build_hooks.rb
Normal file
@ -0,0 +1,12 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.append('CPPPATH' => Dir['src/**/*/'].sort)
|
||||
env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/')
|
||||
env.add_build_hook do |build_op|
|
||||
if build_op[:target] =~ %r{build_one/.*\.o}
|
||||
build_op[:vars]["CFLAGS"] << "-O1"
|
||||
elsif build_op[:target] =~ %r{build_two/.*\.o}
|
||||
build_op[:vars]["CFLAGS"] << "-O2"
|
||||
end
|
||||
end
|
||||
env.Program('build_hook.exe', Dir['src/**/*.c'].sort)
|
||||
end
|
8
build_tests/build_dir/carat.rb
Normal file
8
build_tests/build_dir/carat.rb
Normal file
@ -0,0 +1,8 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.append('CPPPATH' => Dir['src/**/*/'].sort)
|
||||
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.exe", Dir['src/**/*.c'] + ["^/one.o"])
|
||||
end
|
3
build_tests/build_dir/copy.rb
Normal file
3
build_tests/build_dir/copy.rb
Normal file
@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Copy("inst.exe", "copy.rb")
|
||||
end
|
6
build_tests/build_dir/csuffix.rb
Normal file
6
build_tests/build_dir/csuffix.rb
Normal file
@ -0,0 +1,6 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["CSUFFIX"] = %w[.yargh .c]
|
||||
env["CFLAGS"] += %w[-x c]
|
||||
env["CPPPATH"] += Dir["src/**/"]
|
||||
env.Program("build_dir.exe", Dir["src/**/*.{c,yargh}"])
|
||||
end
|
3
build_tests/build_dir/install.rb
Normal file
3
build_tests/build_dir/install.rb
Normal file
@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Install("inst.exe", "install.rb")
|
||||
end
|
9
build_tests/build_dir/install_directory.rb
Normal file
9
build_tests/build_dir/install_directory.rb
Normal file
@ -0,0 +1,9 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Directory("inst")
|
||||
env.Install("inst", "install_directory.rb")
|
||||
|
||||
env.Install("noexist/src", "src")
|
||||
|
||||
env.Directory("exist/src")
|
||||
env.Install("exist/src", "src")
|
||||
end
|
5
build_tests/build_dir/multiple_targets_same_name.rb
Normal file
5
build_tests/build_dir/multiple_targets_same_name.rb
Normal file
@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["CPPPATH"] << "src/two"
|
||||
env.Object("one.o", "src/one/one.c")
|
||||
env.Object("one.o", "src/two/two.c")
|
||||
end
|
6
build_tests/build_dir/no_match_build_dir.rb
Normal file
6
build_tests/build_dir/no_match_build_dir.rb
Normal file
@ -0,0 +1,6 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.append('CPPPATH' => Dir['src/**/*/'].sort)
|
||||
env.build_dir("src2", "build")
|
||||
env.build_root = "build_root"
|
||||
env.Program('build_dir.exe', Dir['src/**/*.c'])
|
||||
end
|
10
build_tests/build_dir/post_build_hook_expansion.rb
Normal file
10
build_tests/build_dir/post_build_hook_expansion.rb
Normal file
@ -0,0 +1,10 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["CPPPATH"] << "src/two"
|
||||
env.Object("one.o", "src/one/one.c")
|
||||
env.add_post_build_hook do |build_op|
|
||||
if build_op[:target] == "one.o"
|
||||
env["MODULE"] = "two"
|
||||
env.Object("${MODULE}.o", "src/${MODULE}/${MODULE}.c")
|
||||
end
|
||||
end
|
||||
end
|
6
build_tests/build_dir/slashes.rb
Normal file
6
build_tests/build_dir/slashes.rb
Normal file
@ -0,0 +1,6 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.append("CPPPATH" => Dir["src/**/*/"].sort)
|
||||
env.build_dir("src/one/", "build_one/")
|
||||
env.build_dir("src/two", "build_two")
|
||||
env.Program("build_dir.exe", Dir["src/**/*.c"])
|
||||
end
|
12
build_tests/clone_env/Rsconsfile
Normal file
12
build_tests/clone_env/Rsconsfile
Normal file
@ -0,0 +1,12 @@
|
||||
debug = Rscons::Environment.new(echo: :command) do |env|
|
||||
env.build_dir('src', 'debug')
|
||||
env['CFLAGS'] = '-O2'
|
||||
env['CPPFLAGS'] = '-DSTRING="Debug Version"'
|
||||
env.Program('program-debug.exe', Dir['src/*.c'])
|
||||
end
|
||||
|
||||
release = debug.clone do |env|
|
||||
env["CPPFLAGS"] = '-DSTRING="Release Version"'
|
||||
env.build_dir('src', 'release')
|
||||
env.Program('program-release.exe', Dir['src/*.c'])
|
||||
end
|
15
build_tests/clone_env/clone_all.rb
Normal file
15
build_tests/clone_env/clone_all.rb
Normal file
@ -0,0 +1,15 @@
|
||||
env1 = Rscons::Environment.new(echo: :command) do |env|
|
||||
env.build_dir('src', 'build')
|
||||
env['CFLAGS'] = '-O2'
|
||||
env.add_build_hook do |build_op|
|
||||
build_op[:vars]['CPPFLAGS'] = '-DSTRING="Hello"'
|
||||
end
|
||||
env.add_post_build_hook do |build_op|
|
||||
$stdout.puts "post #{build_op[:target]}"
|
||||
end
|
||||
env.Program('program.exe', Dir['src/*.c'])
|
||||
end
|
||||
|
||||
env2 = env1.clone(clone: :all) do |env|
|
||||
env.Program('program2.exe', Dir['src/*.c'])
|
||||
end
|
16
build_tests/custom_builder/Rsconsfile
Normal file
16
build_tests/custom_builder/Rsconsfile
Normal file
@ -0,0 +1,16 @@
|
||||
class MySource < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
File.open(target, 'w') do |fh|
|
||||
fh.puts <<EOF
|
||||
#define THE_VALUE 5678
|
||||
EOF
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(MySource.new)
|
||||
env.MySource('inc.h', [])
|
||||
env.Program('program.exe', Dir['*.c'])
|
||||
end
|
18
build_tests/custom_builder/cvar_expansion.rb
Normal file
18
build_tests/custom_builder/cvar_expansion.rb
Normal file
@ -0,0 +1,18 @@
|
||||
class MySource < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
File.open(target, 'w') do |fh|
|
||||
fh.puts <<EOF
|
||||
#define THE_VALUE 678
|
||||
EOF
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
env = Rscons::Environment.new do |env|
|
||||
env["hdr"] = "inc.h"
|
||||
env["src"] = "program.c"
|
||||
env.add_builder(MySource.new)
|
||||
env.MySource('${hdr}')
|
||||
env.Program('program.exe', "${src}")
|
||||
end
|
28
build_tests/custom_builder/cvar_lambda.rb
Normal file
28
build_tests/custom_builder/cvar_lambda.rb
Normal file
@ -0,0 +1,28 @@
|
||||
class MySource < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
File.open(target, 'w') do |fh|
|
||||
fh.puts <<EOF
|
||||
#define THE_VALUE #{env.expand_varref("${the_value}")}
|
||||
EOF
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
e1 = Rscons::Environment.new do |env|
|
||||
env.add_builder(MySource.new)
|
||||
env["one"] = "5"
|
||||
env[:cfg] = {val: "9"}
|
||||
env["two"] = lambda do |args|
|
||||
args[:env][:cfg][:val]
|
||||
end
|
||||
env["the_value"] = lambda do |args|
|
||||
"${one}${two}78"
|
||||
end
|
||||
end
|
||||
|
||||
e1.clone do |env|
|
||||
env[:cfg][:val] = "6"
|
||||
env.MySource('inc.h', [])
|
||||
env.Program('program.exe', Dir['*.c'])
|
||||
end
|
19
build_tests/custom_builder/multiple_targets.rb
Normal file
19
build_tests/custom_builder/multiple_targets.rb
Normal file
@ -0,0 +1,19 @@
|
||||
class CHGen < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
c_fname = target
|
||||
h_fname = target.sub(/\.c$/, ".h")
|
||||
unless cache.up_to_date?([c_fname, h_fname], "", sources, env)
|
||||
puts "CHGen #{c_fname}"
|
||||
File.open(c_fname, "w") {|fh| fh.puts "int THE_VALUE = 42;"}
|
||||
File.open(h_fname, "w") {|fh| fh.puts "extern int THE_VALUE;"}
|
||||
cache.register_build([c_fname, h_fname], "", sources, env)
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env.add_builder(CHGen.new)
|
||||
env.CHGen("inc.c", ["program.c"])
|
||||
env.Program("program.exe", %w[program.c inc.c])
|
||||
end
|
3
build_tests/d/Rsconsfile
Normal file
3
build_tests/d/Rsconsfile
Normal file
@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.Program("hello-d.exe", Dir["*.d"])
|
||||
end
|
3
build_tests/header/Rsconsfile
Normal file
3
build_tests/header/Rsconsfile
Normal file
@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program('header.exe', Dir['*.c'])
|
||||
end
|
15
build_tests/json_to_yaml/Rsconsfile
Normal file
15
build_tests/json_to_yaml/Rsconsfile
Normal file
@ -0,0 +1,15 @@
|
||||
Rscons::Environment.new do |env|
|
||||
require 'json'
|
||||
require 'yaml'
|
||||
env.add_builder(:JsonToYaml) do |target, sources, cache, env, vars|
|
||||
unless cache.up_to_date?(target, :JsonToYaml, sources, env)
|
||||
cache.mkdir_p(File.dirname(target))
|
||||
File.open(target, 'w') do |f|
|
||||
f.write(YAML.dump(JSON.load(IO.read(sources.first))))
|
||||
end
|
||||
cache.register_build(target, :JsonToYaml, sources, env)
|
||||
end
|
||||
target
|
||||
end
|
||||
env.JsonToYaml('foo.yml', 'foo.json')
|
||||
end
|
4
build_tests/library/Rsconsfile
Normal file
4
build_tests/library/Rsconsfile
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.Program('library.exe', ['lib.a', 'three.c'])
|
||||
env.Library("lib.a", ['one.c', 'two.c'], 'CPPFLAGS' => ['-Dmake_lib'])
|
||||
end
|
3
build_tests/preprocess/Rsconsfile
Normal file
3
build_tests/preprocess/Rsconsfile
Normal file
@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Preprocess("pp", "foo.h")
|
||||
end
|
3
build_tests/simple/Rsconsfile
Normal file
3
build_tests/simple/Rsconsfile
Normal file
@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program('simple', Dir['*.c'])
|
||||
end
|
10
build_tests/simple/build_root_builder_no_sources.rb
Normal file
10
build_tests/simple/build_root_builder_no_sources.rb
Normal file
@ -0,0 +1,10 @@
|
||||
class TestBuilder < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
target
|
||||
end
|
||||
end
|
||||
Rscons::Environment.new do |env|
|
||||
env.build_root = "build"
|
||||
env.add_builder(TestBuilder.new)
|
||||
env.TestBuilder("file")
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
env.Object("two.o", "two.c")
|
||||
end
|
4
build_tests/simple/clear_targets.rb
Normal file
4
build_tests/simple/clear_targets.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program("simple.exe", "simple.c")
|
||||
env.clear_targets
|
||||
end
|
4
build_tests/simple/command.rb
Normal file
4
build_tests/simple/command.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env["LD"] = "gcc"
|
||||
env.Program('simple.exe', Dir['*.c'])
|
||||
end
|
4
build_tests/simple/cvar_array.rb
Normal file
4
build_tests/simple/cvar_array.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["sources"] = Dir["*.c"].sort
|
||||
env.Program("simple.exe", "${sources}")
|
||||
end
|
3
build_tests/simple/directory.rb
Normal file
3
build_tests/simple/directory.rb
Normal file
@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Directory("teh_dir")
|
||||
end
|
4
build_tests/simple/disassemble.rb
Normal file
4
build_tests/simple/disassemble.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Object("simple.o", "simple.c")
|
||||
env.Disassemble("simple.txt", "simple.o")
|
||||
end
|
5
build_tests/simple/dump.rb
Normal file
5
build_tests/simple/dump.rb
Normal file
@ -0,0 +1,5 @@
|
||||
env = Rscons::Environment.new do |env|
|
||||
env["CFLAGS"] += %w[-O2 -fomit-frame-pointer]
|
||||
env[:foo] = :bar
|
||||
end
|
||||
env.dump
|
5
build_tests/simple/link_flag_change.rb
Normal file
5
build_tests/simple/link_flag_change.rb
Normal file
@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env["LD"] = "gcc"
|
||||
env["LIBPATH"] += ["libdir"]
|
||||
env.Program('simple.exe', Dir['*.c'])
|
||||
end
|
12
build_tests/simple/phony_target.rb
Normal file
12
build_tests/simple/phony_target.rb
Normal file
@ -0,0 +1,12 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.build_root = "build"
|
||||
env.add_builder(:Checker) do |target, sources, cache, env, vars|
|
||||
unless cache.up_to_date?(target, :Checker, sources, env)
|
||||
puts "Checker #{sources.first}" if env.echo != :off
|
||||
cache.register_build(target, :Checker, sources, env)
|
||||
end
|
||||
target
|
||||
end
|
||||
env.Program("simple.exe", "simple.c")
|
||||
env.Checker(:checker, "simple.exe")
|
||||
end
|
4
build_tests/simple/preprocess.rb
Normal file
4
build_tests/simple/preprocess.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Preprocess("simplepp.c", "simple.c")
|
||||
env.Program("simple.exe", "simplepp.c")
|
||||
end
|
8
build_tests/simple/register_target_in_build_hook.rb
Normal file
8
build_tests/simple/register_target_in_build_hook.rb
Normal file
@ -0,0 +1,8 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program("simple.exe", Dir["*.c"])
|
||||
env.add_build_hook do |build_op|
|
||||
if build_op[:target].end_with?(".o")
|
||||
env.Disassemble("#{build_op[:target]}.txt", build_op[:target])
|
||||
end
|
||||
end
|
||||
end
|
4
build_tests/simple/user_dependencies.rb
Normal file
4
build_tests/simple/user_dependencies.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
program = env.Program("simple.exe", Dir["*.c"])
|
||||
env.depends(program, "program.ld")
|
||||
end
|
3
build_tests/simple_cc/Rsconsfile
Normal file
3
build_tests/simple_cc/Rsconsfile
Normal file
@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program('simple.exe', Dir['*.cc'])
|
||||
end
|
5
build_tests/simple_cc/cxxsuffix.rb
Normal file
5
build_tests/simple_cc/cxxsuffix.rb
Normal file
@ -0,0 +1,5 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["CXXSUFFIX"] = %w[.cccc .cc]
|
||||
env["CXXFLAGS"] += %w[-x c++]
|
||||
env.Program("simple.exe", Dir["*.cc"] + Dir["*.cccc"])
|
||||
end
|
4
build_tests/simple_cc/preprocess.rb
Normal file
4
build_tests/simple_cc/preprocess.rb
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Preprocess("simplepp.cc", "simple.cc")
|
||||
env.Program("simple.exe", "simplepp.cc")
|
||||
end
|
4
build_tests/two_sources/Rsconsfile
Normal file
4
build_tests/two_sources/Rsconsfile
Normal file
@ -0,0 +1,4 @@
|
||||
Rscons::Environment.new(echo: :command) do |env|
|
||||
env.Object("one.o", "one.c", 'CPPFLAGS' => ['-DONE'])
|
||||
env.Program('two_sources.exe', ['one.o', 'two.c'])
|
||||
end
|
7
build_tests/two_sources/assuffix.rb
Normal file
7
build_tests/two_sources/assuffix.rb
Normal file
@ -0,0 +1,7 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["ASSUFFIX"] = %w[.ssss .sss]
|
||||
env["CFLAGS"] += %w[-S]
|
||||
env.Object("one.ssss", "one.c", "CPPFLAGS" => ["-DONE"])
|
||||
env.Object("two.sss", "two.c")
|
||||
env.Program("two_sources.exe", %w[one.ssss two.sss], "ASFLAGS" => env["ASFLAGS"] + %w[-x assembler])
|
||||
end
|
6
build_tests/two_sources/libsuffix.rb
Normal file
6
build_tests/two_sources/libsuffix.rb
Normal file
@ -0,0 +1,6 @@
|
||||
Rscons::Environment.new() do |env|
|
||||
env["LIBSUFFIX"] = %w[.aaaa .aaa]
|
||||
env.Library("one.aaaa", "one.c", "CPPFLAGS" => ["-DONE"])
|
||||
env.Library("two.aaa", "two.c")
|
||||
env.Program("two_sources.exe", %w[one.aaaa two.aaa])
|
||||
end
|
6
build_tests/two_sources/objsuffix.rb
Normal file
6
build_tests/two_sources/objsuffix.rb
Normal file
@ -0,0 +1,6 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env["OBJSUFFIX"] = %w[.oooo .ooo]
|
||||
env.Object("one.oooo", "one.c", "CPPFLAGS" => ["-DONE"])
|
||||
env.Object("two.ooo", "two.c")
|
||||
env.Program("two_sources.exe", %w[one.oooo two.ooo])
|
||||
end
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user