ruby: tests: isolate boilerplate in common file

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).

Thanks to Vít Ondruch for the precious hints and suggestions.
This commit is contained in:
Pino Toscano
2014-04-18 11:27:11 +02:00
parent 0316d24770
commit fbae7f3e69
15 changed files with 45 additions and 61 deletions

View File

@@ -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/*~ \

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

22
ruby/t/test_helper.rb Normal file
View File

@@ -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'