Allow X related tests to work on travis CI

This commit is contained in:
Thibault Jouan 2015-04-09 02:29:52 +00:00
parent 4eecc2e32f
commit 366028fa01
2 changed files with 13 additions and 3 deletions

View File

@ -1,7 +1,9 @@
sudo: false
language: ruby language: ruby
cache: bundler cache: bundler
rvm: rvm:
- 2.2 - 2.2
- ruby-head - ruby-head
- 2.1 - 2.1
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq xdotool

View File

@ -2,12 +2,20 @@ def x_key key
fail "cannot simulate X key `#{key}'" unless system "xdotool key #{key}" fail "cannot simulate X key `#{key}'" unless system "xdotool key #{key}"
end end
def x_socket_check pid
case RbConfig::CONFIG['host_os']
when /linux/
`netstat -xp`.lines.grep /\s+#{pid}\/ruby/
else
`sockstat -u`.lines.grep /\s+ruby.+\s+#{pid}/
end.any?
end
When /^I press the default quit key binding$/ do When /^I press the default quit key binding$/ do
x_key 'alt+q' x_key 'alt+q'
end end
Then /^it must connect to X display$/ do Then /^it must connect to X display$/ do
uhwm_wait_output 'Connected to' uhwm_wait_output 'Connected to'
expect(`sockstat -u`.lines.grep /\s+ruby.+\s+#{@process.pid}/) expect(x_socket_check @process.pid).to be true
.not_to be_empty
end end