Skip to content

Commit

Permalink
Merge pull request #153 from ancorgs/test_bnc943757
Browse files Browse the repository at this point in the history
Test for bnc#943757, fixed in libyui-ncurses 2.47.3
  • Loading branch information
ancorgs committed Sep 30, 2015
2 parents 2a3844c + e702cba commit 12114b7
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -5,7 +5,7 @@ before_install:
# disable rvm, use system Ruby
- rvm reset
- wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh
- sh ./travis_setup.sh -p "docbook-xsl xsltproc yast2-core-dev yast2-devtools libxcrypt-dev cmake yast2-ycp-ui-bindings-dev ruby2.1 ruby2.1-dev rake ruby-fast-gettext language-pack-en language-pack-cs" -g "yast-rake rspec:3.3.0 rubocop:0.29.1"
- sh ./travis_setup.sh -p "docbook-xsl xsltproc yast2-core-dev yast2-devtools libxcrypt-dev cmake yast2-ycp-ui-bindings-dev ruby2.1 ruby2.1-dev rake ruby-fast-gettext language-pack-en language-pack-cs screen" -g "yast-rake rspec:3.3.0 rubocop:0.29.1"
script:
- rake check:syntax
- rubocop
Expand Down
5 changes: 5 additions & 0 deletions package/yast2-ruby-bindings.spec
Expand Up @@ -42,6 +42,11 @@ Requires: yast2-core >= 2.24.0
BuildRequires: yast2-core-devel >= 2.24.0
Requires: yast2-ycp-ui-bindings >= 2.21.9
BuildRequires: yast2-ycp-ui-bindings-devel >= 2.21.9
# The test suite includes a regression test (std_streams_spec.rb) for a
# libyui-ncurses bug fixed in 2.47.3
BuildRequires: libyui-ncurses >= 2.47.3
# The mentioned test requires screen in order to be executed in headless systems
BuildRequires: screen
Requires: ruby
Summary: Ruby bindings for the YaST platform
License: GPL-2.0
Expand Down
2 changes: 2 additions & 0 deletions tests/ruby/CMakeLists.txt
Expand Up @@ -9,3 +9,5 @@ FILE(GLOB Specs "*_spec.rb")
foreach(test ${Specs})
ADD_TEST(${test} rspec --format doc ${test})
endforeach(test)

ADD_TEST("integration" ruby ${CMAKE_CURRENT_SOURCE_DIR}/integration/run.rb)
20 changes: 20 additions & 0 deletions tests/ruby/integration/run.rb
@@ -0,0 +1,20 @@
#!/usr/bin/env ruby

# std_streams_spec.rb is used to verify that bnc#943757 is fixed in
# libyui-ncurses >= 2.47.3. Thus, is an integration test for YaST+libyui
#
# It runs perfectly in a regular system by just calling
# rspec std_streams_spec.rb
# but headless systems like jenkins need this script to fake the screen

test = File.dirname(__FILE__) + "/std_streams_spec.rb"
cmd = "rspec #{test}"

`screen -D -m sh -c '#{cmd}; echo \$? > /tmp/exit'`
if File.read("/tmp/exit") != "0\n"
puts "Test failed: '#{cmd}'. Rerun manually to see the cause."
exit false
else
puts "Test succeeded."
exit true
end
40 changes: 40 additions & 0 deletions tests/ruby/integration/std_streams_spec.rb
@@ -0,0 +1,40 @@
#! /usr/bin/env rspec

# We do not have a proper ncurses in travis at the moment
exit 0 if ENV["TRAVIS"]

require_relative "../test_helper"
require "yast/ui_shortcuts"

Yast.import "UI"

def std_puts(message)
$stdout.puts "stdout: #{message}"
$stderr.puts "stderr: #{message}"
end

# Regression test for the fix of bnc#943757 implemented
# in libyui-ncurses 2.47.3
describe "streams redirection in libyui-ncurses" do
include Yast::UIShortcuts

around do |example|
Yast.ui_component = "ncurses"
Yast::UI.OpenUI
example.run
Yast::UI.CloseUI

# Having an expectation in the around block looks weird, but using around
# to execute OpenUI/CloseUI was needed to make the bug pop up.
#
# In addition to not crashing, these messages should be displayed when
# running RSpec, not sure if it's possible to check that.
expect { std_puts "tty is free again" }.to_not raise_error
end

it "does not fall apart when stderr is used" do
Yast::UI.OpenDialog(PushButton("Hello, World!"))
expect { std_puts "NCurses is using the tty" }.to_not raise_error
Yast::UI.CloseDialog
end
end

0 comments on commit 12114b7

Please sign in to comment.