aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-05-16 19:43:20 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-05-16 19:58:33 +0100
commit2a9170ca94302a6a8fbb6b15c5fb92e151522e72 (patch)
tree58e1bfa72c41fe70213e4b639454c323a0ef1c60
parent3c883c2c974dc73f8292ace543e123ce9e9aea15 (diff)
downloadpaludis-2a9170ca94302a6a8fbb6b15c5fb92e151522e72.tar.gz
paludis-2a9170ca94302a6a8fbb6b15c5fb92e151522e72.tar.xz
ruby testenvironment bindings
-rw-r--r--ruby/Makefile.am2
-rw-r--r--ruby/environment.cc32
-rw-r--r--ruby/environment_TEST.rb8
3 files changed, 41 insertions, 1 deletions
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index d500a53..20a6ff0 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -119,6 +119,7 @@ TESTS_ENVIRONMENT = env \
\`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/.libs\`: \
\`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/.libs\`: \
\`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/no_config/.libs\`: \
+ \`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/test/.libs\`: \
\`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/e/.libs\`: \
\`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/qa/.libs\`: \
\`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/ruby/.libs\`:$$LD_LIBRARY_PATH" \
@@ -154,6 +155,7 @@ libpaludisruby_@PALUDIS_PC_SLOT@_la_LIBADD = \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/environments/paludis/libpaludispaludisenvironment_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/environments/no_config/libpaludisnoconfigenvironment_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/environments/test/libpaludistestenvironment_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/repositories/fake/libpaludisfakerepository_@PALUDIS_PC_SLOT@.la \
$(PTHREAD_LIBS)
diff --git a/ruby/environment.cc b/ruby/environment.cc
index 822b3de..d3b5f6f 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -21,6 +21,7 @@
#include <paludis_ruby.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
+#include <paludis/environments/test/test_environment.hh>
#include <paludis/environment_factory.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/set.hh>
@@ -36,6 +37,7 @@ namespace
static VALUE c_environment;
static VALUE c_paludis_environment;
static VALUE c_no_config_environment;
+ static VALUE c_test_environment;
static VALUE c_environment_factory;
/*
@@ -287,6 +289,28 @@ namespace
/*
* call-seq:
+ * TestEnvironment.new -> TestEnvironment
+ *
+ * Create a new TestEnvironment.
+ */
+ VALUE
+ test_environment_new(VALUE self)
+ {
+ try
+ {
+ std::tr1::shared_ptr<Environment> * e = new std::tr1::shared_ptr<Environment>(new TestEnvironment);
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::tr1::shared_ptr<Environment> >::free, e));
+ rb_obj_call_init(tdata, 0, &self);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
* config_dir -> String
*
* Configuration directory used by this PaludisEnvironment.
@@ -507,6 +531,14 @@ namespace
rb_define_method(c_no_config_environment, "accept_unstable=", RUBY_FUNC_CAST(&no_config_environment_set_accept_unstable), 1);
/*
+ * Document-class: Paludis::TestEnvironment
+ *
+ * A crude test environment.
+ */
+ c_test_environment = rb_define_class_under(paludis_module(), "TestEnvironment", c_environment);
+ rb_define_singleton_method(c_test_environment, "new", RUBY_FUNC_CAST(&test_environment_new), 0);
+
+ /*
* Document-class: Paludis::EnvironmentFactory
*
* A class that holds methods to create environments.
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index d00514a..f28552d 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -2,7 +2,7 @@
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
# Copyright (c) 2007, 2008 Richard Brown
#
# This file is part of the Paludis package manager. Paludis is free software;
@@ -423,5 +423,11 @@ module Paludis
assert_nil ncenv.config_location_key
end
end
+
+ class TestCase_TestEnvironment < Test::Unit::TestCase
+ def test_create
+ x = TestEnvironment.new()
+ end
+ end
end