Skip to content

Commit fdd9446

Browse files
mrknv0dro
authored andcommitted
Fix integration test (#125)
* Add is_complete_request handler * Use cztop for testing * Use pty to give tty for jupyter console * travis: Update dependencies - Use czmq 4 - Use jupyter instead of ipython[notebook] * travis: Update ruby versions * test: Wait prompt instead of sleep
1 parent 514c747 commit fdd9446

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

.travis.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
language: ruby
22

3+
addons:
4+
apt:
5+
sources:
6+
- sourceline: 'deb http://download.opensuse.org/repositories/network:/messaging:/zeromq:/git-draft/xUbuntu_12.04/ ./'
7+
key_url: 'http://download.opensuse.org/repositories/network:/messaging:/zeromq:/git-draft/xUbuntu_12.04/Release.key'
8+
packages:
9+
- libsodium-dev
10+
- libczmq-dev
11+
312
rvm:
413
- ruby-head
5-
- 2.2.2
6-
- 2.1.6
7-
- 2.0.0
14+
- 2.4.0
15+
- 2.3.1
16+
- 2.2.5
17+
- 2.1.10
818

919
before_install:
10-
- "sudo apt-get install libzmq3-dev"
11-
- "sudo pip install 'ipython[notebook]'"
20+
- "sudo pip install 'jupyter'"
1221

1322
script: bundle exec rake
1423

1524
notifications:
16-
irc: "chat.freenode.net#sciruby"
25+
irc: "chat.freenode.net#sciruby"

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ group :plot do
1313
gem 'nyaplot', github: 'sciruby/nyaplot'
1414
end
1515

16+
group :test do
17+
gem 'cztop'
18+
end

jupyter_console_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c.InteractiveShell.colors = 'NoColor'

test/integration_test.rb

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,50 @@
11
require 'test_helper'
2-
require 'open3'
2+
require 'pty'
33
require 'expect'
44

55
class IntegrationTest < IRubyTest
66
def setup
7-
@stdin, @stdout, @stderr, @process = Open3.popen3('bin/iruby')
7+
$expect_verbose = false # make true if you want to dump the output of iruby console
8+
9+
@in, @out, pid = PTY.spawn('bin/iruby --config=jupyter_console_config.py')
10+
@waiter = Thread.start { Process.waitpid(pid) }
811
expect 'In [', 30
912
expect '1'
1013
expect ']:'
1114
end
1215

1316
def teardown
14-
@stdin.close
15-
@stdout.close
16-
@stderr.close
17-
@process.kill
17+
@in.close
18+
@out.close
19+
@waiter.join
1820
end
1921

2022
def write(input)
21-
@stdin.puts input
23+
@out.puts input
24+
end
25+
26+
def expect(pattern, timeout = 10)
27+
assert @in.expect(pattern, timeout), "#{pattern} expected, but timeout"
2228
end
2329

24-
def expect(pattern, timeout = 1)
25-
assert @stdout.expect(pattern, timeout), "#{pattern} expected"
30+
def wait_prompt
31+
expect 'In ['
32+
expect ']:'
2633
end
2734

2835
def test_interaction
2936
write '"Hello, world!"'
3037
expect '"Hello, world!"'
3138

39+
wait_prompt
3240
write 'puts "Hello!"'
3341
expect 'Hello!'
3442

43+
wait_prompt
3544
write '12 + 12'
3645
expect '24'
3746

47+
wait_prompt
3848
write 'ls'
3949
expect 'self.methods'
4050
end

0 commit comments

Comments
 (0)