[Libguestfs] [PATCH 1/3] ruby: Fix tests for out-of-tree build, simplify test scripts

Hilko Bengen bengen at hilluzination.de
Mon Jan 13 12:07:11 UTC 2014


---
 configure.ac                   |  1 +
 ruby/run-ruby-tests            | 27 ---------------------------
 ruby/run-ruby-tests.in         | 27 +++++++++++++++++++++++++++
 ruby/tests/tc_010_load.rb      |  2 --
 ruby/tests/tc_021_close.rb     |  2 --
 ruby/tests/tc_120_rlenvalue.rb |  4 +---
 ruby/tests/tc_200_write.rb     |  2 --
 ruby/tests/tc_210_setvalue.rb  |  2 --
 run.in                         |  4 ++--
 9 files changed, 31 insertions(+), 40 deletions(-)
 delete mode 100755 ruby/run-ruby-tests
 create mode 100755 ruby/run-ruby-tests.in

diff --git a/configure.ac b/configure.ac
index 4066ca5..6785037 100644
--- a/configure.ac
+++ b/configure.ac
@@ -564,6 +564,7 @@ AC_CONFIG_FILES([Makefile
                  sh/Makefile
                  xml/Makefile])
 AC_CONFIG_FILES([python/run-python-tests], [chmod +x python/run-python-tests])
+AC_CONFIG_FILES([ruby/run-ruby-tests], [chmod +x ruby/run-ruby-tests])
 AC_CONFIG_FILES([run], [chmod +x,-w run])
 AC_OUTPUT
 
diff --git a/ruby/run-ruby-tests b/ruby/run-ruby-tests
deleted file mode 100755
index 2efd890..0000000
--- a/ruby/run-ruby-tests
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh -
-# hivex Ruby bindings
-# Copyright (C) 2009-2011 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-set -e
-
-# Run them one at a time, otherwise rake runs them in parallel (which
-# is bound to fail because they all use a single test image file).
-
-for f in tests/tc_*.rb; do
-    echo $RAKE test "$@" TEST="$f"
-    $RAKE test "$@" TEST="$f"
-done
diff --git a/ruby/run-ruby-tests.in b/ruby/run-ruby-tests.in
new file mode 100755
index 0000000..b61699e
--- /dev/null
+++ b/ruby/run-ruby-tests.in
@@ -0,0 +1,27 @@
+#!/bin/sh -
+# hivex Ruby bindings
+# Copyright (C) 2009-2011 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+set -e
+
+# Run them one at a time, otherwise rake runs them in parallel (which
+# is bound to fail because they all use a single test image file).
+export abs_srcdir=@abs_srcdir@
+for f in @srcdir@/tests/tc_*.rb; do
+    echo $RAKE test "$@" TEST="$f"
+    $RAKE test "$@" TEST="$f"
+done
diff --git a/ruby/tests/tc_010_load.rb b/ruby/tests/tc_010_load.rb
index 113ab69..8a8ae51 100644
--- a/ruby/tests/tc_010_load.rb
+++ b/ruby/tests/tc_010_load.rb
@@ -16,8 +16,6 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 require 'test/unit'
-$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
-$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "hivex"))
 require 'hivex'
 
 class TestLoad < Test::Unit::TestCase
diff --git a/ruby/tests/tc_021_close.rb b/ruby/tests/tc_021_close.rb
index a089cf3..9c5ea65 100644
--- a/ruby/tests/tc_021_close.rb
+++ b/ruby/tests/tc_021_close.rb
@@ -16,8 +16,6 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 require 'test/unit'
-$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
-$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "hivex"))
 require 'hivex'
 
 class TestClose < Test::Unit::TestCase
diff --git a/ruby/tests/tc_120_rlenvalue.rb b/ruby/tests/tc_120_rlenvalue.rb
index 368cb19..5cb0a80 100644
--- a/ruby/tests/tc_120_rlenvalue.rb
+++ b/ruby/tests/tc_120_rlenvalue.rb
@@ -22,13 +22,11 @@
 # 8712.
 
 require 'test/unit'
-$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
-$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "hivex"))
 require 'hivex'
 
 class TestRLenValue < Test::Unit::TestCase
   def test_RLenValue
-    h = Hivex::open("../images/rlenvalue_test_hive", {})
+    h = Hivex::open(File::join(ENV['abs_srcdir'], '..', 'images', 'rlenvalue_test_hive'), {})
     assert_not_nil(h)
 
     root = h.root()
diff --git a/ruby/tests/tc_200_write.rb b/ruby/tests/tc_200_write.rb
index b46dc7b..6ae239e 100644
--- a/ruby/tests/tc_200_write.rb
+++ b/ruby/tests/tc_200_write.rb
@@ -16,8 +16,6 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 require 'test/unit'
-$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
-$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "hivex"))
 require 'hivex'
 
 class TestWrite < Test::Unit::TestCase
diff --git a/ruby/tests/tc_210_setvalue.rb b/ruby/tests/tc_210_setvalue.rb
index e55e5fe..4d1aa7e 100644
--- a/ruby/tests/tc_210_setvalue.rb
+++ b/ruby/tests/tc_210_setvalue.rb
@@ -16,8 +16,6 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 require 'test/unit'
-$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
-$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "hivex"))
 require 'hivex'
 
 class TestSetValue < Test::Unit::TestCase
diff --git a/run.in b/run.in
index 9592e38..46b3df6 100755
--- a/run.in
+++ b/run.in
@@ -70,9 +70,9 @@ export PYTHONPATH
 export RUBY=@RUBY@
 export RAKE=@RAKE@
 if [ -z "$RUBYLIB" ]; then
-    RUBYLIB="$b/ruby/lib:$b/ruby/ext/hivex"
+    RUBYLIB="$s/ruby/lib:$b/ruby/ext/hivex"
 else
-    RUBYLIB="$b/ruby/lib:$b/ruby/ext/hivex:$RUBYLIB"
+    RUBYLIB="$s/ruby/lib:$b/ruby/ext/hivex:$RUBYLIB"
 fi
 export RUBYLIB
 export LD_LIBRARY_PATH="$b/ruby/ext/hivex:$LD_LIBRARY_PATH"
-- 
1.8.5.2




More information about the Libguestfs mailing list