[SCM] ci-tooling packaging branch, master, updated. 31603f49bb1a2b54f9555c8043870460d1c5ec9b
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Mon Oct 5 12:21:33 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=4286908
The following commit has been merged in the master branch:
commit 42869089ccdb3a58c5da0195520f9941bda05104
Author: Harald Sitter <sitter at kde.org>
Date: Mon Oct 5 14:17:23 2015 +0200
add a blackbox test for builder
---
kci/builder.rb | 34 ++++++++----
.../test_run}/packaging/debian/changelog | 0
.../test_run}/packaging/debian/control | 0
.../test_run}/packaging/debian/rules | 0
.../test_run}/packaging/debian/source/format | 0
.../test_run}/packaging/debian/source/options | 0
test/test_kci_builder.rb | 60 ++++++++++++++++++++++
7 files changed, 83 insertions(+), 11 deletions(-)
diff --git a/kci/builder.rb b/kci/builder.rb
index 25c3f54..f3de3f0 100755
--- a/kci/builder.rb
+++ b/kci/builder.rb
@@ -48,23 +48,30 @@ Project = Struct.new(:series, :stability, :name)
$stdout = $stderr
class Builder
+ class CoverageError < Exception; end
+
+ def self.testing=(testing)
+ @testing = testing
+ end
+
+ def self.testing
+ @testing ||= false
+ end
+
def self.run
# get basename, distro series, unstable/stable
components = ARGV.fetch(0).split('_')
unless components.size == 3
abort 'Did not get a valid project identifier via ARGV0'
end
- project = Project.new(components[0], components[1], components[2])
+ project = Project.new(components.fetch(0),
+ components.fetch(1),
+ components.fetch(2))
@ppa = "@ppa:kubuntu-ci/#{project.stability}"
- File.open('/etc/apt/apt.conf.d/apt-cacher', 'w') do |file|
- file.puts('Acquire::http { Proxy "http://10.0.3.1:3142"; };')
- end
-
# PWD
- abort 'Could not change dir to ARGV1' unless Dir.chdir(ARGV[1])
-
+ abort 'Could not change dir to ARGV1' unless Dir.chdir(ARGV.fetch(1))
@workspace_path = ARGV.fetch(1)
# Workaround for docker not having suidmaps. We run as root in the docker
@@ -75,10 +82,7 @@ class Builder
# stuff owned by others.
at_exit do
FileUtils.chown_R('jenkins', 'jenkins', @workspace_path, verbose: true)
- end
-
- # install deps
- `apt-get install -y xz-utils dpkg-dev ruby dput debhelper pkg-kde-tools devscripts python-launchpadlib ubuntu-dev-tools git`
+ end unless testing
# version
changelog = Changelog.new('packaging')
@@ -199,6 +203,8 @@ class Builder
abort e
end
+ fail CoverageError, 'Testing disabled after source building' if testing
+
# Sign
Dir.chdir('build/') do
changes = Dir.glob('*.changes')
@@ -522,5 +528,11 @@ class Builder
end
if __FILE__ == $PROGRAM_NAME
+ File.open('/etc/apt/apt.conf.d/apt-cacher', 'w') do |file|
+ file.puts('Acquire::http { Proxy "http://10.0.3.1:3142"; };')
+ end
+
+ `apt-get install -y xz-utils dpkg-dev ruby dput debhelper pkg-kde-tools devscripts python-launchpadlib ubuntu-dev-tools git`
+
Builder.run
end
diff --git a/test/data/test_ci_build_source/test_symbols_keep/packaging/debian/changelog b/test/data/test_kci_builder/test_run/packaging/debian/changelog
similarity index 100%
copy from test/data/test_ci_build_source/test_symbols_keep/packaging/debian/changelog
copy to test/data/test_kci_builder/test_run/packaging/debian/changelog
diff --git a/test/data/test_ci_build_source/test_empty_install/packaging/debian/control b/test/data/test_kci_builder/test_run/packaging/debian/control
similarity index 100%
copy from test/data/test_ci_build_source/test_empty_install/packaging/debian/control
copy to test/data/test_kci_builder/test_run/packaging/debian/control
diff --git a/test/data/test_ci_build_source/test_symbols_keep/packaging/debian/rules b/test/data/test_kci_builder/test_run/packaging/debian/rules
similarity index 100%
copy from test/data/test_ci_build_source/test_symbols_keep/packaging/debian/rules
copy to test/data/test_kci_builder/test_run/packaging/debian/rules
diff --git a/test/data/test_ci_build_source/test_empty_install/packaging/debian/source/format b/test/data/test_kci_builder/test_run/packaging/debian/source/format
similarity index 100%
copy from test/data/test_ci_build_source/test_empty_install/packaging/debian/source/format
copy to test/data/test_kci_builder/test_run/packaging/debian/source/format
diff --git a/test/data/test_ci_build_source/test_symbols_keep/packaging/debian/source/options b/test/data/test_kci_builder/test_run/packaging/debian/source/options
similarity index 100%
copy from test/data/test_ci_build_source/test_symbols_keep/packaging/debian/source/options
copy to test/data/test_kci_builder/test_run/packaging/debian/source/options
diff --git a/test/test_kci_builder.rb b/test/test_kci_builder.rb
new file mode 100644
index 0000000..6e200d2
--- /dev/null
+++ b/test/test_kci_builder.rb
@@ -0,0 +1,60 @@
+require_relative 'lib/testcase'
+
+require_relative '../kci/builder.rb'
+
+class KCIBuilderTest < TestCase
+ REF_TIME = '20150717.1756'
+
+ def setup
+ ARGV.clear
+ Builder.testing = true
+ begin
+ FileUtils.cp_r(Dir.glob("#{data}/*"), Dir.pwd, verbose: true)
+ rescue RuntimeError
+ end
+ alias_time
+ end
+
+ def teardown
+ unalias_time
+ Builder.testing = false
+ end
+
+ def alias_time
+ CI::BuildVersion.send(:alias_method, :__time_orig, :time)
+ CI::BuildVersion.send(:define_method, :time) { REF_TIME }
+ @time_aliased = true
+ end
+
+ def unalias_time
+ return unless @time_aliased
+ CI::BuildVersion.send(:undef_method, :time)
+ CI::BuildVersion.send(:alias_method, :time, :__time_orig)
+ @time_aliased = false
+ end
+
+ def test_run
+ ARGV << 'wily_unstable_extra-cmake-modules'
+ ARGV << Dir.pwd
+ # Expect raise as not the entire thing is covered.
+ assert_raise Builder::CoverageError do
+ Builder.run
+ end
+ # Verify source
+ assert(Dir.exist?('build'))
+ Dir.chdir('build')
+ content = Dir.glob('*')
+ assert_include(content,
+ 'hello_2.10+git20150717.1756+15.04-0_source.changes')
+ assert_include(content, 'hello_2.10+git20150717.1756+15.04-0.dsc')
+ assert_include(content, 'hello_2.10+git20150717.1756+15.04-0.tar.gz')
+ assert_include(content, 'source')
+ end
+
+ def test_bad_project
+ ARGV << 'wily_extra-cmake-modules' # only two parts
+ assert_raise SystemExit do
+ Builder.run
+ end
+ end
+end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list