Skip to content

Commit

Permalink
Fix non-deterministic Rake test for "multitask" by adding semaphore.s…
Browse files Browse the repository at this point in the history
…ynchronize around array access

Changed default.mspec so that :core properly excludes the thread tests
  • Loading branch information
Shri Borde committed Jun 3, 2009
1 parent 1f95df8 commit 4008955
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Expand Up @@ -23,7 +23,7 @@ class MSpecScript
"core\\binding",
"core\\builtin_constants"
]
set :core2, filtered("core", "[j-z]").reject{|el| el =~ /^thread/}
set :core2, filtered("core", "[j-z]").reject{|el| el =~ /thread/i}
set :lang, [
"language"
]
Expand Down
Expand Up @@ -2,19 +2,21 @@

require 'test/unit'
require 'rake'
require 'thread'

######################################################################
class TestMultiTask < Test::Unit::TestCase
include Rake
@@semaphore = Mutex.new

def setup
Task.clear
@runs = Array.new
end

def test_running_multitasks
task :a do 3.times do |i| @runs << "A#{i}"; sleep 0.01; end end
task :b do 3.times do |i| @runs << "B#{i}"; sleep 0.01; end end
task :a do 3.times do |i| @@semaphore.synchronize { @runs << "A#{i}" }; sleep 0.01; end end
task :b do 3.times do |i| @@semaphore.synchronize { @runs << "B#{i}" }; sleep 0.01; end end
multitask :both => [:a, :b]
Task[:both].invoke
assert_equal 6, @runs.size
Expand Down
8 changes: 6 additions & 2 deletions Merlin/Main/Languages/Ruby/Scripts/irtests.bat
Expand Up @@ -56,6 +56,7 @@ if defined PARALLEL_IRTESTS (
)

time /t
echo Legacy Tests

if defined PARALLEL_IRTESTS (
start "Legacy Tests" %MERLIN_ROOT%\Languages\Ruby\Tests\run.bat
Expand All @@ -67,15 +68,16 @@ if defined PARALLEL_IRTESTS (
)
)

time /t

:==============================================================================
: RubySpecs

REM We use mspec-run instead of mspec so that we can specify "-G thread" to disable the volatile thread tests

set MSPEC_RUN=%MERLIN_ROOT%\..\External.LCA_RESTRICTED\Languages\IronRuby\mspec\mspec\bin\mspec-run

time /t
echo RubySpec A tests

if defined PARALLEL_IRTESTS (
start "RubySpec A tests" cmd.exe /k %MERLIN_ROOT%\bin\Debug\ir.exe %MSPEC_RUN% -G fails -G unstable -G thread -G critical -fd :lang :cli :netinterop :cominterop :thread
) else (
Expand All @@ -87,6 +89,7 @@ if defined PARALLEL_IRTESTS (
)

time /t
echo RubySpec B tests

if defined PARALLEL_IRTESTS (
start "RubySpec B tests" mspec ci -fd -V :core1 :lib1
Expand All @@ -99,6 +102,7 @@ if defined PARALLEL_IRTESTS (
)

time /t
echo RubySpec C tests

if defined PARALLEL_IRTESTS (
start "RubySpec C tests" mspec ci -fd -V :core2 :lib2
Expand Down
5 changes: 5 additions & 0 deletions Merlin/Users/sborde/Dev.bat
Expand Up @@ -13,4 +13,9 @@ REM but mspec launches mspec-run as a separate process
set RUBY_EXE=%MERLIN_ROOT%\bin\Debug\ir.exe
set RUBY19_EXE=%MERLIN_TFS%\..\External.LCA_RESTRICTED\Languages\Ruby\ruby-1.9.1p0\bin\ruby.exe

REM Set GEM_HOME so that "gem install" will install to a different location, and not in source tree
REM Note that GEM_PATH points to the gems included in the source tree.
set GEM_HOME=%TEMP%\gems
set GEM_PATH=%GEM_PATH%;%GEM_HOME%

set JAVA_HOME=C:\Progra~1\Java\jre6

0 comments on commit 4008955

Please sign in to comment.