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