Commit feccaf58 authored by Jérémy Bobbio's avatar Jérémy Bobbio

Add support for autopkgtest

parent b22b105a
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Bobbio?= <lunar@debian.org>
Date: Fri, 20 Sep 2013 11:02:51 +0200
Subject: Allow the test suite to work against the installed library
---
test/_backport_guards_test.rb | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/test/_backport_guards_test.rb b/test/_backport_guards_test.rb
index e8575de..ecf3817 100644
--- a/test/_backport_guards_test.rb
+++ b/test/_backport_guards_test.rb
@@ -101,19 +101,27 @@ class AAA_TestBackportGuards < Test::Unit::TestCase
end
end
+ def assert_loaded(path, loaded = true)
+ assert_equal loaded, $LOADED_FEATURES.collect { |loaded| loaded.end_with?(path) }.any?
+ end
+
+ def assert_not_loaded(path)
+ assert_loaded(path, false)
+ end
+
def test_setlib_load_correctly_after_requiring_backports
- path = File.expand_path("../../lib/backports/1.9.2/stdlib/matrix.rb", __FILE__)
- assert_equal false, $LOADED_FEATURES.include?(path)
+ path = 'backports/1.9.2/stdlib/matrix.rb'
+ assert_not_loaded path
assert_equal true, require('matrix')
assert_equal true, $bogus.include?("matrix")
- assert_equal true, $LOADED_FEATURES.include?(path)
+ assert_loaded path
assert_equal false, require('matrix')
end
def test_setlib_load_correctly_before_requiring_backports_test
assert_equal true, $bogus.include?("abbrev")
- path = File.expand_path("../../lib/backports/2.0.0/stdlib/abbrev.rb", __FILE__)
- assert_equal true, $LOADED_FEATURES.include?(path)
+ path = 'backports/2.0.0/stdlib/abbrev.rb'
+ assert_loaded path
assert_equal false, require('abbrev')
end
@@ -123,10 +131,10 @@ class AAA_TestBackportGuards < Test::Unit::TestCase
end
def test_load_correctly_new_libraries_test
- path = File.expand_path("../../lib/backports/2.0.0/stdlib/fake_stdlib_lib.rb", __FILE__)
- assert_equal false, $LOADED_FEATURES.include?(path)
+ path = 'backports/2.0.0/stdlib/fake_stdlib_lib.rb'
+ assert_not_loaded path
assert_equal true, require('fake_stdlib_lib')
- assert_equal true, $LOADED_FEATURES.include?(path)
+ assert_loaded path
assert_equal false, require('fake_stdlib_lib')
end
0001-Allow-the-test-suite-to-work-against-the-installed-l.patch
Tests: gem2deb
Depends: gem2deb rake
#!/usr/bin/ruby
require 'gem2deb/metadata'
require 'gem2deb/dh_ruby'
require 'tmpdir'
require 'fileutils'
class Tester < Gem2Deb::DhRuby
def run
run_tests
end
end
unless ENV['ADTTMP']
$stderr.puts 'ADTTMP is not set. Exiting'
exit 1
end
dest = ENV['ADTTMP']
unless Dir.entries(dest) == ['.', '..']
$stderr.puts 'ADTTMP is not empty. Exiting'
exit 1
end
# Copy test files
metadata = Gem2Deb::Metadata.new('.')
metadata.test_files.each do |path|
next if File.directory?(path)
FileUtils.mkdir_p File.join(dest, File.dirname(path))
FileUtils.install path, File.join(dest, path)
end
# Copy Rakefile if there's one
# XXX: not sure if we need that
FileUtils.cp 'Rakefile', dest if File.exists?('Rakefile')
# Dump gemspecs in static form (because upstream gemspec might use Git or
# other tools)
Dir.glob('*.gemspec').each do |path|
spec = Gem::Specification.load(path)
File.open(File.join(dest, path), 'w') { |f| f.write(spec.to_ruby) }
end
# Copy Debian directory
FileUtils.cp_r 'debian', dest
# Copy metadata for DhRuby
FileUtils.cp 'metadata.yml', dest
# Run the tests
Dir.chdir(dest) do
Tester.new.run
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment