Parallelized build tests working
This commit is contained in:
parent
4c90dbd01b
commit
8a3b2ac126
@ -19,7 +19,6 @@ end
|
||||
RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
|
||||
ENV["specs"] = "1"
|
||||
if args.example_string
|
||||
ENV["partial_specs"] = "1"
|
||||
task.rspec_opts = %W[-e "#{args.example_string}" -f documentation]
|
||||
end
|
||||
end
|
||||
@ -27,6 +26,13 @@ task :spec => :build_dist
|
||||
task :spec do
|
||||
ENV.delete("specs")
|
||||
end
|
||||
task :spec => :build_tests
|
||||
|
||||
task :build_tests do |task, args|
|
||||
ENV["specs"] = "1"
|
||||
sh "ruby -Ilib build_tests/build_tests.rb"
|
||||
ENV.delete("specs")
|
||||
end
|
||||
|
||||
# dspec task is useful to test the distributable release script, but is not
|
||||
# useful for coverage information.
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "bundler"
|
||||
require "fileutils"
|
||||
require "open3"
|
||||
require "set"
|
||||
require "tmpdir"
|
||||
require "rscons"
|
||||
|
||||
BASE_DIR = File.expand_path("build_test_run")
|
||||
OWD = Dir.pwd
|
||||
TESTS_LINE = File.read(__FILE__).lines.find_index {|line| line.chomp == "# Tests"}
|
||||
|
||||
RunResults = Struct.new(:stdout, :stderr, :status)
|
||||
|
||||
@ -25,14 +30,18 @@ class Test
|
||||
def run(outfh)
|
||||
failure = false
|
||||
begin
|
||||
self.instance_eval(@block)
|
||||
self.instance_eval(&@block)
|
||||
@output += "<pass>" if @output == ""
|
||||
rescue RuntimeError => re
|
||||
@output += re.message
|
||||
@output += re.message + "\n"
|
||||
# TODO:
|
||||
# if test.exception.backtrace.find {|e| e =~ %r{^(.*/#{File.basename(__FILE__)}:\d+)}}
|
||||
# message += " (#{$1})"
|
||||
# end
|
||||
re.backtrace.each do |line|
|
||||
if line =~ %r{^(.*/#{File.basename(__FILE__)}:(\d+))}
|
||||
if $2.to_i > TESTS_LINE
|
||||
@output += "#{$1}\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
@output += "Keeping directory #{@run_dir} for inspection"
|
||||
failure = true
|
||||
end
|
||||
@ -94,6 +103,7 @@ end
|
||||
SimpleCov.start do
|
||||
root(#{OWD.inspect})
|
||||
coverage_dir(#{@coverage_dir.inspect})
|
||||
command_name "build_tests"
|
||||
filters.clear
|
||||
add_filter do |src|
|
||||
!(src.filename[SimpleCov.root])
|
||||
@ -173,13 +183,13 @@ EOF
|
||||
end
|
||||
|
||||
def expect_match(a, b)
|
||||
unless a ~= b
|
||||
unless a =~ b
|
||||
raise "Expected #{a.inspect} to match #{b.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
def expect_not_match(a, b)
|
||||
if a ~= b
|
||||
if a =~ b
|
||||
raise "Expected #{a.inspect} to not match #{b.inspect}"
|
||||
end
|
||||
end
|
||||
@ -230,6 +240,7 @@ def rm_rf(dir)
|
||||
end
|
||||
|
||||
def run_tests
|
||||
$stdout.sync = true
|
||||
rm_rf(BASE_DIR)
|
||||
FileUtils.mkdir_p(BASE_DIR)
|
||||
keep_run_dir = false
|
||||
@ -268,6 +279,7 @@ def run_tests
|
||||
threads[thread] = [piper, pipew, test]
|
||||
end
|
||||
end
|
||||
$stdout.write("\n")
|
||||
unless failure
|
||||
rm_rf(BASE_DIR)
|
||||
end
|
||||
@ -416,7 +428,7 @@ test "supports barriers and prevents parallelizing builders across them" do
|
||||
result = run_rscons(args: %w[-f barrier.rb -j 3])
|
||||
expect_eq(result.stderr, "")
|
||||
slines = lines(result.stdout).select {|line| line =~ /T\d/}
|
||||
expect_eq(slines, [)
|
||||
expect_eq(slines, [
|
||||
"[1/6] ThreadedTestBuilder T3",
|
||||
"[2/6] ThreadedTestBuilder T2",
|
||||
"[3/6] ThreadedTestBuilder T1",
|
||||
@ -429,7 +441,7 @@ test "supports barriers and prevents parallelizing builders across them" do
|
||||
"T4 finished",
|
||||
"T5 finished",
|
||||
"T6 finished",
|
||||
]
|
||||
])
|
||||
end
|
||||
|
||||
test "expands target and source paths starting with ^/ and ^^/" do
|
||||
@ -753,7 +765,7 @@ test "rebuilds when user-specified dependencies using ^ change" do
|
||||
expect_eq(result.stderr, "")
|
||||
verify_lines(lines(result.stdout), [%r{Linking .*simple.exe}])
|
||||
|
||||
result = run_rscons(args: %w[-f user_dependencies_carat.rb])
|
||||
result = run_rscons(args: %w[-f user_dependencies_carat.rb], env: {"file_contents" => "2"})
|
||||
expect_eq(result.stderr, "")
|
||||
expect_eq(result.stdout, "")
|
||||
end
|
||||
@ -1810,7 +1822,7 @@ context "SharedLibrary builder" do
|
||||
test_dir "shared_library"
|
||||
result = run_rscons(args: %w[-f shared_library_from_object.rb])
|
||||
expect_eq(result.stderr, "")
|
||||
expect(File.exist?("one.c.o"))
|
||||
expect(File.exist?("one.o"))
|
||||
end
|
||||
end
|
||||
|
||||
@ -1954,7 +1966,7 @@ context "configure task" do
|
||||
result = run_rscons(args: %w[-f configure_with_top_level_env.rb configure --prefix=/yodabob])
|
||||
expect_eq(result.stderr, "")
|
||||
expect_eq(result.status, 0)
|
||||
expect_match(result.stdout, "Prefix is /yodabob")
|
||||
expect_match(result.stdout, %r{Prefix is /yodabob})
|
||||
end
|
||||
|
||||
test "does not configure for distclean operation" do
|
||||
@ -3018,7 +3030,7 @@ EOF
|
||||
expect_eq(result.stderr, "")
|
||||
result = run_rscons(args: %w[-f Rsconscript_samedir])
|
||||
expect_eq(result.stderr, "")
|
||||
expect_not_match(result.stdout, %{(Entering|Leaving) directory})
|
||||
expect_not_match(result.stdout, %r{(Entering|Leaving) directory})
|
||||
verify_lines(lines(result.stdout), [
|
||||
%r{second build},
|
||||
%r{top build},
|
||||
@ -3522,3 +3534,5 @@ test "supports building LLVM assembly files with the Program builder in direct m
|
||||
expect_truthy(File.exist?("llvmtest.exe"))
|
||||
expect_match(`./llvmtest.exe`, /hello again/)
|
||||
end
|
||||
|
||||
run_tests
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user