Skip to content

Commit

Permalink
Merge 73e60c1 into 682a0fc
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Sep 1, 2016
2 parents 682a0fc + 73e60c1 commit db04600
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -5,10 +5,11 @@ before_install:
# disable rvm, use system Ruby
- rvm reset
- wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh
- sh ./travis_setup.sh -p "yast2-devtools yast2-testsuite yast2 yast2-pkg-bindings yast2-country-data yast2-storage" -g rspec:3.3.0
- sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 yast2-pkg-bindings yast2-country-data yast2-storage" -g "rspec:3.3.0 yast-rake simplecov coveralls"
script:
- make -f Makefile.cvs
- make
- sudo make install
- make check
- COVERAGE=1 rake test:unit

1 change: 1 addition & 0 deletions README.md
Expand Up @@ -2,4 +2,5 @@

[![Travis Build](https://travis-ci.org/yast/yast-packager.svg?branch=master)](https://travis-ci.org/yast/yast-packager)
[![Jenkins Build](http://img.shields.io/jenkins/s/https/ci.opensuse.org/yast-packager-master.svg)](https://ci.opensuse.org/view/Yast/job/yast-packager-master/)
[![Coverage Status](https://coveralls.io/repos/yast/yast-packager/badge.png)](https://coveralls.io/r/yast/yast-packager)

3 changes: 2 additions & 1 deletion test/Makefile.am
@@ -1,11 +1,12 @@
TESTS = \
addon_product_test.rb \
inst_url_test.rb \
product_patterns_test.rb \
package_installation_test.rb \
package_slide_show_test.rb \
packages_test.rb \
pkg_finish_test.rb \
product_license_test.rb \
product_patterns_test.rb \
source_dialogs_test.rb \
space_calculation_test.rb

Expand Down
54 changes: 31 additions & 23 deletions test/packages_test.rb
Expand Up @@ -33,13 +33,6 @@ def load_zypp(file_name)
YAML.load_file(file_name)
end

def set_root_path(directory)
root = File.join(DATA_PATH, directory)
check_version = false
handle = Yast::WFM.SCROpen("chroot=#{root}:scr", check_version)
Yast::WFM.SCRSetDefault(handle)
end

PRODUCTS_FROM_ZYPP = load_zypp('products.yml').freeze

describe Yast::Packages do
Expand All @@ -53,26 +46,38 @@ def set_root_path(directory)
allow(Yast::Product).to receive(:Product).and_return nil
end

after(:each) do
# set_root_path is always called and it opens a SCR instance
# that needs to be closed
Yast::WFM.SCRClose(Yast::WFM.SCRGetDefault)
end

context "when biosdevname behavior explicitly defined on the Kenel command line" do
it "returns biosdevname within the list of required packages" do
set_root_path("cmdline-biosdevname_1")
expect(Yast::Packages.kernelCmdLinePackages.include?("biosdevname")).to eq(true)
context "when biosdevname=1" do
around do |example|
root = File.join(DATA_PATH, "cmdline-biosdevname_1")
change_scr_root(root, &example)
end

it "returns biosdevname within the list of required packages" do
expect(Yast::Packages.kernelCmdLinePackages.include?("biosdevname")).to eq(true)
end
end

it "does not return biosdevname within the list of required packages" do
set_root_path("cmdline-biosdevname_0")
expect(Yast::Packages.kernelCmdLinePackages.include?("biosdevname")).to eq(false)
context "when biosdevname=0" do
around do |example|
root = File.join(DATA_PATH, "cmdline-biosdevname_0")
change_scr_root(root, &example)
end

it "does not return biosdevname within the list of required packages" do
expect(Yast::Packages.kernelCmdLinePackages.include?("biosdevname")).to eq(false)
end
end

it "does not return biosdevname within the list of required packages then value is invalid" do
set_root_path("cmdline-biosdevname_10")
expect(Yast::Packages.kernelCmdLinePackages.include?("biosdevname")).to eq(false)
context "when biosdevname=10 (invalid)" do
around do |example|
root = File.join(DATA_PATH, "cmdline-biosdevname_10")
change_scr_root(root, &example)
end

it "does not return biosdevname within the list of required packages then value is invalid" do
expect(Yast::Packages.kernelCmdLinePackages.include?("biosdevname")).to eq(false)
end
end
end

Expand All @@ -84,7 +89,10 @@ def set_root_path(directory)
end

context "when biosdevname behavior not defined on the Kernel command line" do
before { set_root_path("cmdline-biosdevname_nil") }
around do |example|
root = File.join(DATA_PATH, "cmdline-biosdevname_nil")
change_scr_root(root, &example)
end

context "and running on a Dell system" do
it "returns biosdevname within the list of packages" do
Expand Down
9 changes: 5 additions & 4 deletions test/product_license_test.rb
Expand Up @@ -111,10 +111,11 @@
# :halt case
allow(Yast::ProductLicense).to receive(:TimedOKCancel).and_return(true)

expect(Yast::ProductLicense.HandleLicenseDialogRet(licenses_ref, "base_prod", "abort")).to eq(:abort)
expect(Yast::ProductLicense.HandleLicenseDialogRet(licenses_ref, "base_prod", "continue")).to eq(:accepted)
expect(Yast::ProductLicense.HandleLicenseDialogRet(licenses_ref, "base_prod", "halt")).to eq(:halt)
expect(Yast::ProductLicense.HandleLicenseDialogRet(licenses_ref, "base_prod", "unknown")).to eq(:abort)
base_prod = false
expect(Yast::ProductLicense.HandleLicenseDialogRet(licenses_ref, base_prod, "abort")).to eq(:abort)
expect(Yast::ProductLicense.HandleLicenseDialogRet(licenses_ref, base_prod, "continue")).to eq(:accepted)
expect(Yast::ProductLicense.HandleLicenseDialogRet(licenses_ref, base_prod, "halt")).to eq(:halt)
expect(Yast::ProductLicense.HandleLicenseDialogRet(licenses_ref, base_prod, "unknown")).to eq(:abort)
end
end
end
Expand Down
31 changes: 26 additions & 5 deletions test/test_helper.rb
Expand Up @@ -2,11 +2,6 @@
y2dirs = ENV.fetch("Y2DIR", "").split(":")
ENV["Y2DIR"] = y2dirs.unshift(srcdir).join(":")

if ENV["COVERAGE"]
require "simplecov"
SimpleCov.start
end

require "yast"
require "yast/rspec"
require "pathname"
Expand All @@ -18,3 +13,29 @@
config.extend Yast::I18n # available in context/describe
config.include Yast::I18n # available in it/let/before/...
end

if ENV["COVERAGE"]
require "simplecov"
SimpleCov.start do
add_filter "/test/"
end

# For coverage we need to load all ruby files
# Note that clients/ are excluded because they run too eagerly by design
fs = Dir["#{srcdir}/**/*.rb"]
fs.delete_if { |f| f.start_with? "#{srcdir}/clients/" }
# HACK: this would BuildRequire yast2-slp so defer this
fs.delete_if { |f| f.end_with? "/SourceManagerSLP.rb" }
fs.each do |f|
require_relative f
end

# use coveralls for on-line code coverage reporting at Travis CI
if ENV["TRAVIS"]
require "coveralls"
SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
end
end

0 comments on commit db04600

Please sign in to comment.