From: =?utf-8?b?SsOpcsOpbXkgQm9iYmlv?= <lunar@debian.org>
Date: Mon, 25 Feb 2019 08:45:50 -0300
Subject: Use system library paths when running under autopkgtest

Forwarded: not-needed
Last-Update: 2015-09-09
---
 test/_backport_guards_test.rb | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/_backport_guards_test.rb b/test/_backport_guards_test.rb
index e62d377..c7b6550 100644
--- a/test/_backport_guards_test.rb
+++ b/test/_backport_guards_test.rb
@@ -83,6 +83,14 @@ class AAA_TestBackportGuards < Test::Unit::TestCase
     delta unless delta.empty?
   end
 
+  def lib_path(path)
+    unless ENV['ADTTMP'].nil? # running under autopkgtest
+      "/usr/lib/ruby/vendor_ruby/#{path}"
+    else
+      File.expand_path("../../lib/#{path}", __FILE__)
+    end
+  end
+
   # Order super important!
   def test__1_abbrev_can_be_required_before_backports
     assert require('abbrev')
@@ -110,7 +118,7 @@ class AAA_TestBackportGuards < Test::Unit::TestCase
   end
 
   def test_setlib_load_correctly_after_requiring_backports
-    path = File.expand_path("../../lib/backports/1.9.2/stdlib/matrix.rb", __FILE__)
+    path = lib_path('backports/1.9.2/stdlib/matrix.rb')
     assert_equal false,  $LOADED_FEATURES.include?(path)
     assert_equal true,  require('matrix')
     assert_equal true,  $bogus.include?("matrix")
@@ -120,7 +128,7 @@ class AAA_TestBackportGuards < Test::Unit::TestCase
 
   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__)
+    path = lib_path('backports/2.0.0/stdlib/abbrev.rb')
     assert_equal true,  $LOADED_FEATURES.include?(path)
     assert_equal false, require('abbrev')
   end
@@ -131,7 +139,7 @@ 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__)
+    path = lib_path('backports/2.0.0/stdlib/fake_stdlib_lib.rb')
     assert_equal false, $LOADED_FEATURES.include?(path)
     assert_equal true,  require('fake_stdlib_lib')
     assert_equal true,  $LOADED_FEATURES.include?(path)
