Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from ancorgs/test_bnc943757
Test for bnc#943757, fixed in libyui-ncurses 2.47.3
- Loading branch information
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |