Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-rear for openSUSE:Factory checked in at 2021-01-30 13:56:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-rear (Old) and /work/SRC/openSUSE:Factory/.yast2-rear.new.28504 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-rear" Sat Jan 30 13:56:27 2021 rev:7 rq:867747 version:4.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-rear/yast2-rear.changes 2021-01-18 11:34:55.257133053 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-rear.new.28504/yast2-rear.changes 2021-01-30 13:57:34.954361588 +0100 @@ -1,0 +2,7 @@ +Sat Jan 23 20:14:50 UTC 2021 - Petr Pavlu <petr.pa...@suse.com> + +- Fix quoting of values in POST_RECOVERY_SCRIPT and + BACKUP_PROG_INCLUDE (bsc#1180983). +- 4.3.0 + +------------------------------------------------------------------- @@ -5,0 +13 @@ +- 4.2.2 Old: ---- yast2-rear-4.2.2.tar.bz2 New: ---- yast2-rear-4.3.0.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-rear.spec ++++++ --- /var/tmp/diff_new_pack.nPa8Fh/_old 2021-01-30 13:57:35.418363773 +0100 +++ /var/tmp/diff_new_pack.nPa8Fh/_new 2021-01-30 13:57:35.422363791 +0100 @@ -17,7 +17,7 @@ Name: yast2-rear -Version: 4.2.2 +Version: 4.3.0 Release: 0 Summary: YaST2 - Rear - Relax and Recover License: GPL-2.0-only @@ -36,6 +36,7 @@ BuildRequires: yast2-devtools >= 4.2.2 BuildRequires: yast2-storage-ng BuildRequires: yast2-testsuite +BuildRequires: rubygem(%rb_default_ruby_abi:rspec) Requires: rear >= 1.10.0 Requires: yast2 ++++++ yast2-rear-4.2.2.tar.bz2 -> yast2-rear-4.3.0.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/.github/workflows/ci.yml new/yast2-rear-4.3.0/.github/workflows/ci.yml --- old/yast2-rear-4.2.2/.github/workflows/ci.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-rear-4.3.0/.github/workflows/ci.yml 2021-01-29 17:06:48.000000000 +0100 @@ -0,0 +1,58 @@ + +# See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions + +name: CI + +on: [push, pull_request] + +jobs: + Tests: + runs-on: ubuntu-latest + container: registry.opensuse.org/yast/head/containers/yast-ruby:latest + + steps: + + - name: Git Checkout + uses: actions/checkout@v2 + + # just for easier debugging... + - name: Inspect Installed Packages + run: rpm -qa | sort + + - name: Unit Tests + run: rake test:unit + # enable code coverage reporting + env: + COVERAGE: 1 + + # send the coverage report to coveralls.io + - name: Coveralls Report + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + Package: + runs-on: ubuntu-latest + container: registry.opensuse.org/yast/head/containers/yast-ruby:latest + + steps: + + - name: Git Checkout + uses: actions/checkout@v2 + + - name: Package Build + run: yast-ci-ruby -o package + + # downloading the Docker image takes some time so bundling several fast + # checks into one job avoids that overhead + Checks: + runs-on: ubuntu-latest + container: registry.opensuse.org/yast/head/containers/yast-ruby:latest + + steps: + + - name: Git Checkout + uses: actions/checkout@v2 + + - name: POT Check + run: rake check:pot diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/.travis.yml new/yast2-rear-4.3.0/.travis.yml --- old/yast2-rear-4.2.2/.travis.yml 2021-01-18 09:40:35.000000000 +0100 +++ new/yast2-rear-4.3.0/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,11 +0,0 @@ -sudo: required -language: bash -services: - - docker - -before_install: - - docker build -t yast-rear-image . -script: - # the "yast-travis-ruby" script is included in the base yastdevel/ruby image - # see https://github.com/yast/docker-yast-ruby/blob/master/yast-travis-ruby - - docker run -it -e TRAVIS=1 -e TRAVIS_JOB_ID="$TRAVIS_JOB_ID" yast-rear-image yast-travis-ruby diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/Dockerfile new/yast2-rear-4.3.0/Dockerfile --- old/yast2-rear-4.2.2/Dockerfile 2021-01-18 09:40:35.000000000 +0100 +++ new/yast2-rear-4.3.0/Dockerfile 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -FROM registry.opensuse.org/yast/head/containers/yast-ruby:latest -COPY . /usr/src/app - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/README.md new/yast2-rear-4.3.0/README.md --- old/yast2-rear-4.2.2/README.md 2021-01-18 09:40:35.000000000 +0100 +++ new/yast2-rear-4.3.0/README.md 2021-01-29 17:06:48.000000000 +0100 @@ -1,7 +1,10 @@ ## YaST - REAR Module -[![Travis Build](https://travis-ci.org/yast/yast-rear.svg?branch=master)](https://travis-ci.org/yast/yast-rear) -[![Jenkins Build](http://img.shields.io/jenkins/s/https/ci.opensuse.org/yast-rear-master.svg)](https://ci.opensuse.org/view/Yast/job/yast-rear-master/) +[![Workflow Status](https://github.com/yast/yast-rear/workflows/CI/badge.svg?branch=master)]( +https://github.com/yast/yast-rear/actions?query=branch%3Amaster) +[![Jenkins Status](https://ci.opensuse.org/buildStatus/icon?job=yast-yast-rear-master)]( +https://ci.opensuse.org/view/Yast/job/yast-yast-rear-master/) +[![Coverage Status](https://img.shields.io/coveralls/yast/yast-rear.svg)](https://coveralls.io/r/yast/yast-rear?branch=master) [Relax-and-Recover](http://relax-and-recover.org/) is a setup-and-forget Linux bare metal disaster recovery solution. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/package/yast2-rear.changes new/yast2-rear-4.3.0/package/yast2-rear.changes --- old/yast2-rear-4.2.2/package/yast2-rear.changes 2021-01-18 09:40:35.000000000 +0100 +++ new/yast2-rear-4.3.0/package/yast2-rear.changes 2021-01-29 17:06:48.000000000 +0100 @@ -1,8 +1,16 @@ ------------------------------------------------------------------- +Sat Jan 23 20:14:50 UTC 2021 - Petr Pavlu <petr.pa...@suse.com> + +- Fix quoting of values in POST_RECOVERY_SCRIPT and + BACKUP_PROG_INCLUDE (bsc#1180983). +- 4.3.0 + +------------------------------------------------------------------- Fri Jan 15 17:23:26 UTC 2021 - aabdal...@suse.com - Don't show a warning anymore for vfat partitions, as versions 1.18 and higher of rear support them (bsc#1180599) +- 4.2.2 ------------------------------------------------------------------- Tue Dec 31 13:59:56 UTC 2019 - Josef Reidinger <jreidin...@suse.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/package/yast2-rear.spec new/yast2-rear-4.3.0/package/yast2-rear.spec --- old/yast2-rear-4.2.2/package/yast2-rear.spec 2021-01-18 09:40:35.000000000 +0100 +++ new/yast2-rear-4.3.0/package/yast2-rear.spec 2021-01-29 17:06:48.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-rear -Version: 4.2.2 +Version: 4.3.0 Release: 0 Summary: YaST2 - Rear - Relax and Recover Group: System/YaST @@ -35,6 +35,7 @@ BuildRequires: yast2 yast2-testsuite BuildRequires: yast2-storage-ng BuildRequires: yast2-devtools >= 4.2.2 +BuildRequires: rubygem(%rb_default_ruby_abi:rspec) Requires: yast2 Requires: rear >= 1.10.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/src/include/rear/ui.rb new/yast2-rear-4.3.0/src/include/rear/ui.rb --- old/yast2-rear-4.2.2/src/include/rear/ui.rb 2021-01-18 09:40:35.000000000 +0100 +++ new/yast2-rear-4.3.0/src/include/rear/ui.rb 2021-01-29 17:06:48.000000000 +0100 @@ -50,6 +50,22 @@ 'fi' ] + # List of scripts that the module should offer to remove from POST_RECOVERY_SCRIPT. + # + # This is used to fix up a problem with older versions of yast-rear which output an incorrectly + # escaped snapper quota snippet when writing it into the ReaR configuration file. The problem + # appeared in the following versions: 3.2.0 (2017) .. 4.2.2 (2021). This logic can be removed at + # some reasonable point in the future when it is expected all configuration files have been + # likely already corrected. + POST_RECOVERY_SCRIPT_REMOVE = [ + 'if snapper --no-dbus -r $TARGET_FS_ROOT get-config | grep -q ^QGROUP.*[0-9]/[0-9] ; '\ + 'then snapper --no-dbus -r $TARGET_FS_ROOT set-config QGROUP= ;'\ + ' snapper --no-dbus -r $TARGET_FS_ROOT setup-quota && echo snapper setup-quota done'\ + ' || echo snapper setup-quota failed ; '\ + 'else echo snapper setup-quota not used ; '\ + 'fi' + ] + def initialize_rear_ui(include_target) Yast.import "UI" @@ -103,16 +119,29 @@ mountpoints.map {|e| e + "/*" } end - # helper to compare an array with a default array and returns a formatted - # list containing the items that need to be added to the array to become - # equal to the default array. - def ArrayChecker(value, default) - to_add = default - value + # Helper to compare two arrays + # + # Compare the value array with the default array. The action selects whether the default array + # defines entries that are expected in the value array and should be added if missing (:add), or + # are not desired and should be removed if present (:remove). + # + # @param value [Array<String>] current entries + # @param default [Array<String>] entries that should appear (:add) or are not desired (:remove) + # in the value array + # @param action [Symbol] operation mode (:add, :remove) + # @return [String] list describing which entries need adding (:add) or removing (:remove) + def ArrayChecker(value, default, action) + if action == :add + diff = default - value + else + raise ArgumentError, "action must be :add or :remove" if action != :remove + diff = default & value + end - unless to_add.empty? + unless diff.empty? message = "<ul><li>" + - to_add.join("</li><li>") + + diff.join("</li><li>") + "</li></ul>" end @@ -508,17 +537,20 @@ backup_options = BACKUP_OPTIONS if backup_options.empty? if RearSystemCheck.Btrfs? - msg = ArrayChecker(backup_prog_include, mountpoints) + msg = ArrayChecker(backup_prog_include, mountpoints, :add) message += _("Additional directories in the backup:") + msg if msg end - msg = ArrayChecker(required_progs, REQUIRED_PROGS) + msg = ArrayChecker(required_progs, REQUIRED_PROGS, :add) message += _("Additional programs in the rescue system:") + msg if msg - msg = ArrayChecker(copy_as_is, COPY_AS_IS) + msg = ArrayChecker(copy_as_is, COPY_AS_IS, :add) message += _("Additional files to be copied into the rescue system:") + msg if msg - msg = ArrayChecker(post_recovery_script, POST_RECOVERY_SCRIPT) + msg = ArrayChecker(post_recovery_script, POST_RECOVERY_SCRIPT_REMOVE, :remove) + message += _("Removal of malformed post recovery scripts:") + msg if msg + + msg = ArrayChecker(post_recovery_script, POST_RECOVERY_SCRIPT, :add) message += _("Additional post recovery scripts:") + msg if msg unless message.empty? @@ -534,6 +566,7 @@ backup_prog_include |= mountpoints required_progs |= REQUIRED_PROGS copy_as_is |= COPY_AS_IS + post_recovery_script -= POST_RECOVERY_SCRIPT_REMOVE post_recovery_script |= POST_RECOVERY_SCRIPT else Builtins.y2warning("User did not accept the config changes we suggested.") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/src/modules/Rear.rb new/yast2-rear-4.3.0/src/modules/Rear.rb --- old/yast2-rear-4.2.2/src/modules/Rear.rb 2021-01-18 09:40:35.000000000 +0100 +++ new/yast2-rear-4.3.0/src/modules/Rear.rb 2021-01-29 17:06:48.000000000 +0100 @@ -30,6 +30,7 @@ # Input and output routines. require "yast" require "y2storage" +require "shellwords" module Yast class RearClass < Module @@ -72,57 +73,75 @@ deep_copy(usbparts) end - + # The module distinguishes between two types of lists that are used in the ReaR configuration. + # They are called by this code as basic and quoted lists. + # * A basic list consists of as-is names. Elements of this list are not transformed in any way + # when being written to or read from the configuration file, with the exception of escaping + # spaces. + # * A quoted list consists of names that should be protected from shell processing. Elements of + # such a list are quoted when writing them in the configuration file and unquoted/unescaped + # when reading them. This is used to store scripts that are invoked by ReaR using + # 'eval "${CONFIG_VAR[@]}"' and for wildcard names that should not be expanded by the shell + # directly. # Convert List from Config File to YCP List def RearListToYCPList(rearlist) - ycplist = [] - ycplisttmp = [] - return [] if rearlist == nil - # remove brakets + # remove parentheses rearlist = Builtins.regexpsub(Convert.to_string(rearlist), "^ *\\((.*)\\) *$", "\\1") - # split string seperated by spaces into a string list, respect backslash escaped blanks - ycplisttmp = Builtins.splitstring(rearlist, " ") + # split string separated by spaces into a string list, respect backslash escaped blanks + ycplisttmp = rearlist.split(" ") + ycplist = [] buffer = "" - Builtins.foreach(ycplisttmp) do |elem| - length = Builtins.size(elem) - if Builtins.substring(elem, Ops.subtract(length, 1), 1) == "\\" - buffer = Ops.add( - Ops.add( - buffer, - Builtins.substring(elem, 0, Ops.subtract(length, 1)) - ), - " " - ) + ycplisttmp.each do |elem| + if elem[-1] == "\\" + buffer += elem[0...-1] + " " else - buffer = Ops.add(buffer, elem) - ycplist = Builtins.add(ycplist, buffer) + buffer += elem + ycplist.push(buffer) buffer = "" end end # remove empty elements - ycplist = Builtins.filter(ycplist) { |element| element != "" } + ycplist = ycplist.select { |elem| elem != "" } deep_copy(ycplist) end - # Convert YCP List to Format for Config File def YCPListToRearList(ycplist) - ycplist = deep_copy(ycplist) - escaped = [] # escape blanks in directories with a backslash - Builtins.foreach(ycplist) do |elem| - escaped = Builtins.add( - escaped, - Builtins.mergestring(Builtins.splitstring(elem, " "), "\\ ") - ) - end - Ops.add(Ops.add("(", Builtins.mergestring(escaped, " ")), ")") + escaped = ycplist.map { |elem| elem.gsub(" ", "\\ ") } + + "(" + escaped.join(" ") + ")" + end + + # Convert Quoted List from Config File to YCP List + def RearQuotedListToYCPList(rearlist) + return [] if rearlist == nil + + # remove parentheses + rearlist = Builtins.regexpsub(Convert.to_string(rearlist), "^ *\\((.*)\\) *$", "\\1") + + # split string separated by spaces into a string list, respect shell quoting + ycplist = Shellwords.split(rearlist); + + # remove empty elements + ycplist = ycplist.select { |elem| elem != "" } + + deep_copy(ycplist) + end + + # Convert YCP List to Quoted Format for Config File + def YCPListToRearQuotedList(ycplist) + # escape all commands by putting them in single quotes, instead of using Shellwords.escape + # which would escape each individual character thus making the result harder to read + escaped = ycplist.map { |elem| "'" + String.Quote(elem) + "'" } + + "(" + escaped.join(" ") + ")" end # Read rear settings from /etc/rear/local.conf @@ -160,11 +179,11 @@ backup_prog_include_tmp = SCR.Read(path(".etc.rear_conf.v.BACKUP_PROG_INCLUDE")) - @backup_prog_include = RearListToYCPList(backup_prog_include_tmp) + @backup_prog_include = RearQuotedListToYCPList(backup_prog_include_tmp) post_recovery_script_tmp = SCR.Read(path(".etc.rear_conf.v.POST_RECOVERY_SCRIPT")) - @post_recovery_script = RearListToYCPList(post_recovery_script_tmp) + @post_recovery_script = RearQuotedListToYCPList(post_recovery_script_tmp) # These two configuration parameters extend a rear system variable. # It is bash, so this is done by including the old value of that variable @@ -213,14 +232,14 @@ unless @backup_prog_include.empty? SCR.Write( path(".etc.rear_conf.v.BACKUP_PROG_INCLUDE"), - YCPListToRearList(@backup_prog_include) + YCPListToRearQuotedList(@backup_prog_include) ) end unless @post_recovery_script.empty? SCR.Write( path(".etc.rear_conf.v.POST_RECOVERY_SCRIPT"), - YCPListToRearList(@post_recovery_script) + YCPListToRearQuotedList(@post_recovery_script) ) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/test/Makefile.am new/yast2-rear-4.3.0/test/Makefile.am --- old/yast2-rear-4.2.2/test/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-rear-4.3.0/test/Makefile.am 2021-01-29 17:06:48.000000000 +0100 @@ -0,0 +1,7 @@ +TESTS = \ + rear_test.rb + +TEST_EXTENSIONS = .rb +RB_LOG_COMPILER = rspec +VERBOSE = 1 +EXTRA_DIST = $(TESTS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/test/rear_test.rb new/yast2-rear-4.3.0/test/rear_test.rb --- old/yast2-rear-4.2.2/test/rear_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-rear-4.3.0/test/rear_test.rb 2021-01-29 17:06:48.000000000 +0100 @@ -0,0 +1,119 @@ +#!/usr/bin/env rspec + +require_relative "./test_helper" + +Yast.import "Rear" + +describe Yast::Rear do + describe "#RearListToYCPList" do + it "correctly splits and parses a given input list" do + ycplist = subject.RearListToYCPList("()") + expect(ycplist).to eq([]) + + ycplist = subject.RearListToYCPList("(a)") + expect(ycplist).to eq(["a"]) + + ycplist = subject.RearListToYCPList("(a b c)") + expect(ycplist).to eq(["a", "b", "c"]) + + ycplist = subject.RearListToYCPList("(a\\ b c)") + expect(ycplist).to eq(["a b", "c"]) + + ycplist = subject.RearListToYCPList("(a\\ \\ \\ b c)") + expect(ycplist).to eq(["a b", "c"]) + + ycplist = subject.RearListToYCPList("(a* b)") + expect(ycplist).to eq(["a*", "b"]) + + ycplist = subject.RearListToYCPList("('a' b)") + expect(ycplist).to eq(["'a'", "b"]) + end + end + + describe "#YCPListToRearList" do + it "correctly transforms a given list for output" do + rearlist = subject.YCPListToRearList([]) + expect(rearlist).to eq(("()")) + + rearlist = subject.YCPListToRearList(["a"]) + expect(rearlist).to eq("(a)") + + rearlist = subject.YCPListToRearList(["a", "b", "c"]) + expect(rearlist).to eq("(a b c)") + + rearlist = subject.YCPListToRearList(["a b", "c"]) + expect(rearlist).to eq("(a\\ b c)") + + rearlist = subject.YCPListToRearList(["a b", "c"]) + expect(rearlist).to eq("(a\\ \\ \\ b c)") + + rearlist = subject.YCPListToRearList(["a*", "b"]) + expect(rearlist).to eq("(a* b)") + + rearlist = subject.YCPListToRearList(["'a'", "b"]) + expect(rearlist).to eq("('a' b)") + end + end + + describe "#RearQuotedListToYCPList" do + it "correctly splits and parses a given input list" do + ycplist = subject.RearQuotedListToYCPList("()") + expect(ycplist).to eq([]) + + ycplist = subject.RearQuotedListToYCPList("(a)") + expect(ycplist).to eq(["a"]) + + ycplist = subject.RearQuotedListToYCPList("(a b c)") + expect(ycplist).to eq(["a", "b", "c"]) + + ycplist = subject.RearQuotedListToYCPList("(a\\ b c)") + expect(ycplist).to eq(["a b", "c"]) + + ycplist = subject.RearQuotedListToYCPList("(a\\ \\ \\ b c)") + expect(ycplist).to eq(["a b", "c"]) + + ycplist = subject.RearQuotedListToYCPList("(a* b)") + expect(ycplist).to eq(["a*", "b"]) + + ycplist = subject.RearQuotedListToYCPList("('a' b)") + expect(ycplist).to eq(["a", "b"]) + + ycplist = subject.RearQuotedListToYCPList("('a'\\''b' c)") + expect(ycplist).to eq(["a'b", "c"]) + + ycplist = subject.RearQuotedListToYCPList("('' a)") + expect(ycplist).to eq(["a"]) + end + end + + describe "#YCPListToRearQuotedList" do + it "correctly transforms a given list for output" do + rearlist = subject.YCPListToRearQuotedList([]) + expect(rearlist).to eq("()") + + rearlist = subject.YCPListToRearQuotedList(["a"]) + expect(rearlist).to eq("('a')") + + rearlist = subject.YCPListToRearQuotedList(["a", "b", "c"]) + expect(rearlist).to eq("('a' 'b' 'c')") + + rearlist = subject.YCPListToRearQuotedList(["a b", "c"]) + expect(rearlist).to eq("('a b' 'c')") + + rearlist = subject.YCPListToRearQuotedList(["a b", "c"]) + expect(rearlist).to eq("('a b' 'c')") + + rearlist = subject.YCPListToRearQuotedList(["a*", "b"]) + expect(rearlist).to eq("('a*' 'b')") + + rearlist = subject.YCPListToRearQuotedList(["a", "b"]) + expect(rearlist).to eq("('a' 'b')") + + rearlist = subject.YCPListToRearQuotedList(["a'b", "c"]) + expect(rearlist).to eq("('a'\\''b' 'c')") + + rearlist = subject.YCPListToRearQuotedList([""]) + expect(rearlist).to eq("('')") + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-rear-4.2.2/test/test_helper.rb new/yast2-rear-4.3.0/test/test_helper.rb --- old/yast2-rear-4.2.2/test/test_helper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-rear-4.3.0/test/test_helper.rb 2021-01-29 17:06:48.000000000 +0100 @@ -0,0 +1,42 @@ +ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) + +require "yast" +require "yast/rspec" + +# stable testing in localized env +ENV["LC_ALL"] = "en_US.UTF-8" + +RSpec.configure do |config| + config.mock_with :rspec do |mocks| + # make sure we mock only the existing methods + mocks.verify_partial_doubles = true + end +end + +if ENV["COVERAGE"] + require "simplecov" + SimpleCov.start do + add_filter "/test/" + end + + src_location = File.expand_path("../src", __dir__) + # track all ruby files under src + SimpleCov.track_files("#{src_location}/**/*.rb") + + # additionally use the LCOV format for on-line code coverage reporting at CI + if ENV["CI"] || ENV["COVERAGE_LCOV"] + require "simplecov-lcov" + + SimpleCov::Formatter::LcovFormatter.config do |c| + c.report_with_single_file = true + # this is the default Coveralls GitHub Action location + # https://github.com/marketplace/actions/coveralls-github-action + c.single_report_path = "coverage/lcov.info" + end + + SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::LcovFormatter + ] + end +end