Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-storage-ng for openSUSE:Factory checked in at 2022-09-27 20:13:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-storage-ng (Old) and /work/SRC/openSUSE:Factory/.yast2-storage-ng.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-storage-ng" Tue Sep 27 20:13:22 2022 rev:130 rq:1006181 version:4.5.9 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-storage-ng/yast2-storage-ng.changes 2022-08-23 14:26:43.383236202 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-storage-ng.new.2275/yast2-storage-ng.changes 2022-09-27 20:13:26.889763165 +0200 @@ -1,0 +2,7 @@ +Mon Sep 26 10:48:49 UTC 2022 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Decouple user interface logic from the probing process + (related to gh#yast/d-installer#247). +- 4.5.9 + +------------------------------------------------------------------- Old: ---- yast2-storage-ng-4.5.8.tar.bz2 New: ---- yast2-storage-ng-4.5.9.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-storage-ng.spec ++++++ --- /var/tmp/diff_new_pack.Tqooyz/_old 2022-09-27 20:13:27.385764259 +0200 +++ /var/tmp/diff_new_pack.Tqooyz/_new 2022-09-27 20:13:27.389764268 +0200 @@ -17,7 +17,7 @@ Name: yast2-storage-ng -Version: 4.5.8 +Version: 4.5.9 Release: 0 Summary: YaST2 - Storage Configuration License: GPL-2.0-only OR GPL-3.0-only ++++++ yast2-storage-ng-4.5.8.tar.bz2 -> yast2-storage-ng-4.5.9.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/package/yast2-storage-ng.changes new/yast2-storage-ng-4.5.9/package/yast2-storage-ng.changes --- old/yast2-storage-ng-4.5.8/package/yast2-storage-ng.changes 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/package/yast2-storage-ng.changes 2022-09-26 17:00:58.000000000 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Mon Sep 26 10:48:49 UTC 2022 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Decouple user interface logic from the probing process + (related to gh#yast/d-installer#247). +- 4.5.9 + +------------------------------------------------------------------- Tue Aug 16 17:42:49 UTC 2022 - Josef Reidinger <jreidin...@suse.com> - Adapt to new types of mount by in libstorage-ng. Skipped by now diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/package/yast2-storage-ng.spec new/yast2-storage-ng-4.5.9/package/yast2-storage-ng.spec --- old/yast2-storage-ng-4.5.8/package/yast2-storage-ng.spec 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/package/yast2-storage-ng.spec 2022-09-26 17:00:58.000000000 +0200 @@ -16,7 +16,7 @@ # Name: yast2-storage-ng -Version: 4.5.8 +Version: 4.5.9 Release: 0 Summary: YaST2 - Storage Configuration License: GPL-2.0-only OR GPL-3.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2partitioner/dialogs/probing_issues.rb new/yast2-storage-ng-4.5.9/src/lib/y2partitioner/dialogs/probing_issues.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2partitioner/dialogs/probing_issues.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/src/lib/y2partitioner/dialogs/probing_issues.rb 2022-09-26 17:00:58.000000000 +0200 @@ -81,7 +81,7 @@ # # @return [Y2Issues::List] def issues - DeviceGraphs.instance.system.issues_manager.probing_issues + DeviceGraphs.instance.system.probing_issues end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2partitioner/widgets/menus/view.rb new/yast2-storage-ng-4.5.9/src/lib/y2partitioner/widgets/menus/view.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2partitioner/widgets/menus/view.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/src/lib/y2partitioner/widgets/menus/view.rb 2022-09-26 17:00:58.000000000 +0200 @@ -90,7 +90,7 @@ end def probing_issues? - DeviceGraphs.instance.system.issues_manager.probing_issues.any? + DeviceGraphs.instance.system.probing_issues.any? end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2storage/callbacks/probe.rb new/yast2-storage-ng-4.5.9/src/lib/y2storage/callbacks/probe.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2storage/callbacks/probe.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/src/lib/y2storage/callbacks/probe.rb 2022-09-26 17:00:58.000000000 +0200 @@ -18,13 +18,12 @@ # find current contact information at www.suse.com. require "yast" -require "yast2/popup" require "y2storage/callbacks/issues_callback" require "y2storage/storage_features_list" require "y2storage/package_handler" Yast.import "Mode" -Yast.import "Label" +Yast.import "Pkg" module Y2Storage module Callbacks @@ -36,10 +35,12 @@ include Yast::Logger - def initialize + # @param user_callbacks [UserProbe] Probing user callbacks + def initialize(user_callbacks: nil) textdomain "storage" - super + super() + @user_callbacks = user_callbacks || YastProbe.new end # Callback for libstorage-ng to show a message to the user. @@ -81,11 +82,13 @@ # Redirect to error callback if no packages can be installed. return error(message, what) unless can_install?(packages) - answer = show_popup(packages) + answer = user_callbacks.install_packages?(packages) log.info "User answer: #{answer} (packages #{packages})" - return true if answer == :ignore + # continue if the user does not want to install the missing packages + return true unless answer + # install the missing packages and try again PackageHandler.new(packages).commit @again = true false @@ -93,6 +96,12 @@ # Initialization def begin + # Release all sources before probing. Otherwise, unmount action could fail if the mount point + # of the software source device is modified. Note that this is only necessary during the + # installation because libstorage-ng would try to unmount from the chroot path + # (e.g., /mnt/mount/point) and there is nothing mounted there. + Yast::Pkg.SourceReleaseAll if Yast::Mode.installation + @again = false end @@ -105,25 +114,8 @@ private - # Interactive pop-up, AutoYaST is not taken into account because this is - # only used in normal mode, not in (auto)installation. - def show_popup(packages) - text = n_( - "The following package needs to be installed to fully analyze the system:\n" \ - "%s\n\n" \ - "If you ignore this and continue without installing it, the system\n" \ - "information presented by YaST will be incomplete.", - "The following packages need to be installed to fully analyze the system:\n" \ - "%s\n\n" \ - "If you ignore this and continue without installing them, the system\n" \ - "information presented by YaST will be incomplete.", - packages.size - ) % packages.sort.join(", ") - - buttons = { ignore: Yast::Label.IgnoreButton, install: Yast::Label.InstallButton } - - Yast2::Popup.show(text, buttons: buttons, focus: :install) - end + # @return [UserProbe] Probing user callbacks + attr_reader :user_callbacks def can_install?(packages) if packages.empty? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2storage/callbacks/user_probe.rb new/yast2-storage-ng-4.5.9/src/lib/y2storage/callbacks/user_probe.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2storage/callbacks/user_probe.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.5.9/src/lib/y2storage/callbacks/user_probe.rb 2022-09-26 17:00:58.000000000 +0200 @@ -0,0 +1,55 @@ +# Copyright (c) [2022] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +module Y2Storage + module Callbacks + # Class to implement callbacks used during probing + # + # This classes can be inherited to customize the behavior during + # the probing phase. + class UserProbe + include Yast::Logger + + # Reports activation and probing issues + # + # This default implementation always returns true, asking libstorage-ng + # to continue. + # + # @param issues [IssuesList] Probing issues + # @return [Boolean] true if the user acknowledges the issues and wants + # to continue; false otherwise. + def report_issues(issues) + log.info "Found the following issues in the devicegraph: #{issues.inspect}" + true + end + + # Determines whether to install packages which provide missing commands + # + # This default implementation always returns false, preventing packages + # installation. + # + # @param packages [Array<String>] List of packages to install + # @return [Boolean] return true if the package should be installed; false otherwise + def install_packages?(packages) + log.info "Found the following issues in the devicegraph: #{packages}" + false + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2storage/callbacks/yast_probe.rb new/yast2-storage-ng-4.5.9/src/lib/y2storage/callbacks/yast_probe.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2storage/callbacks/yast_probe.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.5.9/src/lib/y2storage/callbacks/yast_probe.rb 2022-09-26 17:00:58.000000000 +0200 @@ -0,0 +1,79 @@ +# Copyright (c) [2022] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "yast" +require "y2storage/issues_reporter" +require "y2storage/callbacks/user_probe" +require "yast2/popup" + +Yast.import "Label" + +module Y2Storage + module Callbacks + # Class to implement callbacks used during probing + # + # It reimplements the default behaviour to match YaST requirements. + class YastProbe < UserProbe + include Yast::I18n + include Yast::Logger + + def initialize + super + textdomain "storage" + end + + # Reports activation and probing issues through IssuesReporter + # + # @param issues [IssuesList] Probing issues + # @return [Boolean] true if the user accepts to continue; false otherwise + # @see UserProbe#report_issues + def report_issues(issues) + return true if issues.empty? + + reporter = Y2Storage::IssuesReporter.new(issues) + reporter.report(message: _("Issues found while analyzing the storage devices.")) + end + + # Interactive pop-up, AutoYaST is not taken into account because this is + # only used in normal mode, not in (auto)installation. + # + # @param packages [Array<String>] List of packages to install + # @return [Boolean] true if the user accepts to install the packages; false otherwise + # @see UserProbe#install_packages? + def install_packages?(packages) + text = n_( + "The following package needs to be installed to fully analyze the system:\n" \ + "%s\n\n" \ + "If you ignore this and continue without installing it, the system\n" \ + "information presented by YaST will be incomplete.", + "The following packages need to be installed to fully analyze the system:\n" \ + "%s\n\n" \ + "If you ignore this and continue without installing them, the system\n" \ + "information presented by YaST will be incomplete.", + packages.size + ) % packages.sort.join(", ") + + buttons = { ignore: Yast::Label.IgnoreButton, install: Yast::Label.InstallButton } + + answer = Yast2::Popup.show(text, buttons: buttons, focus: :install) + answer == :install + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2storage/callbacks.rb new/yast2-storage-ng-4.5.9/src/lib/y2storage/callbacks.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2storage/callbacks.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/src/lib/y2storage/callbacks.rb 2022-09-26 17:00:58.000000000 +0200 @@ -20,5 +20,7 @@ require "y2storage/callbacks/initialize" require "y2storage/callbacks/activate" require "y2storage/callbacks/probe" +require "y2storage/callbacks/user_probe" +require "y2storage/callbacks/yast_probe" require "y2storage/callbacks/commit" require "y2storage/callbacks/check" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2storage/devicegraph.rb new/yast2-storage-ng-4.5.9/src/lib/y2storage/devicegraph.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2storage/devicegraph.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/src/lib/y2storage/devicegraph.rb 2022-09-26 17:00:58.000000000 +0200 @@ -38,7 +38,6 @@ require "y2storage/storage_class_wrapper" require "y2storage/storage_manager" require "y2storage/storage_features_list" -require "y2storage/issues_manager" module Y2Storage # The master container of libstorage. @@ -130,6 +129,9 @@ storage_forward :remove_device private :remove_device + # @return [IssuesList] List of probing issues + attr_accessor :probing_issues + # Creates a new devicegraph with the information read from a file # # @param filename [String] @@ -141,11 +143,6 @@ new(devicegraph) end - # @return [IssuesManager] - def issues_manager - @issues_manager ||= IssuesManager.new(self) - end - # @return [Devicegraph] def dup new_graph = ::Storage::Devicegraph.new(to_storage_value.storage) @@ -169,7 +166,7 @@ # @param devicegraph [Devicegraph] def copy(devicegraph) storage_copy(devicegraph) - devicegraph.issues_manager.probing_issues = issues_manager.probing_issues + devicegraph.probing_issues = probing_issues devicegraph end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2storage/devicegraph_sanitizer.rb new/yast2-storage-ng-4.5.9/src/lib/y2storage/devicegraph_sanitizer.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2storage/devicegraph_sanitizer.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/src/lib/y2storage/devicegraph_sanitizer.rb 2022-09-26 17:00:58.000000000 +0200 @@ -81,7 +81,7 @@ # # @return [Y2Issues::List] def issues - devicegraph.issues_manager.probing_issues + devicegraph.probing_issues end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2storage/issues_manager.rb new/yast2-storage-ng-4.5.9/src/lib/y2storage/issues_manager.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2storage/issues_manager.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/src/lib/y2storage/issues_manager.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,72 +0,0 @@ -# Copyright (c) [2021] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require "yast" -require "y2issues/list" -require "y2storage/issues_reporter" -require "y2storage/storage_env" - -module Y2Storage - # Class to manage issues associated to a devicegraph - class IssuesManager - include Yast::I18n - - # List of probing issues - # - # @return [Y2Issues::List] - attr_accessor :probing_issues - - # Constructor - # - # @param devicegraph [Devicegraph] - def initialize(devicegraph) - textdomain "storage" - - @devicegraph = devicegraph - @probing_issues = Y2Issues::List.new - end - - # Reports probing issues - # - # If there are probing issues, then the user is asked whether to continue. - # If the $LIBSTORAGE_IGNORE_PROBE_ERRORS environment variable is set, the issues are not reported to - # the user. - # - # @return [Boolean] - def report_probing_issues - return true if probing_issues.empty? || StorageEnv.instance.ignore_probe_errors? - - reporter = IssuesReporter.new(probing_issues) - - reporter.report(message: probing_issues_message) - end - - private - - # @return [Devicegraph] - attr_reader :devicegraph - - # Message to show when reporting probing issues - # - # @return [String] - def probing_issues_message - _("Issues found while analyzing the storage devices.") - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/src/lib/y2storage/storage_manager.rb new/yast2-storage-ng-4.5.9/src/lib/y2storage/storage_manager.rb --- old/yast2-storage-ng-4.5.8/src/lib/y2storage/storage_manager.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/src/lib/y2storage/storage_manager.rb 2022-09-26 17:00:58.000000000 +0200 @@ -29,12 +29,12 @@ require "y2storage/callbacks" require "y2storage/hwinfo_reader" require "y2storage/configuration" +require "y2storage/storage_env" require "yast2/fs_snapshot" require "y2issues/list" Yast.import "Mode" Yast.import "Stage" -Yast.import "Pkg" module Y2Storage # Singleton class to provide access to the libstorage Storage object and @@ -157,12 +157,12 @@ # # @see #probe! # - # @param probe_callbacks [Callbacks::Probe, nil] + # @param callbacks [Callbacks::UserProbe, nil] # @return [Boolean] whether probing was successful, false if libstorage-ng # found a problem and the corresponding callback returned false (i.e. it # was decided to abort due to the error) - def probe(probe_callbacks: nil) - probe!(probe_callbacks: probe_callbacks) + def probe(callbacks = nil) + probe!(callbacks) true rescue Storage::Exception, Yast::AbortException => e log.error("ERROR: #{e.message}") @@ -180,15 +180,9 @@ # # @raise [Storage::Exception, Yast::AbortException] when probe fails # - # @param probe_callbacks [Callbacks::Probe, nil] - def probe!(probe_callbacks: nil) - probe_callbacks ||= Callbacks::Probe.new - - # Release all sources before probing. Otherwise, unmount action could fail if the mount point - # of the software source device is modified. Note that this is only necessary during the - # installation because libstorage-ng would try to unmount from the chroot path - # (e.g., /mnt/mount/point) and there is nothing mounted there. - Yast::Pkg.SourceReleaseAll if Yast::Mode.installation + # @param callbacks [Callbacks::Probe, nil] + def probe!(callbacks = nil) + probe_callbacks = Callbacks::Probe.new(user_callbacks: callbacks) begin @storage.probe(probe_callbacks) @@ -201,7 +195,7 @@ @probe_issues = probe_callbacks.issues probe_performed - manage_probing_issues + manage_probing_issues(callbacks) DumpManager.dump(@probed_graph) nil @@ -477,7 +471,7 @@ issues = activate_issues.concat(probe_issues) issues.concat(ProbedDevicegraphChecker.new(raw_probed).issues) - raw_probed.issues_manager.probing_issues = issues + raw_probed.probing_issues = issues end # Resets the #staging_revision @@ -494,11 +488,18 @@ # The raw probed devicegraph remains untouched, and the new sanitized one is internally saved and # copied into the staging devicegraph. # + # @param callbacks [Callbacks::UserProbe,nil] # @raise [Yast::AbortException] if the user decides to not continue. In that case, the probed # and staging devicegraphs also remain untouched, but they are useless for # proposal/partitioner. - def manage_probing_issues - continue = raw_probed.issues_manager.report_probing_issues + def manage_probing_issues(callbacks = nil) + probing_issues = raw_probed.probing_issues + + continue = true + if !StorageEnv.instance.ignore_probe_errors? && probing_issues.any? + callbacks ||= Callbacks::YastProbe.new + continue = callbacks.report_issues(raw_probed.probing_issues) + end raise Yast::AbortException, "Devicegraph contains errors. User has aborted." unless continue diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/test/y2partitioner/widgets/menus/view_test.rb new/yast2-storage-ng-4.5.9/test/y2partitioner/widgets/menus/view_test.rb --- old/yast2-storage-ng-4.5.8/test/y2partitioner/widgets/menus/view_test.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/test/y2partitioner/widgets/menus/view_test.rb 2022-09-26 17:00:58.000000000 +0200 @@ -30,8 +30,7 @@ let(:graphical) { true } - let(:issues_manager) { instance_double(Y2Storage::IssuesManager, probing_issues: issues) } - let(:devicegraph) { instance_double(Y2Storage::Devicegraph, issues_manager: issues_manager) } + let(:devicegraph) { instance_double(Y2Storage::Devicegraph, probing_issues: issues) } let(:device_graphs) { instance_double(Y2Partitioner::DeviceGraphs, system: devicegraph) } let(:issues) { Y2Issues::List.new } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/test/y2storage/callbacks/probe_test.rb new/yast2-storage-ng-4.5.9/test/y2storage/callbacks/probe_test.rb --- old/yast2-storage-ng-4.5.8/test/y2storage/callbacks/probe_test.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/test/y2storage/callbacks/probe_test.rb 2022-09-26 17:00:58.000000000 +0200 @@ -35,10 +35,36 @@ end describe "#begin" do + before do + allow(Yast::Pkg).to receive(:SourceReleaseAll) + end + it "clears again flag" do subject.begin expect(subject.again?).to be false end + + context "during installation" do + before do + allow(Yast::Mode).to receive(:installation).and_return(true) + end + + it "releases software source devices before probing" do + expect(Yast::Pkg).to receive(:SourceReleaseAll) + subject.begin + end + end + + context "in an installed system" do + before do + allow(Yast::Mode).to receive(:installation).and_return(false) + end + + it "releases software source devices before probing" do + expect(Yast::Pkg).to_not receive(:SourceReleaseAll) + subject.begin + end + end end describe "#again?" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/test/y2storage/callbacks/yast_probe_test.rb new/yast2-storage-ng-4.5.9/test/y2storage/callbacks/yast_probe_test.rb --- old/yast2-storage-ng-4.5.8/test/y2storage/callbacks/yast_probe_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.5.9/test/y2storage/callbacks/yast_probe_test.rb 2022-09-26 17:00:58.000000000 +0200 @@ -0,0 +1,111 @@ +#!/usr/bin/env rspec + +# Copyright (c) [2021] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "../spec_helper" +require "y2storage/callbacks/yast_probe" + +describe Y2Storage::Callbacks::YastProbe do + subject { described_class.new } + + let(:devicegraph) { devicegraph_from(scenario) } + + let(:scenario) { "mixed_disks" } + + describe "#report_issues" do + let(:issues) { Y2Issues::List.new([Y2Storage::Issue.new("Issue 1")]) } + let(:reporter) { Y2Storage::IssuesReporter.new(issues) } + let(:acepted) { true } + + before do + allow(Y2Storage::IssuesReporter).to receive(:new).with(issues) + .and_return(reporter) + + allow(reporter).to receive(:report).and_return(acepted) + end + + it "reports the issues" do + expect(reporter).to receive(:report) do |args| + expect(args[:message]).to include("Issues found") + end + + subject.report_issues(issues) + end + + context "when the report is accepted" do + let(:accepted) { true } + + it "returns true" do + expect(subject.report_issues(issues)).to eq(true) + end + end + + context "when the report is rejected" do + let(:acepted) { false } + + it "returns false" do + expect(subject.report_issues(issues)).to eq(false) + end + end + + context "when there are no probing issues" do + let(:issues) { Y2Issues::List.new } + + it "does not report issues" do + expect_any_instance_of(Y2Storage::IssuesReporter).to_not receive(:report) + + subject.report_issues(issues) + end + + it "returns true" do + expect(subject.report_issues(issues)).to eq(true) + end + end + end + + describe "#install_packages?" do + before do + allow(Yast2::Popup).to receive(:show).and_return(answer) + end + + let(:answer) { :install } + + it "asks the user whether packages should be installed" do + expect(Yast2::Popup).to receive(:show) + .with(/The following package needs to be installed/, buttons: Hash, focus: :install) + .and_return(:install) + subject.install_packages?(["btrfsprogs"]) + end + + context "if the clicks 'Ignore'" do + let(:answer) { :ignore } + + it "returns false" do + expect(subject.install_packages?(["btrfsprogs"])).to eq(false) + end + end + + context "if the clicks 'Ignore'" do + it "returns true" do + expect(subject.install_packages?(["btrfsprogs"])).to eq(true) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/test/y2storage/devicegraph_sanitizer_test.rb new/yast2-storage-ng-4.5.9/test/y2storage/devicegraph_sanitizer_test.rb --- old/yast2-storage-ng-4.5.8/test/y2storage/devicegraph_sanitizer_test.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/test/y2storage/devicegraph_sanitizer_test.rb 2022-09-26 17:00:58.000000000 +0200 @@ -27,10 +27,9 @@ let(:devicegraph) { devicegraph_from("mixed_disks") } let(:issues) { Y2Issues::List.new } - let(:issues_manager) { instance_double(Y2Storage::IssuesManager, probing_issues: issues) } before do - allow(devicegraph).to receive(:issues_manager).and_return(issues_manager) + allow(devicegraph).to receive(:probing_issues).and_return(issues) end describe "#sanitized_devicegraph" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/test/y2storage/devicegraph_test.rb new/yast2-storage-ng-4.5.9/test/y2storage/devicegraph_test.rb --- old/yast2-storage-ng-4.5.8/test/y2storage/devicegraph_test.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/test/y2storage/devicegraph_test.rb 2022-09-26 17:00:58.000000000 +0200 @@ -29,30 +29,18 @@ next_dev.nil? || device.compare_by_name(next_dev) < 0 end - describe "#issues_manager" do - before do - fake_scenario("mixed_disks") - end - - subject { fake_devicegraph } - - it "returns its issues manager instance" do - expect(subject.issues_manager).to be_a(Y2Storage::IssuesManager) - end - end - describe "#copy" do subject { fake_devicegraph } before do fake_scenario("mixed_disks") - subject.issues_manager.probing_issues = Y2Issues::List.new([Y2Storage::Issue.new("Issue 1")]) + subject.probing_issues = Y2Issues::List.new([Y2Storage::Issue.new("Issue 1")]) end let(:other_devicegraph) do devicegraph = subject.dup - devicegraph.issues_manager.probing_issues = Y2Issues::List.new + devicegraph.probing_issues = Y2Issues::List.new disk = devicegraph.find_by_name("/dev/sda") disk.delete_partition_table devicegraph @@ -64,14 +52,14 @@ end it "copies the issues into the given devicegraph" do - expect(subject.issues_manager.probing_issues) - .to_not eq(other_devicegraph.issues_manager.probing_issues) + expect(subject.probing_issues) + .to_not eq(other_devicegraph.probing_issues) subject.copy(other_devicegraph) - issues = other_devicegraph.issues_manager.probing_issues + issues = other_devicegraph.probing_issues - expect(issues).to eq(subject.issues_manager.probing_issues) + expect(issues).to eq(subject.probing_issues) expect(issues.to_a.size).to eq(1) expect(issues.to_a.first.message).to eq("Issue 1") end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/test/y2storage/issues_manager_test.rb new/yast2-storage-ng-4.5.9/test/y2storage/issues_manager_test.rb --- old/yast2-storage-ng-4.5.8/test/y2storage/issues_manager_test.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/test/y2storage/issues_manager_test.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,119 +0,0 @@ -#!/usr/bin/env rspec - -# Copyright (c) [2021] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require_relative "../spec_helper" -require "y2storage/issues_manager" - -describe Y2Storage::IssuesManager do - subject { described_class.new(devicegraph) } - - let(:devicegraph) { devicegraph_from(scenario) } - - let(:scenario) { "mixed_disks" } - - describe "#probing_issues" do - it "returns a list of Y2Issues" do - expect(subject.probing_issues).to be_a(Y2Issues::List) - end - end - - describe "#report_probing_issues" do - before do - subject.probing_issues = probing_issues - end - - context "when there are no probing issues" do - let(:probing_issues) { Y2Issues::List.new } - - it "does not report issues" do - expect_any_instance_of(Y2Storage::IssuesReporter).to_not receive(:report) - - subject.report_probing_issues - end - - it "returns true" do - expect(subject.report_probing_issues).to eq(true) - end - end - - context "when there are probing issues" do - let(:probing_issues) { Y2Issues::List.new([Y2Storage::Issue.new("Issue 1")]) } - - before do - allow_any_instance_of(Y2Storage::StorageEnv) - .to receive(:ignore_probe_errors?).and_return(ignore_errors) - end - - context "and the probing issues should be ignored" do - let(:ignore_errors) { true } - - it "does not report issues" do - expect_any_instance_of(Y2Storage::IssuesReporter).to_not receive(:report) - - subject.report_probing_issues - end - - it "returns true" do - expect(subject.report_probing_issues).to eq(true) - end - end - - context "and the probing issues should not be ignored" do - let(:ignore_errors) { false } - - before do - allow(Y2Storage::IssuesReporter).to receive(:new).with(subject.probing_issues) - .and_return(reporter) - - allow(reporter).to receive(:report).and_return(acepted) - end - - let(:reporter) { Y2Storage::IssuesReporter.new(subject.probing_issues) } - - let(:acepted) { true } - - it "reports the issues" do - expect(reporter).to receive(:report) do |args| - expect(args[:message]).to include("Issues found") - end - - subject.report_probing_issues - end - - context "and the report is acepted" do - let(:acepted) { true } - - it "returns true" do - expect(subject.report_probing_issues).to eq(true) - end - end - - context "and the report is rejected" do - let(:acepted) { false } - - it "returns false" do - expect(subject.report_probing_issues).to eq(false) - end - end - end - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.5.8/test/y2storage/storage_manager_test.rb new/yast2-storage-ng-4.5.9/test/y2storage/storage_manager_test.rb --- old/yast2-storage-ng-4.5.8/test/y2storage/storage_manager_test.rb 2022-08-17 15:32:33.000000000 +0200 +++ new/yast2-storage-ng-4.5.9/test/y2storage/storage_manager_test.rb 2022-09-26 17:00:58.000000000 +0200 @@ -684,15 +684,15 @@ context "and there are issues during probing" do before do allow(manager.storage).to receive(:probed).and_return st_probed - allow_any_instance_of(Y2Storage::IssuesManager) - .to receive(:report_probing_issues).and_return(continue) + allow_any_instance_of(Y2Storage::Callbacks::YastProbe) + .to receive(:report_issues).and_return(continue) end let(:st_probed) { devicegraph_from("lvm-errors1-devicegraph.xml").to_storage_value } let(:continue) { true } it "reports the probing issues" do - expect_any_instance_of(Y2Storage::IssuesManager).to receive(:report_probing_issues) + expect_any_instance_of(Y2Storage::Callbacks::YastProbe).to receive(:report_issues) manager.probe end @@ -806,30 +806,6 @@ expect(manager.probe!).to be_nil end - context "during installation" do - before do - allow(Yast::Mode).to receive(:installation).and_return(true) - end - - it "releases software source devices before probing" do - expect(Yast::Pkg).to receive(:SourceReleaseAll) - - manager.probe! - end - end - - context "in an installed system" do - before do - allow(Yast::Mode).to receive(:installation).and_return(false) - end - - it "does not release software source devices before probing" do - expect(Yast::Pkg).to_not receive(:SourceReleaseAll) - - manager.probe! - end - end - context "and libstorage-ng fails while probing" do before do allow(manager.storage).to receive(:probe).and_raise Storage::Exception @@ -843,8 +819,8 @@ context "and there are issues during probing" do before do allow(manager.storage).to receive(:probed).and_return st_probed - allow_any_instance_of(Y2Storage::IssuesManager) - .to receive(:report_probing_issues).and_return(continue) + allow_any_instance_of(Y2Storage::Callbacks::YastProbe) + .to receive(:report_issues).and_return(continue) end let(:st_probed) { devicegraph_from("lvm-errors1-devicegraph.xml").to_storage_value } @@ -863,14 +839,14 @@ it "stores the issues" do manager.probe! - issues_manager = manager.probed.issues_manager + probing_issues = manager.probed.probing_issues - expect(issues_manager.probing_issues).to be_a(Y2Issues::List) - expect(issues_manager.probing_issues).to_not be_empty + expect(probing_issues).to be_a(Y2Issues::List) + expect(probing_issues).to_not be_empty end it "reports the probing issues" do - expect_any_instance_of(Y2Storage::IssuesManager).to receive(:report_probing_issues) + expect_any_instance_of(Y2Storage::Callbacks::YastProbe).to receive(:report_issues) manager.probe! end