aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-11-08 23:24:28 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-11-08 23:24:28 +0000
commit1e3f66540816679cd156156d6454ac8726d64ac9 (patch)
treefd12fd5f503623753c830436e726369f6e925cc6
parentd3e16ddedfbdd4d68b049bc2ee7bde954fd0f736 (diff)
downloadpaludis-1e3f66540816679cd156156d6454ac8726d64ac9.tar.gz
paludis-1e3f66540816679cd156156d6454ac8726d64ac9.tar.xz
(ruby) Add binding for PretendAction and SupportsInstalledActionTest.
-rw-r--r--ruby/action.cc89
-rw-r--r--ruby/action_TEST.rb38
2 files changed, 127 insertions, 0 deletions
diff --git a/ruby/action.cc b/ruby/action.cc
index 50e4fdd..c0f16c5 100644
--- a/ruby/action.cc
+++ b/ruby/action.cc
@@ -36,6 +36,8 @@ namespace
static VALUE c_supports_config_action_test;
static VALUE c_supports_install_action_test;
static VALUE c_supports_uninstall_action_test;
+ static VALUE c_supports_pretend_action_test;
+ static VALUE c_supports_installed_action_test;
static VALUE c_action;
static VALUE c_fetch_action;
@@ -53,6 +55,8 @@ namespace
static VALUE c_uninstall_action_options;
static VALUE c_uninstall_action;
+ static VALUE c_pretend_action;
+
const bool
value_to_bool(VALUE v)
{
@@ -218,6 +222,22 @@ namespace
*
* Create new SupportsUninstallActionTest object.
*/
+ /*
+ * Document-method: SupportsPretendActionTest.new
+ *
+ * call-seq:
+ * SupportsPretendActionTest.new -> SupportsPretendActionTest
+ *
+ * Create new SupportsPretendActionTest object.
+ */
+ /*
+ * Document-method: SupportsInstalledActionTest.new
+ *
+ * call-seq:
+ * SupportsInstalledActionTest.new -> SupportsInstalledActionTest
+ *
+ * Create new SupportsInstalledActionTest object.
+ */
template <typename A_>
struct SupportsActionTestNew
{
@@ -473,6 +493,14 @@ namespace
*
* Create new ConfigAction
*/
+ /*
+ * Document-method PretendAction.new
+ *
+ * call-seq:
+ * PretendAction.new -> PretendAction
+ *
+ * Create new PretendAction
+ */
template <typename A_>
struct EasyActionNew
{
@@ -705,6 +733,35 @@ namespace
return uninstall_action_options_to_value(tr1::static_pointer_cast<UninstallAction>(*p)->options);
}
+ /*
+ * call-seq:
+ * failed? -> true or false
+ *
+ * Did our pretend phase fail?
+ */
+ VALUE
+ pretend_action_failed(VALUE self)
+ {
+ tr1::shared_ptr<Action> * p;
+ Data_Get_Struct(self, tr1::shared_ptr<Action>, p);
+ return bool_to_value(tr1::static_pointer_cast<PretendAction>(*p)->failed());
+ }
+
+ /*
+ * call-seq:
+ * set_failed -> Qnil
+ *
+ * Mark the action as failed.
+ */
+ VALUE
+ pretend_action_set_failed(VALUE self)
+ {
+ tr1::shared_ptr<Action> * p;
+ Data_Get_Struct(self, tr1::shared_ptr<Action>, p);
+ tr1::static_pointer_cast<PretendAction>(*p)->set_failed();
+ return Qnil;
+ }
+
void do_register_action()
{
/*
@@ -766,6 +823,26 @@ namespace
rb_define_method(c_supports_uninstall_action_test, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
/*
+ * Document-class: Paludis::SupportsPretendActionTest
+ *
+ * Tests whether a Paludis::PackageID supports a Paludis::PretendAction.
+ */
+ c_supports_pretend_action_test = rb_define_class_under(paludis_module(), "SupportsPretendActionTest", c_supports_action_test_base);
+ rb_define_singleton_method(c_supports_pretend_action_test, "new",
+ RUBY_FUNC_CAST((&SupportsActionTestNew<PretendAction>::supports_action_test_new)), 0);
+ rb_define_method(c_supports_pretend_action_test, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
+
+ /*
+ * Document-class: Paludis::SupportsInstalledActionTest
+ *
+ * Tests whether a Paludis::PackageID supports a Paludis::InstalledAction.
+ */
+ c_supports_installed_action_test = rb_define_class_under(paludis_module(), "SupportsInstalledActionTest", c_supports_action_test_base);
+ rb_define_singleton_method(c_supports_installed_action_test, "new",
+ RUBY_FUNC_CAST((&SupportsActionTestNew<InstalledAction>::supports_action_test_new)), 0);
+ rb_define_method(c_supports_installed_action_test, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
+
+ /*
* Document-class: Paludis::Action
*
* Base class for actions, used by Paludis::PackageID#perform_action.
@@ -907,6 +984,18 @@ namespace
rb_define_singleton_method(c_uninstall_action, "new", RUBY_FUNC_CAST(&uninstall_action_new), 1);
rb_define_method(c_uninstall_action, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
rb_define_method(c_uninstall_action, "options", RUBY_FUNC_CAST(&uninstall_action_options), 0);
+
+ /*
+ * Document-class: Paludis::PretendAction
+ *
+ * A PretendAction is used by InstallTask to handle install-pretend-phase checks on a PackageID.
+ */
+ c_pretend_action = rb_define_class_under(paludis_module(), "PretendAction", c_action);
+ rb_define_singleton_method(c_pretend_action, "new",
+ RUBY_FUNC_CAST((&EasyActionNew<PretendAction>::easy_action_new)), 0);
+ rb_define_method(c_pretend_action, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
+ rb_define_method(c_pretend_action, "failed?", RUBY_FUNC_CAST(&pretend_action_failed), 0);
+ rb_define_method(c_pretend_action, "set_failed", RUBY_FUNC_CAST(&pretend_action_set_failed), 0);
}
}
diff --git a/ruby/action_TEST.rb b/ruby/action_TEST.rb
index 4947d89..c2382a2 100644
--- a/ruby/action_TEST.rb
+++ b/ruby/action_TEST.rb
@@ -88,6 +88,20 @@ module Paludis
end
end
+ class TestCase_SupportsInstallActionTest < Test::Unit::TestCase
+ def test_create
+ assert_kind_of SupportsInstallActionTest, SupportsInstallActionTest.new
+ assert_kind_of SupportsActionTestBase, SupportsInstallActionTest.new
+ end
+ end
+
+ class TestCase_SupportsInstallActionTest < Test::Unit::TestCase
+ def test_create
+ assert_kind_of SupportsInstallActionTest, SupportsInstallActionTest.new
+ assert_kind_of SupportsActionTestBase, SupportsInstallActionTest.new
+ end
+ end
+
class TestCase_Action < Test::Unit::TestCase
def test_no_create
assert_raise NoMethodError do
@@ -290,6 +304,30 @@ module Paludis
assert !action.options.no_config_protect?
end
end
+
+ class TestCase_PretendAction < Test::Unit::TestCase
+ def test_create
+ assert_kind_of PretendAction, PretendAction.new
+ assert_kind_of Action, PretendAction.new
+ end
+
+ def test_bad_create
+ assert_raise ArgumentError do
+ PretendAction.new('')
+ end
+ end
+
+ def test_methods
+ action = PretendAction.new
+ assert !action.failed?
+
+ assert_nothing_raised do
+ action.set_failed
+ end
+
+ assert action.failed?
+ end
+ end
end