diff tests/js-system/main.cpp @ 179:ef527409e638

Irccd: update JavaScript code
author David Demelier <markand@malikania.fr>
date Tue, 31 May 2016 21:03:01 +0200
parents a02756832959
children cb61cc16e2b6
line wrap: on
line diff
--- a/tests/js-system/main.cpp	Thu May 26 21:20:46 2016 +0200
+++ b/tests/js-system/main.cpp	Tue May 31 21:03:01 2016 +0200
@@ -23,6 +23,7 @@
 #include <irccd/mod-system.hpp>
 #include <irccd/plugin-js.hpp>
 #include <irccd/service-module.hpp>
+#include <irccd/sysconfig.hpp>
 #include <irccd/system.hpp>
 
 using namespace irccd;
@@ -36,6 +37,7 @@
 		: m_plugin(std::make_shared<JsPlugin>("empty", SOURCEDIR "/empty.js"))
 	{
 		m_irccd.moduleService().get("Irccd")->load(m_irccd, *m_plugin);
+		m_irccd.moduleService().get("Irccd.File")->load(m_irccd, *m_plugin);
 		m_irccd.moduleService().get("Irccd.System")->load(m_irccd, *m_plugin);
 	}
 };
@@ -51,6 +53,27 @@
 	}
 }
 
+#if defined(HAVE_POPEN)
+
+TEST_F(TestJsSystem, popen)
+{
+	try {
+		auto ret = duk::pevalString(m_plugin->context(),
+			"f = Irccd.System.popen(\"" IRCCD_EXECUTABLE " --version\", \"r\");"
+			"r = f.readline();"
+		);
+
+		if (ret != 0)
+			throw duk::exception(m_plugin->context(), -1);
+
+		ASSERT_EQ(IRCCD_VERSION, duk::getGlobal<std::string>(m_plugin->context(), "r"));
+	} catch (const std::exception &ex) {
+		FAIL() << ex.what();
+	}
+}
+
+#endif
+
 int main(int argc, char **argv)
 {
 	testing::InitGoogleTest(&argc, argv);