Hello community, here is the log from the commit of package yast2-ruby-bindings for openSUSE:Factory checked in at 2020-11-13 18:57:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-ruby-bindings (Old) and /work/SRC/openSUSE:Factory/.yast2-ruby-bindings.new.24930 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-ruby-bindings" Fri Nov 13 18:57:19 2020 rev:105 rq:848098 version:4.3.9 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-ruby-bindings/yast2-ruby-bindings.changes 2020-09-25 16:26:06.419601987 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-ruby-bindings.new.24930/yast2-ruby-bindings.changes 2020-11-13 18:57:26.786004469 +0100 @@ -1,0 +2,32 @@ +Thu Nov 12 10:20:58 UTC 2020 - Martin Vidner <mvid...@suse.com> + +- Build fix for "error creating /run/tmux/399" (bsc#1178394) +- 4.3.9 + +------------------------------------------------------------------- +Tue Nov 3 17:39:19 UTC 2020 - Martin Vidner <mvid...@suse.com> + +- Test: menu items remain disabled after hotkeys are recomputed + (bsc#1178394) +- 4.3.8 + +------------------------------------------------------------------- +Thu Oct 29 17:26:31 UTC 2020 - Stefan Hundhammer <shundham...@suse.com> + +- Added unit tests for NCMultiSelectionBox (bsc#1177985) +- 4.3.7 + +------------------------------------------------------------------- +Thu Oct 29 11:30:49 UTC 2020 - Stefan Schubert <sch...@suse.com> + +- Reporting augeas parsing errors and displaying them in rich-text + format (bsc#1174198). +- 4.3.6 + +------------------------------------------------------------------- +Tue Oct 13 14:42:52 UTC 2020 - Martin Vidner <mvid...@suse.com> + +- Add automatic TUI (ncurses) tests using tmux (bsc#1165388). +- 4.3.5 + +------------------------------------------------------------------- Old: ---- yast2-ruby-bindings-4.3.4.tar.bz2 New: ---- yast2-ruby-bindings-4.3.9.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-ruby-bindings.spec ++++++ --- /var/tmp/diff_new_pack.0cSUEW/_old 2020-11-13 18:57:28.002005878 +0100 +++ /var/tmp/diff_new_pack.0cSUEW/_new 2020-11-13 18:57:28.002005878 +0100 @@ -17,7 +17,7 @@ Name: yast2-ruby-bindings -Version: 4.3.4 +Version: 4.3.9 Release: 0 URL: https://github.com/yast/yast-ruby-bindings BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -28,7 +28,7 @@ BuildRequires: gcc-c++ BuildRequires: yast2-core-devel BuildRequires: yast2-devtools >= 3.1.10 -%if 0%{suse_version} == 1310 +%if 0%{?suse_version} == 1310 BuildRequires: rubygem-fast_gettext < 3.0 BuildRequires: rubygem-rspec Requires: rubygem-fast_gettext < 3.0 @@ -40,15 +40,15 @@ BuildRequires: ruby-devel Requires: yast2-core >= 3.2.2 BuildRequires: yast2-core-devel >= 3.2.2 -# MenuBar widget -Requires: yast2-ycp-ui-bindings >= 4.3.1 -BuildRequires: yast2-ycp-ui-bindings-devel >= 4.3.1 +# MenuBar-shortcuts-test.rb +Requires: yast2-ycp-ui-bindings >= 4.3.6 +BuildRequires: yast2-ycp-ui-bindings-devel >= 4.3.6 # 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 to check if tmux is there, because tmux is -# needed to execute the test in headless systems -BuildRequires: which +# The mentioned test requires tmux in order to be executed in headless systems +# Also many other libyui tests to come +BuildRequires: tmux # only a soft dependency, the Ruby debugger is optional Suggests: rubygem(%{rb_default_ruby_abi}:byebug) @@ -89,6 +89,9 @@ cd - %check +# Build workers are set up without systemd so the default /run/tmux dir +# will not be present (unless clamav pulls systemd in, on SLE) +export TMUX_TMPDIR=/tmp cd build make test ARGS=-V cd - ++++++ yast2-ruby-bindings-4.3.4.tar.bz2 -> yast2-ruby-bindings-4.3.9.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/Dockerfile new/yast2-ruby-bindings-4.3.9/Dockerfile --- old/yast2-ruby-bindings-4.3.4/Dockerfile 2020-09-24 19:33:21.000000000 +0200 +++ new/yast2-ruby-bindings-4.3.9/Dockerfile 2020-11-12 11:45:50.000000000 +0100 @@ -2,4 +2,9 @@ # Install tmux to make sure the libyui+YaST integration tests are run RUN zypper --non-interactive in tmux +# Enable installing docs... +RUN sed -i 's/\(rpm\.install\.excludedocs =\).*/\1 no/' /etc/zypp/zypp.conf +# ... and reinstall the RPM containing the examples we use for tests +RUN zypper --non-interactive in --force yast2-ycp-ui-bindings-devel + COPY . /usr/src/app diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/package/yast2-ruby-bindings.changes new/yast2-ruby-bindings-4.3.9/package/yast2-ruby-bindings.changes --- old/yast2-ruby-bindings-4.3.4/package/yast2-ruby-bindings.changes 2020-09-24 19:33:21.000000000 +0200 +++ new/yast2-ruby-bindings-4.3.9/package/yast2-ruby-bindings.changes 2020-11-12 11:45:50.000000000 +0100 @@ -1,4 +1,36 @@ ------------------------------------------------------------------- +Thu Nov 12 10:20:58 UTC 2020 - Martin Vidner <mvid...@suse.com> + +- Build fix for "error creating /run/tmux/399" (bsc#1178394) +- 4.3.9 + +------------------------------------------------------------------- +Tue Nov 3 17:39:19 UTC 2020 - Martin Vidner <mvid...@suse.com> + +- Test: menu items remain disabled after hotkeys are recomputed + (bsc#1178394) +- 4.3.8 + +------------------------------------------------------------------- +Thu Oct 29 17:26:31 UTC 2020 - Stefan Hundhammer <shundham...@suse.com> + +- Added unit tests for NCMultiSelectionBox (bsc#1177985) +- 4.3.7 + +------------------------------------------------------------------- +Thu Oct 29 11:30:49 UTC 2020 - Stefan Schubert <sch...@suse.com> + +- Reporting augeas parsing errors and displaying them in rich-text + format (bsc#1174198). +- 4.3.6 + +------------------------------------------------------------------- +Tue Oct 13 14:42:52 UTC 2020 - Martin Vidner <mvid...@suse.com> + +- Add automatic TUI (ncurses) tests using tmux (bsc#1165388). +- 4.3.5 + +------------------------------------------------------------------- Thu Sep 24 19:46:00 UTC 2020 - besse...@fedoraproject.org - Fixes for gensalt handling with libxcrypt (bsc#1176924) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/package/yast2-ruby-bindings.spec new/yast2-ruby-bindings-4.3.9/package/yast2-ruby-bindings.spec --- old/yast2-ruby-bindings-4.3.4/package/yast2-ruby-bindings.spec 2020-09-24 19:33:21.000000000 +0200 +++ new/yast2-ruby-bindings-4.3.9/package/yast2-ruby-bindings.spec 2020-11-12 11:45:50.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-ruby-bindings -Version: 4.3.4 +Version: 4.3.9 Release: 0 URL: https://github.com/yast/yast-ruby-bindings BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -28,7 +28,7 @@ BuildRequires: gcc-c++ BuildRequires: yast2-core-devel BuildRequires: yast2-devtools >= 3.1.10 -%if 0%{suse_version} == 1310 +%if 0%{?suse_version} == 1310 BuildRequires: rubygem-fast_gettext < 3.0 BuildRequires: rubygem-rspec Requires: rubygem-fast_gettext < 3.0 @@ -40,15 +40,15 @@ BuildRequires: ruby-devel Requires: yast2-core >= 3.2.2 BuildRequires: yast2-core-devel >= 3.2.2 -# MenuBar widget -Requires: yast2-ycp-ui-bindings >= 4.3.1 -BuildRequires: yast2-ycp-ui-bindings-devel >= 4.3.1 +# MenuBar-shortcuts-test.rb +Requires: yast2-ycp-ui-bindings >= 4.3.6 +BuildRequires: yast2-ycp-ui-bindings-devel >= 4.3.6 # 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 to check if tmux is there, because tmux is -# needed to execute the test in headless systems -BuildRequires: which +# The mentioned test requires tmux in order to be executed in headless systems +# Also many other libyui tests to come +BuildRequires: tmux # only a soft dependency, the Ruby debugger is optional Suggests: rubygem(%{rb_default_ruby_abi}:byebug) @@ -89,6 +89,9 @@ cd - %check +# Build workers are set up without systemd so the default /run/tmux dir +# will not be present (unless clamav pulls systemd in, on SLE) +export TMUX_TMPDIR=/tmp cd build make test ARGS=-V cd - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/src/ruby/yast/debugger.rb new/yast2-ruby-bindings-4.3.9/src/ruby/yast/debugger.rb --- old/yast2-ruby-bindings-4.3.4/src/ruby/yast/debugger.rb 2020-09-24 19:33:21.000000000 +0200 +++ new/yast2-ruby-bindings-4.3.9/src/ruby/yast/debugger.rb 2020-11-12 11:45:50.000000000 +0100 @@ -2,6 +2,18 @@ require "yast" module Yast + # Interface to a Ruby debugger (byebug) + # + # `Y2DEBUGGER` environment variable (or install boot option) + # + # - 1: start the debugger when YaST starts; + # in GUI, run an xterm with the debugger client; + # in TUI, tell the user to run the debugger client + # - manual: like "1" but always tell the user instead of starting the client + # - remote: tell the user to connect from a remote machine. INSECURE! + # - 0: do not start the debugger, don't even ask if an exception is raised + # + # See also https://yastgithubio.readthedocs.io/en/latest/debugging/ class Debugger class << self include Yast::Logger @@ -85,6 +97,11 @@ start(remote: debug == "remote", start_client: debug != "manual") end + # @return [Boolean] Is the debugger explicitly unwanted even if available + def unwanted? + env_value == "0" + end + # is the Ruby debugger installed and can be loaded? # @return [Boolean] true if the debugger is present def installed? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/src/ruby/yast/wfm.rb new/yast2-ruby-bindings-4.3.9/src/ruby/yast/wfm.rb --- old/yast2-ruby-bindings-4.3.4/src/ruby/yast/wfm.rb 2020-09-24 19:33:21.000000000 +0200 +++ new/yast2-ruby-bindings-4.3.9/src/ruby/yast/wfm.rb 2020-11-12 11:45:50.000000000 +0100 @@ -4,6 +4,7 @@ require "yast/debugger" require "yast/profiler" require "yast/yast" +require "cgi" # @private we need it as clients is called in global contenxt GLOBAL_WFM_CONTEXT = proc {} @@ -208,35 +209,53 @@ private_class_method def self.ask_to_run_debugger? Yast.import "Mode" + !Mode.auto && !Debugger.unwanted? && Debugger.installed? + end - !Mode.auto && Debugger.installed? + # @param [CFA::AugeasParsingError] e the caught exception + # @return [String] human readable exception description + private_class_method def self.parsing_error_msg(e) + msg = "Parse error while reading file #{e.file}<br>" \ + "YaST cannot continue and will quit.<br>" \ + "<br>" \ + "Possible causes and remedies:" \ + "<ol>" \ + "<li>You made a mistake when changing the file by hand," \ + " the syntax is invalid. Try reverting the changes.</li>" \ + "<li>The syntax is in fact valid but YaST does not recognize it." \ + " Please report a YaST bug.</li>" \ + "<li>YaST made a mistake and wrote invalid syntax earlier." \ + " Please report a YaST bug.</li>" \ + "</ol>" + msg + "Caller: #{CGI::escapeHTML(e.backtrace.first)}<br><br>" \ + "Details: #{CGI::escapeHTML(e.message)}" end # @param [Exception] e the caught exception # @return [String] human readable exception description private_class_method def self.internal_error_msg(e) - msg = "Internal error. Please report a bug report with logs.\n" \ - "Run save_y2logs to get complete logs.\n\n" + msg = "Internal error. Please report a bug report with logs.<br>" \ + "Run save_y2logs to get complete logs.<br><br>" if e.is_a?(ArgumentError) && e.message =~ /invalid byte sequence in UTF-8/ - msg += "A string was encountered that is not valid in UTF-8.\n" \ - "The system encoding is #{Encoding.locale_charmap.inspect}.\n" \ - "Refer to https://www.suse.com/support/kb/doc?id=7018056.\n\n" + msg += "A string was encountered that is not valid in UTF-8.<br>" \ + "The system encoding is #{Encoding.locale_charmap.inspect}.<br>" \ + "Refer to https://www.suse.com/support/kb/doc?id=7018056.<br><br>" end - msg + "Caller: #{e.backtrace.first}\n\n" \ - "Details: #{e.message}" + msg + "Caller: #{CGI::escapeHTML(e.backtrace.first)}<br><br>" \ + "Details: #{CGI::escapeHTML(e.message)}" end # Handles a SignalExpection private_class_method def self.handle_signal_exception(e) signame = Signal.signame(e.signo) - msg = "YaST received a signal %s and will exit.\n" % signame + msg = "YaST received a signal %s and will exit.<br>" % signame # sigterm are often sent by user if e.signo == 15 - msg += "If termination is not sent by user then please report a bug report with logs.\n" + msg += "If termination is not sent by user then please report a bug report with logs.<br>" else - msg += "Please report a bug report with logs.\n" + msg += "Please report a bug report with logs.<br>" end msg += "Run save_y2logs to get complete logs." @@ -253,18 +272,32 @@ Builtins.y2error("Client %1 failed with '%2' (%3).\nBacktrace:\n%4", client, e.message, - e.class, + e.class.to_s, e.backtrace.join("\n")) - msg = internal_error_msg(e) + if e.class.to_s == "CFA::AugeasParsingError" + msg = parsing_error_msg(e) + else + msg = internal_error_msg(e) + end + msg.gsub!(/\n/, "<br />") + + # Pure approximation here + # 50 is for usable text area width, +6 is for additional lines like + # button line, Error caption and so. Whole dialog is at most 20 lines + # high to fit into screen + height = [msg.size / 50 + 6, 20].min if ask_to_run_debugger? Yast.import "Popup" Yast.import "Label" - msg += "\n\nStart the Ruby debugger now and debug the issue?" \ + msg += "<br><br>Start the Ruby debugger now and debug the issue?" \ " (Experts only!)" - if Popup.YesNoHeadline(Label.ErrorMsg, msg) + if Popup.AnyQuestionRichText(Label.ErrorMsg, msg, 60, height, + Label.YesButton, + Label.NoButton, + :focus_none) Debugger.start # Now you can restart the client and watch it step-by-step with # "next"/"step" commands or you can add some breakpoints into @@ -273,12 +306,7 @@ end else Yast.import "Report" - # Pure approximation here - # 50 is for usable text area width, +6 is for additional lines like - # button line, Error caption and so. Whole dialog is at most 20 lines - # high to fit into screen - height = [msg.size / 50 + 6, 20].min - Report.LongError(msg.gsub(/\n/, '<br />'), height:height) + Report.LongError(msg, height: height) end rescue Exception => e Builtins.y2internal("Error reporting failed with '%1'.Backtrace:\n%2", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/CMakeLists.txt new/yast2-ruby-bindings-4.3.9/tests/CMakeLists.txt --- old/yast2-ruby-bindings-4.3.4/tests/CMakeLists.txt 2020-09-24 19:33:21.000000000 +0200 +++ new/yast2-ruby-bindings-4.3.9/tests/CMakeLists.txt 2020-11-12 11:45:50.000000000 +0100 @@ -1,6 +1,11 @@ -# -# CMakeLists.txt for yast2/ruby-bindings/tests/ruby -# +# CMakeLists.txt for yast-ruby-bindings/tests + +# use +# make test +# or, for verbose output, +# make test ARGS=-V +# ARGS is passed to ctest; see also +# man ctest ENABLE_TESTING() @@ -12,3 +17,8 @@ ADD_TEST("integration" ruby ${CMAKE_CURRENT_SOURCE_DIR}/integration/run.rb) ADD_TEST("translations" rspec --format doc ${CMAKE_CURRENT_SOURCE_DIR}/integration/translations_spec.rb) + +file(GLOB libyui_specs "libyui/*_spec.rb") +foreach(test ${libyui_specs}) + ADD_TEST(${test} rspec --format doc ${test}) +endforeach(test) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/builtins_regexps_spec.rb new/yast2-ruby-bindings-4.3.9/tests/builtins_regexps_spec.rb --- old/yast2-ruby-bindings-4.3.4/tests/builtins_regexps_spec.rb 2020-09-24 19:33:21.000000000 +0200 +++ new/yast2-ruby-bindings-4.3.9/tests/builtins_regexps_spec.rb 2020-11-12 11:45:50.000000000 +0100 @@ -83,13 +83,13 @@ describe ".regexptokenize" do it "works as expected" do - expect(Yast::Builtins.regexptokenize("aaabbBb", "(.*[A-Z]).*")).to eq(["aaabbB"]) + expect(Yast::Builtins.regexptokenize("aaabb7b", "(.*[0-9]).*")).to eq(["aaabb7"]) expect(Yast::Builtins.regexptokenize("aaabbb", "(.*ab)(.*)")).to eq(["aaab", "bb"]) expect(Yast::Builtins.regexptokenize("aaabbb", "(.*ba).*")).to eq([]) expect(Yast::Builtins.regexptokenize("aaabbb", "(.*ba).*(")).to eq(nil) # the result must be UTF-8 string - expect(Yast::Builtins.regexptokenize("aaabbBb", "(.*[A-Z]).*").first.encoding).to eq(Encoding::UTF_8) + expect(Yast::Builtins.regexptokenize("aaabb7b", "(.*[0-9]).*").first.encoding).to eq(Encoding::UTF_8) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/integration/run.rb new/yast2-ruby-bindings-4.3.9/tests/integration/run.rb --- old/yast2-ruby-bindings-4.3.4/tests/integration/run.rb 2020-09-24 19:33:21.000000000 +0200 +++ new/yast2-ruby-bindings-4.3.9/tests/integration/run.rb 2020-11-12 11:45:50.000000000 +0100 @@ -29,7 +29,9 @@ test = File.dirname(__FILE__) + "/std_streams_spec.rb" cmd = "rspec #{test} >#{OUTPUT} 2>&1" -`tmux -c '#{cmd}; echo \$? > #{RESULT}'` +tmux_out = `TERM=screen tmux -c '#{cmd}; echo \$? > #{RESULT}'` +puts "Outside tmux output:" +puts tmux_out if File.exist?(RESULT) && File.read(RESULT) == "0\n" puts "Test succeeded." cleanup diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/integration/std_streams_spec.rb new/yast2-ruby-bindings-4.3.9/tests/integration/std_streams_spec.rb --- old/yast2-ruby-bindings-4.3.4/tests/integration/std_streams_spec.rb 2020-09-24 19:33:21.000000000 +0200 +++ new/yast2-ruby-bindings-4.3.9/tests/integration/std_streams_spec.rb 2020-11-12 11:45:50.000000000 +0100 @@ -3,13 +3,15 @@ require_relative "../test_helper" require "yast/ui_shortcuts" -Yast.import "UI" - def std_puts(message) $stdout.puts "stdout: #{message}" $stderr.puts "stderr: #{message}" end +std_puts "tty before importing UI" +std_puts "TERM=#{ENV['TERM']}" +Yast.import "UI" + # Regression test for the fix of bnc#943757 implemented # in libyui-ncurses 2.47.3 describe "streams redirection in libyui-ncurses" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/libyui/menu_item_spec.rb new/yast2-ruby-bindings-4.3.9/tests/libyui/menu_item_spec.rb --- old/yast2-ruby-bindings-4.3.4/tests/libyui/menu_item_spec.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-ruby-bindings-4.3.9/tests/libyui/menu_item_spec.rb 2020-11-12 11:45:50.000000000 +0100 @@ -0,0 +1,59 @@ +require_relative "rspec_tmux_tui" + +describe "Menu Item" do + around(:each) do |ex| + @tui = YastTui.new + @tui.example("MenuBar-shortcuts-test") do + ex.run + end + end + + bug = "1177760" # https://bugzilla.suse.com/show_bug.cgi?id=1177760 + it "has hotkeys in menu items, boo##{bug}" do + @base = "menu_hotkeys_#{bug}" + @tui.await(/File.*Edit.*View/) + @tui.capture_pane_to("#{@base}-1-initial") + + @tui.send_keys "M-V" # &View + @tui.capture_pane_to("#{@base}-2-view-menu-activated") + + @tui.send_keys "M-N" # &Normal + @tui.capture_pane_to("#{@base}-3-normal-menu-item-activated") + + # the label + expect(@tui.capture_pane).to include("Last Event") + # the output + expect(@tui.capture_pane).to include("view_normal") + + @tui.send_keys "M-Q" # &Quit + end + + bug = "1178394" # https://bugzilla.suse.com/show_bug.cgi?id=1178394 + it "remains disabled after hotkeys are recomputed" do + @base = "menu_disabled_#{bug}" + @tui.await(/File.*Edit.*View/) + @tui.capture_pane_to("#{@base}-1-initial") + + @tui.send_keys "M-E" # &Edit + @tui.capture_pane_to("#{@base}-2-edit-menu-activated") + + # select the 1st available item; it is Copy because Cut is disabled + @tui.send_keys "Enter" + @tui.capture_pane_to("#{@base}-3-copy-item-activated") + expect(@tui.capture_pane).to include("Last Event:", "copy") + + # This changes the shortcuts! + @tui.send_keys "M-B" # Extra &Buttons + @tui.capture_pane_to("#{@base}-4-extra-buttons-activated") + + @tui.send_keys "M-T" # Edi&t + @tui.capture_pane_to("#{@base}-5-edit-menu-activated") + + # select the 1st available item; it is Copy because Cut is disabled + @tui.send_keys "Enter" + @tui.capture_pane_to("#{@base}-6-copy-item-activated") + expect(@tui.capture_pane).to include("Last Event:", "copy") + + @tui.send_keys "M-Q" # &Quit + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/libyui/multi_selection_box_spec.rb new/yast2-ruby-bindings-4.3.9/tests/libyui/multi_selection_box_spec.rb --- old/yast2-ruby-bindings-4.3.4/tests/libyui/multi_selection_box_spec.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-ruby-bindings-4.3.9/tests/libyui/multi_selection_box_spec.rb 2020-11-12 11:45:50.000000000 +0100 @@ -0,0 +1,115 @@ +require_relative "rspec_tmux_tui" + +describe "MultiSelectionBox" do + context "Basics" do + before(:all) do + @base = "multi_selection_box_basics" + @tui = YastTui.new + @tui.example("MultiSelectionBox-test") + @tui.await("Select toppings") + @tui.capture_pane_to("#{@base}-1") + end + + after(:all) do + @tui.send_keys "M-C" # &Close + end + + describe "Visual appearance" do + it "Has all the expected items" do + # the output; //m = match across lines + expect(@tui.capture_pane).to match(/Cheese.*Tomatoes.*Mushrooms.*Onions.*Salami.*Ham/m) + end + + it "Visually selects the right items initially" do + expect(@tui.capture_pane).to include( + "[x] Cheese", + "[x] Tomatoes", + "[ ] Mushrooms", + "[ ] Onions", + "[ ] Salami", + "[ ] Ham") + end + end + + describe "Introspection" do + it "QueryWidget(:SelectedItems) reports the correct items" do + expect(@tui.capture_pane).to match(/Selected:\s+\[:cheese, :tomatoes\]/) + end + + it "QueryWidget(:CurrentItem) reports the correct item" do + expect(@tui.capture_pane).to match(/Current:\s+:cheese/) + end + end + + describe "Basic keyboard handling" do + it "Moving the cursor works" do + @tui.send_keys "M-S" # &Select toppings + @tui.send_keys "Home" # first item + @tui.send_keys "Down" + @tui.send_keys "Down" + expect(@tui.capture_pane).to match(/Current:\s+:mushrooms/) + @tui.send_keys "End" # last item + expect(@tui.capture_pane).to match(/Current:\s+:ham/) + end + + it "Selecing an item works visually and in the internal state" do + @tui.send_keys "M-S" # &Select toppings + @tui.send_keys "End" # last item ("Ham") + @tui.send_keys "Space" # select/deselect item + expect(@tui.capture_pane).to match(/Selected:\s+\[:cheese, :tomatoes\, :ham\]/) + expect(@tui.capture_pane).to include("[x] Ham") + end + + it "Deselecting an item works visually and in the internal state" do + @tui.send_keys "M-S" # &Select toppings + @tui.send_keys "Home" # first item + @tui.send_keys "Down" # one item down to "Tomatoes" + @tui.send_keys "Space" # select/deselect item + expect(@tui.capture_pane).to match(/Selected:\s+\[:cheese\, :ham\]/) + expect(@tui.capture_pane).to include("[ ] Tomatoes") + end + end + + describe "Exchanging content" do + it "Replacing all items works" do + expect(@tui.capture_pane).to include("[ ] Vegetarian") + @tui.send_keys "M-V" # &Vegetarian + @tui.await(/Current:.*:mushrooms/) + expect(@tui.capture_pane).to include("[x] Vegetarian") + expect(@tui.capture_pane).not_to include("Salami") + expect(@tui.capture_pane).not_to include("Ham") + expect(@tui.capture_pane).to match(/Selected:.*:cheese, :tomatoes, :mushrooms/) + + @tui.send_keys "M-V" # &Vegetarian + @tui.await("Salami") + expect(@tui.capture_pane).to include("[ ] Vegetarian") + expect(@tui.capture_pane).to include("Salami") + expect(@tui.capture_pane).to include("Ham") + expect(@tui.capture_pane).to match(/Selected:.*:cheese, :tomatoes, :salami/) + end + end + end + + context "Known fixed bugs" do + + around(:each) do |ex| + @base = "multi_selection_box" + @tui = YastTui.new + @tui.example("MultiSelectionBox-test") do + @tui.await("Select toppings") + ex.run + @tui.send_keys "M-C" # &Close + end + end + + it "bsc#1177985: QueryWidget(:SelectedItems) does not return nil after replacing the items" do + @bug = "1177985" # https://bugzilla.suse.com/show_bug.cgi?id=1177985 + + @tui.send_keys "M-V" # &Vegetarian + @tui.await(/Current:.*:mushrooms/) + @tui.capture_pane_to("#{@base}-#{@bug}") + + expect(@tui.capture_pane).to match(/Selected:.*:cheese, :tomatoes, :mushrooms/) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/libyui/rspec_tmux_tui.rb new/yast2-ruby-bindings-4.3.9/tests/libyui/rspec_tmux_tui.rb --- old/yast2-ruby-bindings-4.3.4/tests/libyui/rspec_tmux_tui.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-ruby-bindings-4.3.9/tests/libyui/rspec_tmux_tui.rb 2020-11-12 11:45:50.000000000 +0100 @@ -0,0 +1,135 @@ +require "shellwords" + +# Drive interactive TUI (textual user interface) with tmux. +# https://github.com/tmux/tmux +class TmuxTui + class Error < RuntimeError + end + + def self.new_session(*args) + new(*args) + end + + attr_reader :session_name + + # @param session_name [String] + def initialize(session_name: nil) + @session_name = session_name || new_session_name + end + + # @param shell_command [String] + # @param xy [(Integer, Integer)] + # @param detach [Boolean] + # @param remain_on_exit [Boolean] useful if shell_command may unexpectedly + # fail quickly. In that case we can still capture the pane + # and read the error messages. + def new_session(shell_command, + xy: [80, 24], detach: true, remain_on_exit: true) + + @shell_command = shell_command + @x, @y = xy + @detach = detach + + detach_args = @detach ? ["-d"] : [] + remain_on_exit_args = if remain_on_exit + ["set-hook", "-g", "session-created", "set remain-on-exit on", ";"] + else + [] + end + + tmux_ret = system "tmux", + * remain_on_exit_args, + "new-session", + "-s", @session_name, + "-x", @x.to_s, + "-y", @y.to_s, + * detach_args, + "sh", "-c", shell_command + + return tmux_ret unless block_given? + + yield + ensure_no_session + end + + def new_session_name + "tmux-tui-#{rand 10000}" + end + + # @param color [Boolean] include escape sequences to reproduce the colors + # @param sleep [Numeric] in seconds; by default it is useful to wait a bit + # to give the program time to react to user input + # @return [String] + def capture_pane(color: false, sleep_s: 0.3) + sleep(sleep_s) + esc = color ? "-e" : "" + # FIXME: failure of the command? + `tmux capture-pane -t #{session_name.shellescape} -p #{esc}` + end + + # Capture the pane to filename.out.txt (plain) + # and filename.out.esc (color using terminal escapes) + # @param filename [String] + # @return [void] + def capture_pane_to(filename) + # FIXME: two separate captures could end up with different screen content. + # If that ends up being a problem we will need to produce plain text + # by filtering the color version + + txt = capture_pane(color: false) + esc = capture_pane(color: true, sleep_s: 0) + File.write("#{filename}.out.txt", txt) + File.write("#{filename}.out.esc", esc) + end + + # Wait about 10 seconds for *pattern* to appear. + # @param pattern [String,Regexp] a literal String or a regular expression + # @raise [Error] if it does not appear + # @return [void] + def await(pattern) + pattern = Regexp.new(Regexp.quote(pattern)) if pattern.is_a? String + + sleeps = [0.1, 0.2, 0.2, 0.5, 1, 2, 2, 5] + txt = "" + sleeps.each do |sl| + txt = capture_pane + if txt =~ pattern + sleep 0.1 # draw the rest of the screen + return nil + else + sleep sl + end + end + raise Error, "Timed out waiting for #{pattern.inspect}. Seen:\n#{txt}" + end + + # @param keys [String] "C-X" for Ctrl-X, "M-X" for Alt-X, think "Meta"; + # for details see: + # man tmux | less +/"^KEY BINDINGS" + def send_keys(keys) + system "tmux", "send-keys", "-t", session_name, keys + end + + def has_session? # rubocop:disable Style/PredicateName + # the method name mimics the tmux command + system "tmux", "has-session", "-t", session_name + end + + def kill_session + system "tmux", "kill-session", "-t", session_name + end + + def ensure_no_session + kill_session if has_session? + end +end + +class YastTui < TmuxTui + def example(basename, &block) + basename += ".rb" unless basename.end_with? ".rb" + yast_ncurses = "#{__dir__}/yast_ncurses" + example_dir = "/usr/share/doc/packages/yast2-ycp-ui-bindings/examples" + + new_session("#{yast_ncurses} #{example_dir}/#{basename}", &block) + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/libyui/table_sort.rb new/yast2-ruby-bindings-4.3.9/tests/libyui/table_sort.rb --- old/yast2-ruby-bindings-4.3.4/tests/libyui/table_sort.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-ruby-bindings-4.3.9/tests/libyui/table_sort.rb 2020-11-12 11:45:50.000000000 +0100 @@ -0,0 +1,62 @@ +#! /usr/bin/env ruby + +require_relative "../test_helper" +require "yast" + +if Yast.ui_component == "" + Yast.ui_component = ARGV[0] || "ncurses" +end + +module Yast + class TableCellClient < Client + def main + Yast.import "UI" + + # notice that neither the ids nor the values are sorted here + contents = [ + Item(Id("id-zzz-1-bbb"), "name-bbb", "value-bbb"), + Item(Id("id-yyy-2-ccc"), "name-ccc", "value-ccc"), + Item(Id("id-xxx-3-aaa"), "name-aaa", "value-aaa"), + ] + keep_sorting = WFM.Args()[0] == "no-sort" + opts = keep_sorting ? Opt(:keepSorting, :notify) : Opt(:notify) + UI.OpenDialog( + VBox( + Label("Table sorting test"), + MinSize( + 25, 8, + Table(Id(:table), opts, Header("Name", "Value"), contents) + ), + Label("Enter/Double-click any item to uppercase the value"), + HBox( + HSquash(Label("Current Item: ")), + Label(Id(:current_item), Opt(:outputField, :hstretch), "...") + ), + PushButton(Id(:cancel), "&Close") + ) + ) + + if WFM.Args()[0] == "change-current-item" + # test boo#1177145, wrong item is selected + UI.ChangeWidget(Id(:table), :CurrentItem, "id-yyy-2-ccc") + current_item_id = UI.QueryWidget(Id(:table), :CurrentItem) + UI.ChangeWidget(Id(:current_item), :Value, current_item_id.inspect) + end + + while UI.UserInput != :cancel + current_item_id = UI.QueryWidget(Id(:table), :CurrentItem) + UI.ChangeWidget(Id(:current_item), :Value, current_item_id.inspect) + + value = UI.QueryWidget(:table, Cell(current_item_id, 1)) + UI.ChangeWidget(Id(:table), Cell(current_item_id, 1), value.upcase) + end + items = UI.QueryWidget(:table, :Items) + Builtins.y2milestone("Items: %1", items) + + UI.CloseDialog + nil + end + end +end + +Yast::TableCellClient.new.main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/libyui/table_sort_spec.rb new/yast2-ruby-bindings-4.3.9/tests/libyui/table_sort_spec.rb --- old/yast2-ruby-bindings-4.3.4/tests/libyui/table_sort_spec.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-ruby-bindings-4.3.9/tests/libyui/table_sort_spec.rb 2020-11-12 11:45:50.000000000 +0100 @@ -0,0 +1,46 @@ +require_relative "rspec_tmux_tui" + +describe "Table" do + context "when it sorts the items," do + around(:each) do |ex| + y2start = "ruby -r #{__dir__}/../test_helper #{__dir__}/../../src/y2start/y2start" + @base = "table_sort" + @tui = TmuxTui.new + @tui.new_session "#{y2start} #{__dir__}/#{@base}.rb -a change-current-item ncurses" do + ex.run + end + end + + bug = "1165388" # https://bugzilla.suse.com/show_bug.cgi?id=1165388 + it "ChangeWidget(_, Cell(row, col)) changes the correct cell, boo##{bug}" do + base = @base + "_cell" + @tui.await(/Table sorting test/) + @tui.capture_pane_to("#{base}-1-initial") + + @tui.send_keys "Home" # go to first table row + @tui.capture_pane_to("#{base}-2-first-row-selected") + + @tui.send_keys "Enter" # activate first table row + @tui.capture_pane_to("#{base}-3-first-row-activated") + + expect(@tui.capture_pane).to match(/name-aaa.VALUE-AAA/) + + @tui.send_keys "M-C" # &Close + end + + bug = "1177145" # https://bugzilla.suse.com/show_bug.cgi?id=1177145 + it "ChangeWidget(_, :CurrentItem) activates the correct line, boo##{bug}" do + base = @base + "_current_item" + @tui.await(/Table sorting test/) + @tui.capture_pane_to("#{base}-1-ccc-selected") + # the UI code performs a + # UI.ChangeWidget(Id(:table), :CurrentItem, "id-yyy-2-ccc") + # then + # UI.QueryWidget(Id(:table), :CurrentItem) + @tui.send_keys "Enter" # activate the current item to produce an event + expect(@tui.capture_pane).to match(/Current Item: "id-yyy-2-ccc"/) + + @tui.send_keys "M-C" # &Close + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ruby-bindings-4.3.4/tests/libyui/yast_ncurses new/yast2-ruby-bindings-4.3.9/tests/libyui/yast_ncurses --- old/yast2-ruby-bindings-4.3.4/tests/libyui/yast_ncurses 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-ruby-bindings-4.3.9/tests/libyui/yast_ncurses 2020-11-12 11:45:50.000000000 +0100 @@ -0,0 +1,5 @@ +#! /usr/bin/env ruby +require_relative "../test_helper" +require "yast" +Yast.ui_component = "ncurses" +load ARGV[0] _______________________________________________ openSUSE Commits mailing list -- commit@lists.opensuse.org To unsubscribe, email commit-le...@lists.opensuse.org List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette List Archives: https://lists.opensuse.org/archives/list/commit@lists.opensuse.org