Skip to content

Commit 08553c9

Browse files
committed
Use test-unit
1 parent c46c6ef commit 08553c9

15 files changed

+162
-110
lines changed

Rakefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
require 'rake/testtask'
1+
require "bundler/gem_helper"
22

3-
begin
4-
require 'bundler/gem_tasks'
5-
rescue Exception
6-
end
3+
base_dir = File.join(File.dirname(__FILE__))
4+
5+
helper = Bundler::GemHelper.new(base_dir)
6+
helper.install
77

88
FileList['tasks/**.rake'].each {|f| load f }
99

10-
Rake::TestTask.new('test') do |t|
11-
t.libs << 'lib'
12-
t.libs << 'test'
13-
t.test_files = FileList['test/**/*_test.rb']
14-
t.verbose = true
10+
desc "Run tests"
11+
task :test do
12+
cd(base_dir) do
13+
ruby("test/run-test.rb")
14+
end
1515
end
1616

1717
task default: 'test'

iruby.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Gem::Specification.new do |s|
2323
s.add_dependency 'mimemagic', '~> 0.3'
2424
s.add_dependency 'multi_json', '~> 1.11'
2525

26-
s.add_development_dependency 'minitest'
2726
s.add_development_dependency 'pycall', '>= 1.2.1'
2827
s.add_development_dependency 'rake'
28+
s.add_development_dependency 'test-unit'
29+
s.add_development_dependency 'test-unit-rr'
2930
end

test/helper.rb

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
require "iruby"
2+
require "test/unit"
3+
require "test/unit/rr"
4+
require "tmpdir"
5+
6+
module IRubyTest
7+
class TestBase < Test::Unit::TestCase
8+
def assert_output(stdout=nil, stderr=nil)
9+
flunk "assert_output requires a block to capture output." unless block_given?
10+
11+
out, err = capture_io do
12+
yield
13+
end
14+
15+
y = check_assert_output_result(stderr, err, "stderr")
16+
x = check_assert_output_result(stdout, out, "stdout")
17+
18+
(!stdout || x) && (!stderr || y)
19+
end
20+
21+
private
22+
23+
def capture_io
24+
captured_stdout = StringIO.new
25+
captured_stderr = StringIO.new
26+
27+
orig_stdout, $stdout = $stdout, captured_stdout
28+
orig_stderr, $stderr = $stderr, captured_stderr
29+
30+
yield
31+
32+
return captured_stdout.string, captured_stderr.string
33+
ensure
34+
$stdout = orig_stdout
35+
$stderr = orig_stderr
36+
end
37+
38+
def check_assert_output_result(expected, actual, name)
39+
if expected
40+
message = "In #{name}"
41+
case expected
42+
when Regexp
43+
assert_match(expected, actual, message)
44+
else
45+
assert_equal(expected, actual, message)
46+
end
47+
end
48+
end
49+
50+
def ignore_warning
51+
saved, $VERBOSE = $VERBOSE , nil
52+
yield
53+
ensure
54+
$VERBOSE = saved
55+
end
56+
57+
def with_env(env)
58+
keys = env.keys
59+
saved_values = ENV.values_at(*keys)
60+
ENV.update(env)
61+
yield
62+
ensure
63+
if keys && saved_values
64+
keys.zip(saved_values) do |k, v|
65+
ENV[k] = v
66+
end
67+
end
68+
end
69+
70+
def windows_only
71+
omit('windows only test') unless windows?
72+
end
73+
74+
def apple_only
75+
omit('apple only test') unless windows?
76+
end
77+
78+
def unix_only
79+
omit('unix only test') if windows? || apple?
80+
end
81+
82+
def windows?
83+
/mingw|mswin/ =~ RUBY_PLATFORM
84+
end
85+
86+
def apple?
87+
/darwin/ =~ RUBY_PLATFORM
88+
end
89+
end
90+
end

test/integration_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'test_helper'
21
require 'pty'
32
require 'expect'
43

@@ -33,7 +32,7 @@ def wait_prompt
3332
end
3433

3534
def test_interaction
36-
skip "This test too much unstable"
35+
omit("This test too much unstable")
3736

3837
write '"Hello, world!"'
3938
expect '"Hello, world!"'

test/iruby/backend_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'test_helper'
2-
31
module IRubyTest
42
class PlainBackendTest < IRubyTest::TestBase
53
def setup

test/iruby/command_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'test_helper'
21
require 'iruby/command'
32

43
module IRubyTest

test/iruby/jupyter_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'test_helper'
21
require 'iruby/jupyter'
32

43
module IRubyTest

test/iruby/multi_logger_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'stringio'
2-
require 'test_helper'
32
require 'iruby/logger'
43

54
class IRubyTest::MultiLoggerTest < IRubyTest::TestBase

test/iruby/session_adapter/cztop_adapter_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_send
1313
end
1414

1515
def test_recv
16-
skip
16+
omit
1717
end
1818
end
1919
end

test/iruby/session_adapter/ffirzmq_adapter_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_send
1313
end
1414

1515
def test_recv
16-
skip
16+
omit
1717
end
1818
end
1919
end

0 commit comments

Comments
 (0)