Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/SLE-15-SP4' into huha-show-pro…
Browse files Browse the repository at this point in the history
…duct-master
  • Loading branch information
shundhammer committed May 4, 2022
2 parents 0357c81 + 86f8539 commit 7ff4d3b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
20 changes: 20 additions & 0 deletions library/packages/test/slide_show_test.rb
Expand Up @@ -6,6 +6,26 @@
Yast.import "Slides"
Yast.import "UI"

# Avoid testing product_name() and the methods that are using it:
# This will break because we needed to suppress
#
# require "y2packager/product_spec"
#
# by overloading Kernel::require in ./test_helper.rb to avoid a cyclic
# dependency between this package and yast2-packager.
#
# It will work when running the unit tests locally, but it will break in an
# autobuild environment ("rake osc:build", "rake osc:sr") which is called in
# Jenkins because unlike any real-life system using YaST, an AutoBuild
# environment will NOT install yast2-packager anyway to satisfy other
# requirements. So this problem is hard to spot.
#
# It might be possible to force it to work with some heavy monkey-patching and
# instance_double, but for the extent of useful testing that it might bring,
# this is simply not worthwhile.
#
# 2022-05-04 shundhammer
#
describe "Yast::SlideShow" do
before(:each) do
Yast.y2milestone "--------- Running test ---------"
Expand Down
26 changes: 26 additions & 0 deletions library/packages/test/test_helper.rb
Expand Up @@ -2,3 +2,29 @@
require "pathname"

PACKAGES_FIXTURES_PATH = Pathname.new(File.dirname(__FILE__)).join("data")

LIBS_TO_SKIP = [
"y2packager/product_spec" # used in SlideShow.rb
].freeze

# Hack to avoid to require some files. Stolen from
# https://github.com/yast/yast-storage-ng/blob/master/test/spec_helper.rb#L32-L50
#
# This is here to avoid a cyclic dependency with yast2-packager at build time.
# yast2.spec does build-require yast2-packager, so the (Ruby) require for files
# defined by that package must be avoided.
#
# Of course that means that tests might need to use instance() or
# instance_double() to make the missing classes and methods from those
# libraries available.
#
# Notice that the problem might be hidden for locally running the unit tests,
# but not when calling them in an Autobuild environment (e.g. "rake osc:build"
# or "rake osc:sr").
module Kernel
alias_method :old_require, :require

def require(path)
old_require(path) unless LIBS_TO_SKIP.include?(path)
end
end
10 changes: 10 additions & 0 deletions package/yast2.spec
Expand Up @@ -64,6 +64,16 @@ BuildRequires: yast2-ycp-ui-bindings >= 4.3.3
BuildRequires: cpio
BuildRequires: rpm

# Intentionally NOT requiring or build-requiring yast2-packager
# to avoid a cyclic dependency.
#
# For the BuildRequires, see test_helper.rb and slide_show_test.rb
# in library/packages/test/ .
#
# For the runtime Requires, it can safely be assumed that every system that
# does any package installation has yast2-packager from the dependencies of the
# client module that does that.

# for ag_tty (/bin/stty)
# for /usr/bin/md5sum
Requires: coreutils
Expand Down

0 comments on commit 7ff4d3b

Please sign in to comment.