[SCM] ci-tooling packaging branch, master, updated. 6c134059d1383fa6f158ca5a6e5cc0d338d67aeb
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Fri Nov 27 12:20:18 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=50f45b6
The following commit has been merged in the master branch:
commit 50f45b617e847ddd758ad0d459ee924856f4d649
Author: Harald Sitter <sitter at kde.org>
Date: Fri Nov 27 12:26:01 2015 +0100
introduce a new testcase feature to require binaries
binaries that are not found but required will cause a test omission
this can be used for the entire class by using
class A < TestCase; required_binaries 'bin1', 'bin2'; end
which is evaluated at priority_setup for each test.
or by simply calling asserting this during the test itself
def test_a; require_binaries('bin1', 'bin2'); end
which is evaluated during the test, as to allow omitting one test only.
both also accept arrays
---
test/lib/testcase.rb | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/test/lib/testcase.rb b/test/lib/testcase.rb
index cff05ff..112e244 100644
--- a/test/lib/testcase.rb
+++ b/test/lib/testcase.rb
@@ -11,6 +11,11 @@ class TestCase < Test::Unit::TestCase
class << self
attr_accessor :file
+ # attr_accessor :required_binaries
+ def required_binaries(*args)
+ @required_binaries ||= []
+ @required_binaries += args.flatten
+ end
end
def self.autodetect_inherited_file
@@ -28,6 +33,16 @@ class TestCase < Test::Unit::TestCase
subclass.autodetect_inherited_file unless @file
end
+ # Automatically issues omit() if binaries required for a test are not present
+ # @param binaries [Array<String>] binaries to check for (can be full path)
+ def require_binaries(*binaries)
+ binaries.flatten.each do |bin|
+ p bin
+ next if system("type #{bin} > /dev/null 2>&1")
+ omit("#{self.class} requires #{bin} but #{bin} is not in $PATH")
+ end
+ end
+
def assert_is_a(obj, expected)
actual = obj.class.ancestors | obj.class.included_modules
diff = AssertionMessage.delayed_diff(expected, actual)
@@ -47,6 +62,7 @@ EOT
@previous_pwd = Dir.pwd
@tmpdir = Dir.mktmpdir(self.class.to_s.gsub(':', '_'))
Dir.chdir(@tmpdir)
+ require_binaries(self.class.required_binaries)
end
def priority_teardown
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list