Isolate in a common file all the standard boilerplate in tests, i.e. the
import of the test framework and the guestfs module (including the
import path hack needed for the latter).
(This is the same change as fbae7f3e69ce598c52af71ec204f8dbd0a9ce5e5
in libguestfs.)
---
ruby/Makefile.am | 3 ++-
ruby/tests/tc_010_load.rb | 5 ++---
ruby/tests/tc_021_close.rb | 5 ++---
ruby/tests/tc_120_rlenvalue.rb | 5 ++---
ruby/tests/tc_130_special.rb | 3 +--
ruby/tests/tc_200_write.rb | 5 ++---
ruby/tests/tc_210_setvalue.rb | 5 ++---
ruby/tests/test_helper.rb | 20 ++++++++++++++++++++
8 files changed, 33 insertions(+), 18 deletions(-)
create mode 100644 ruby/tests/test_helper.rb
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index 7a5fe42..0e9a868 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -23,7 +23,8 @@ EXTRA_DIST = \
ext/hivex/_hivex.c \
lib/hivex.rb \
run-ruby-tests \
- tests/tc_*.rb
+ tests/tc_*.rb \
+ tests/test_helper.rb
CLEANFILES = \
lib/*~ \
diff --git a/ruby/tests/tc_010_load.rb b/ruby/tests/tc_010_load.rb
index 8a8ae51..a45e904 100644
--- a/ruby/tests/tc_010_load.rb
+++ b/ruby/tests/tc_010_load.rb
@@ -1,5 +1,5 @@
# hivex Ruby bindings -*- ruby -*-
-# Copyright (C) 2009-2011 Red Hat Inc.
+# Copyright (C) 2009-2014 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
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-require 'test/unit'
-require 'hivex'
+require File::join(File::dirname(__FILE__), 'test_helper')
class TestLoad < Test::Unit::TestCase
def test_load
diff --git a/ruby/tests/tc_021_close.rb b/ruby/tests/tc_021_close.rb
index 9c5ea65..3068e23 100644
--- a/ruby/tests/tc_021_close.rb
+++ b/ruby/tests/tc_021_close.rb
@@ -1,5 +1,5 @@
# hivex Ruby bindings -*- ruby -*-
-# Copyright (C) 2009-2011 Red Hat Inc.
+# Copyright (C) 2009-2014 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
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-require 'test/unit'
-require 'hivex'
+require File::join(File::dirname(__FILE__), 'test_helper')
class TestClose < Test::Unit::TestCase
def test_close
diff --git a/ruby/tests/tc_120_rlenvalue.rb b/ruby/tests/tc_120_rlenvalue.rb
index 5cb0a80..f269805 100644
--- a/ruby/tests/tc_120_rlenvalue.rb
+++ b/ruby/tests/tc_120_rlenvalue.rb
@@ -1,5 +1,5 @@
# hivex Ruby bindings -*- ruby -*-
-# Copyright (C) 2009-2011 Red Hat Inc.
+# Copyright (C) 2009-2014 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
@@ -21,8 +21,7 @@
# length and offset for this value cell should be 37 bytes, position
# 8712.
-require 'test/unit'
-require 'hivex'
+require File::join(File::dirname(__FILE__), 'test_helper')
class TestRLenValue < Test::Unit::TestCase
def test_RLenValue
diff --git a/ruby/tests/tc_130_special.rb b/ruby/tests/tc_130_special.rb
index 0623f4d..aedb543 100644
--- a/ruby/tests/tc_130_special.rb
+++ b/ruby/tests/tc_130_special.rb
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
# -*- ruby -*-
-require 'test/unit'
-require 'hivex'
+require File::join(File::dirname(__FILE__), 'test_helper')
class TestRLenValue < Test::Unit::TestCase
def test_RLenValue
diff --git a/ruby/tests/tc_200_write.rb b/ruby/tests/tc_200_write.rb
index 6ae239e..36faec2 100644
--- a/ruby/tests/tc_200_write.rb
+++ b/ruby/tests/tc_200_write.rb
@@ -1,5 +1,5 @@
# hivex Ruby bindings -*- ruby -*-
-# Copyright (C) 2009-2011 Red Hat Inc.
+# Copyright (C) 2009-2014 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
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-require 'test/unit'
-require 'hivex'
+require File::join(File::dirname(__FILE__), 'test_helper')
class TestWrite < Test::Unit::TestCase
def test_write
diff --git a/ruby/tests/tc_210_setvalue.rb b/ruby/tests/tc_210_setvalue.rb
index 4d1aa7e..3796dad 100644
--- a/ruby/tests/tc_210_setvalue.rb
+++ b/ruby/tests/tc_210_setvalue.rb
@@ -1,5 +1,5 @@
# hivex Ruby bindings -*- ruby -*-
-# Copyright (C) 2009-2011 Red Hat Inc.
+# Copyright (C) 2009-2014 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
@@ -15,8 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-require 'test/unit'
-require 'hivex'
+require File::join(File::dirname(__FILE__), 'test_helper')
class TestSetValue < Test::Unit::TestCase
def test_set_value
diff --git a/ruby/tests/test_helper.rb b/ruby/tests/test_helper.rb
new file mode 100644
index 0000000..67e1b14
--- /dev/null
+++ b/ruby/tests/test_helper.rb
@@ -0,0 +1,20 @@
+# hivex Ruby bindings -*- ruby -*-
+# Copyright (C) 2009-2014 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.
+
+require 'test/unit'
+
+require 'hivex'
--
1.9.0