Sha256: f337329170f3d8cdab1ac903f5f7fd15f7184ece8d847565e07361ad282c9ddb

Contents?: true

Size: 1.5 KB

Versions: 124

Compression:

Stored size: 1.5 KB

Contents

require File.expand_path('../helper', __FILE__)
require 'thread'

class TestRakeMultiTask < Rake::TestCase
  include Rake
  include Rake::DSL

  def setup
    super

    Task.clear
    @runs = Array.new
    @mutex = Mutex.new
  end

  def add_run(obj)
    @mutex.synchronize do
      @runs << obj
    end
  end

  def test_running_multitasks
    task :a do 3.times do |i| add_run("A#{i}"); sleep 0.01; end end
    task :b do 3.times do |i| add_run("B#{i}"); sleep 0.01;  end end
    multitask :both => [:a, :b]
    Task[:both].invoke
    assert_equal 6, @runs.size
    assert @runs.index("A0") < @runs.index("A1")
    assert @runs.index("A1") < @runs.index("A2")
    assert @runs.index("B0") < @runs.index("B1")
    assert @runs.index("B1") < @runs.index("B2")
  end

  def test_all_multitasks_wait_on_slow_prerequisites
    task :slow do 3.times do |i| add_run("S#{i}"); sleep 0.05 end end
    task :a => [:slow] do 3.times do |i| add_run("A#{i}"); sleep 0.01 end end
    task :b => [:slow] do 3.times do |i| add_run("B#{i}"); sleep 0.01 end end
    multitask :both => [:a, :b]
    Task[:both].invoke
    assert_equal 9, @runs.size
    assert @runs.index("S0") < @runs.index("S1")
    assert @runs.index("S1") < @runs.index("S2")
    assert @runs.index("S2") < @runs.index("A0")
    assert @runs.index("S2") < @runs.index("B0")
    assert @runs.index("A0") < @runs.index("A1")
    assert @runs.index("A1") < @runs.index("A2")
    assert @runs.index("B0") < @runs.index("B1")
    assert @runs.index("B1") < @runs.index("B2")
  end
end

Version data entries

124 entries across 97 versions & 23 rubygems

Version Path
challah-0.6.0 vendor/bundle/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
horseman-0.0.5 vendor/ruby/1.9.1/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
challah-0.5.4 vendor/bundle/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
challah-0.5.3 vendor/bundle/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
challah-0.5.2 vendor/bundle/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
dirty_history-0.5.3 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_multi_task.rb
dirty_history-0.5.2 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_multi_task.rb
dirty_history-0.5.2 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_multi_task.rb
challah-0.5.1 vendor/bundle/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
challah-0.5.0 vendor/bundle/gems/rake-0.9.2.2/test/test_rake_multi_task.rb
dirty_history-0.5.1 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_multi_task.rb
dirty_history-0.5.1 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_multi_task.rb
dirty_history-0.5.0 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_multi_task.rb