diff --git a/ruby/Makefile.am b/ruby/Makefile.am index 8c9684423..f605188e0 100644 --- a/ruby/Makefile.am +++ b/ruby/Makefile.am @@ -29,7 +29,8 @@ EXTRA_DIST = \ lib/guestfs.rb \ run-bindtests \ run-ruby-tests \ - t/tc_*.rb + t/tc_*.rb \ + t/test_helper.rb CLEANFILES = \ lib/*~ \ diff --git a/ruby/t/tc_010_load.rb b/ruby/t/tc_010_load.rb index 800d1ff81..f1d296c4c 100644 --- a/ruby/t/tc_010_load.rb +++ b/ruby/t/tc_010_load.rb @@ -15,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_load diff --git a/ruby/t/tc_020_create.rb b/ruby/t/tc_020_create.rb index d765acd0a..74764392f 100644 --- a/ruby/t/tc_020_create.rb +++ b/ruby/t/tc_020_create.rb @@ -15,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_create diff --git a/ruby/t/tc_030_create_flags.rb b/ruby/t/tc_030_create_flags.rb index 7ec2ce99b..3286a1f60 100644 --- a/ruby/t/tc_030_create_flags.rb +++ b/ruby/t/tc_030_create_flags.rb @@ -1,5 +1,5 @@ # libguestfs Ruby bindings -*- ruby -*- -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_create_flags diff --git a/ruby/t/tc_040_create_multiple.rb b/ruby/t/tc_040_create_multiple.rb index 339b699e3..0d86786a5 100644 --- a/ruby/t/tc_040_create_multiple.rb +++ b/ruby/t/tc_040_create_multiple.rb @@ -1,5 +1,5 @@ # libguestfs Ruby bindings -*- ruby -*- -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_create_multiple diff --git a/ruby/t/tc_050_handle_properties.rb b/ruby/t/tc_050_handle_properties.rb index cf4a7a75f..55bb2072e 100644 --- a/ruby/t/tc_050_handle_properties.rb +++ b/ruby/t/tc_050_handle_properties.rb @@ -1,5 +1,5 @@ # libguestfs Ruby bindings -*- ruby -*- -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_handle_properties diff --git a/ruby/t/tc_060_explicit_close.rb b/ruby/t/tc_060_explicit_close.rb index 74456e45b..4752d479b 100644 --- a/ruby/t/tc_060_explicit_close.rb +++ b/ruby/t/tc_060_explicit_close.rb @@ -1,5 +1,5 @@ # libguestfs Ruby bindings -*- ruby -*- -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_explicit_close diff --git a/ruby/t/tc_070_optargs.rb b/ruby/t/tc_070_optargs.rb index e28f944a7..b8c23e65d 100644 --- a/ruby/t/tc_070_optargs.rb +++ b/ruby/t/tc_070_optargs.rb @@ -1,5 +1,5 @@ # libguestfs Ruby bindings -*- ruby -*- -# Copyright (C) 2010 Red Hat Inc. +# Copyright (C) 2010-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,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_optargs diff --git a/ruby/t/tc_100_launch.rb b/ruby/t/tc_100_launch.rb index f77a026f3..68fb1197d 100644 --- a/ruby/t/tc_100_launch.rb +++ b/ruby/t/tc_100_launch.rb @@ -15,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_launch diff --git a/ruby/t/tc_410_close_event.rb b/ruby/t/tc_410_close_event.rb index f694ca86b..d0c446563 100644 --- a/ruby/t/tc_410_close_event.rb +++ b/ruby/t/tc_410_close_event.rb @@ -15,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_events diff --git a/ruby/t/tc_420_log_messages.rb b/ruby/t/tc_420_log_messages.rb index 6757d4623..4397e6e5f 100644 --- a/ruby/t/tc_420_log_messages.rb +++ b/ruby/t/tc_420_log_messages.rb @@ -15,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_events diff --git a/ruby/t/tc_800_rhbz507346.rb b/ruby/t/tc_800_rhbz507346.rb index 66e0e9269..100b1fe76 100644 --- a/ruby/t/tc_800_rhbz507346.rb +++ b/ruby/t/tc_800_rhbz507346.rb @@ -1,5 +1,5 @@ # libguestfs Ruby bindings -*- ruby -*- -# Copyright (C) 2009 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,10 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_rhbz507346 diff --git a/ruby/t/tc_810_rhbz664558c6.rb b/ruby/t/tc_810_rhbz664558c6.rb index 5eb373ea0..105035b7f 100644 --- a/ruby/t/tc_810_rhbz664558c6.rb +++ b/ruby/t/tc_810_rhbz664558c6.rb @@ -1,5 +1,5 @@ # libguestfs Ruby bindings -*- ruby -*- -# Copyright (C) 2011 Red Hat Inc. +# Copyright (C) 2011-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 @@ -19,10 +19,7 @@ # the interpreter to segfault. See: # https://bugzilla.redhat.com/show_bug.cgi?id=664558#c6 -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def test_rhbz664558c6 diff --git a/ruby/t/tc_820_rhbz1046509.rb b/ruby/t/tc_820_rhbz1046509.rb index 978decd83..831aaf058 100644 --- a/ruby/t/tc_820_rhbz1046509.rb +++ b/ruby/t/tc_820_rhbz1046509.rb @@ -1,5 +1,5 @@ # libguestfs Ruby bindings -*- ruby -*- -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -18,10 +18,7 @@ # Test that we don't break the old ::create module function while # fixing https://bugzilla.redhat.com/show_bug.cgi?id=1046509 -require 'test/unit' -$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) -$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) -require 'guestfs' +require File::join(File::dirname(__FILE__), 'test_helper') class TestLoad < Test::Unit::TestCase def _handleok(g) diff --git a/ruby/t/test_helper.rb b/ruby/t/test_helper.rb new file mode 100644 index 000000000..8ebfe2f97 --- /dev/null +++ b/ruby/t/test_helper.rb @@ -0,0 +1,22 @@ +# libguestfs 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +require 'test/unit' + +$:.unshift(File::join(File::dirname(__FILE__), "..", "lib")) +$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs")) +require 'guestfs'