File: threads.rb

package info (click to toggle)
ruby-maxitest 6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 504 kB
  • sloc: ruby: 1,583; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 781 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
ENV["MT_CPU"] = "2" # so we get 3 threads total and not variation based on machines cpus
require "maxitest/global_must"
require "./spec/cases/helper"
require "maxitest/threads"

describe "threads" do
  order_dependent!

  def assert_correct_threads
    _(Thread.list.count).must_equal 3, Thread.list
  end

  def create_thread
    Thread.new { sleep 0.1 }
  end

  it "is fine without extra threads" do
    assert_correct_threads
  end

  it "fails on extra threads" do
    assert_correct_threads
    create_thread
    _(Thread.list).must_equal 4
  end

  it "can kill extra threads" do
    assert_correct_threads
    create_thread
    maxitest_kill_extra_threads
  end

  it "can wait for extra threads" do
    assert_correct_threads
    maxitest_wait_for_extra_threads
  end
end