Skip to content

Commit

Permalink
use global test helper that allows coveralls stats
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jan 29, 2015
1 parent b5680ee commit 53d87e1
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 49 deletions.
7 changes: 1 addition & 6 deletions library/general/test/test_helper.rb
@@ -1,6 +1 @@
top_srcdir = File.expand_path("../../../..", __FILE__)
inc_dirs = Dir.glob("#{top_srcdir}/library/*/src")
ENV["Y2DIR"] = inc_dirs.join(":")

require "yast"
require "yast/rspec"
require_relative "../../../test/test_helper.rb"
8 changes: 1 addition & 7 deletions library/network/test/load_ipv6_cfg_test.rb
@@ -1,10 +1,4 @@
#!/usr/bin/env rspec

top_srcdir = File.expand_path("../../../..", __FILE__)
inc_dirs = Dir.glob("#{top_srcdir}/library/*/src")
ENV["Y2DIR"] = inc_dirs.join(":")

require "yast"
require_relative "test_helper"

Yast.import "NetworkInterfaces"

Expand Down
8 changes: 1 addition & 7 deletions library/network/test/network_interfaces_helpers_test.rb
@@ -1,10 +1,4 @@
#!/usr/bin/env rspec

top_srcdir = File.expand_path("../../../..", __FILE__)
inc_dirs = Dir.glob("#{top_srcdir}/library/*/src")
ENV["Y2DIR"] = inc_dirs.join(":")

require "yast"
require_relative "test_helper"

Yast.import("NetworkInterfaces")

Expand Down
8 changes: 1 addition & 7 deletions library/network/test/susefirewall_services_test.rb
@@ -1,10 +1,4 @@
#!/usr/bin/env rspec

top_srcdir = File.expand_path("../../../..", __FILE__)
inc_dirs = Dir.glob("#{top_srcdir}/library/*/src")
ENV["Y2DIR"] = inc_dirs.join(":")

require "yast"
require_relative "test_helper"

Yast.import "SuSEFirewallServices"
Yast.import "SCR"
Expand Down
1 change: 1 addition & 0 deletions library/network/test/test_helper.rb
@@ -0,0 +1 @@
require_relative "../../../test/test_helper.rb"
7 changes: 1 addition & 6 deletions library/packages/test/test_helper.rb
@@ -1,6 +1 @@
top_srcdir = File.expand_path("../../../..", __FILE__)
inc_dirs = Dir.glob("#{top_srcdir}/library/*/src")
ENV["Y2DIR"] = inc_dirs.join(":")

require "yast"
require "yast/rspec"
require_relative "../../../test/test_helper.rb"
6 changes: 1 addition & 5 deletions library/runlevel/test/test_helper.rb
@@ -1,8 +1,4 @@
#!/usr/bin/env rspec

# We need the stubs used for SystemdService tests
require_relative "../../systemd/test/test_helper"

ENV["Y2DIR"] = File.expand_path("../../src", __FILE__)

require "yast"
require_relative "../../../test_helper.rb"
7 changes: 1 addition & 6 deletions library/system/test/test_helper.rb
@@ -1,6 +1 @@
top_srcdir = File.expand_path("../../../..", __FILE__)
inc_dirs = Dir.glob("#{top_srcdir}/library/*/src")
ENV["Y2DIR"] = inc_dirs.join(":")

require "yast"
require "yast/rspec"
require_relative "../../../test/test_helper.rb"
6 changes: 1 addition & 5 deletions library/systemd/test/test_helper.rb
@@ -1,8 +1,4 @@
require "rspec"

ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) unless ENV["Y2DIR"]

require "yast"
require_relative "../../../test/test_helper.rb"

require "yast2/systemd_unit"

Expand Down
21 changes: 21 additions & 0 deletions test/test_helper.rb
@@ -0,0 +1,21 @@
root_location = File.expand_path("../../", __FILE__)
inc_dirs = Dir.glob("#{root_location}/library/*/src")
ENV["Y2DIR"] = inc_dirs.join(":")

require "yast"
require "yast/rspec"

if ENV["COVERAGE"]
require "simplecov"
SimpleCov.start
# for coverage we need to load all ruby files
Dir["#{root_location}/library/*/src/{module,lib}/**/*.rb"].each { |f| require_relative f }
# use coveralls for on-line code coverage reporting at Travis CI
if ENV["TRAVIS"]
require "coveralls"
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
end
end

0 comments on commit 53d87e1

Please sign in to comment.