Skip to content

Commit

Permalink
add test messages for single- and multi-threaded; show graph for para…
Browse files Browse the repository at this point in the history
…llel visual check
  • Loading branch information
quix committed Apr 6, 2009
1 parent bdfb714 commit 2ff2c90
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions test/parallel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'rake'
Rake.application.num_threads = 8
puts "- Testing multi-threaded"

1 change: 1 addition & 0 deletions test/single_threaded.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
require 'rake'
Rake.application.num_threads = 1
puts "- Testing single-threaded"
37 changes: 29 additions & 8 deletions test/test_parallel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@
require 'rbconfig'
require 'test/unit'

PARALLEL_TEST_MESSAGE = <<'EOS'
Task graph for sample parallel execution:
default
/ \
/ \
a b
/ \
/ \
x y
EOS

if Rake.application.num_threads > 1
class TestSimpleParallel < Test::Unit::TestCase
def test_1
def setup
puts PARALLEL_TEST_MESSAGE
end

def test_parallel
here = File.dirname(__FILE__)
rake = File.expand_path("#{here}/../bin/rake")

Expand All @@ -18,15 +37,17 @@ def test_1
lib
end
}.call

[
"Rakefile.simple",
"Rakefile.seq",
].each { |file|
["Rakefile.simple", true],
["Rakefile.seq", false],
].each { |file, disp|
(1..5).each { |n|
args = [rake, "--threads", n.to_s, "-f", "test/#{file}"]
puts("\n" + "-"*40)
puts(args.join(" "))
args = [rake, "--threads", n.to_s, "-s", "-f", "test/#{file}"]
if disp
puts "\nvisual check: #{n} thread#{n > 1 ? 's' : ''}"
puts args.join(" ")
end
assert(ruby(*args))
}
}
Expand Down

0 comments on commit 2ff2c90

Please sign in to comment.