2727
2828namespace fs = std::filesystem;
2929
30- class await_test : public testing ::Test
30+ class metacall_cli_core_plugin_await_test : public testing ::Test
3131{
3232public:
3333};
3434
35- TEST_F (await_test , DefaultConstructor)
35+ TEST_F (metacall_cli_core_plugin_await_test , DefaultConstructor)
3636{
3737 metacall_print_info ();
3838
@@ -60,56 +60,52 @@ TEST_F(await_test, DefaultConstructor)
6060 metacall_value_destroy (args[1 ]);
6161 metacall_value_destroy (result);
6262
63- /* NodeJS */
64- #if defined(OPTION_BUILD_LOADERS_NODE)
65- {
66- /* Get core plugin path and handle in order to load cli plugins */
67- const char *plugin_path = metacall_plugin_path ();
68- void *plugin_extension_handle = metacall_plugin_extension ();
69- void *cli_plugin_handle = NULL ;
70-
71- if (plugin_path != NULL && plugin_extension_handle != NULL )
72- {
73- /* Define the cli plugin path as string (core plugin path plus cli) */
74- fs::path plugin_cli_path (plugin_path);
75- plugin_cli_path /= " cli" ;
76- std::string plugin_cli_path_str (plugin_cli_path.string ());
77-
78- /* Load cli plugins into plugin cli handle */
79- void *args[] = {
80- metacall_value_create_string (plugin_cli_path_str.c_str (), plugin_cli_path_str.length ()),
81- metacall_value_create_ptr (&cli_plugin_handle)
82- };
83-
84- void *ret = metacallhv_s (plugin_extension_handle, " plugin_load_from_path" , args, sizeof (args) / sizeof (args[0 ]));
85-
86- if (ret == NULL || (ret != NULL && metacall_value_to_int (ret) != 0 ))
87- {
88- std::cerr << " Failed to load CLI plugins from folder: " << plugin_cli_path_str << std::endl;
89- }
90-
91- metacall_value_destroy (args[0 ]);
92- metacall_value_destroy (args[1 ]);
93- metacall_value_destroy (ret);
94- }
95-
96- void *func = metacall_handle_function (cli_plugin_handle, " await" );
97- if (func == NULL )
98- std::cerr << " function not in handle\n " << METACALL_PLUGIN_PATH << ' \n ' ;
99- void *args[] = {
100- metacall_value_create_function (func)
101- };
102- void *ret = metacallhv_s (handle, " await__test" , args, 1 );
103-
104- EXPECT_NE ((void *)NULL , (void *)ret);
105-
106- EXPECT_EQ ((enum metacall_value_id)METACALL_DOUBLE, (enum metacall_value_id)metacall_value_id (ret));
107-
108- EXPECT_EQ ((double )22 , (long )metacall_value_to_double (ret));
109-
110- metacall_value_destroy (ret);
111- }
112- #endif /* OPTION_BUILD_LOADERS_NODE */
63+ /* Get core plugin path and handle in order to load cli plugins */
64+ const char *plugin_path = metacall_plugin_path ();
65+ void *plugin_extension_handle = metacall_plugin_extension ();
66+ void *cli_plugin_handle = NULL ;
67+
68+ ASSERT_NE ((const char *)plugin_path, (const char *)NULL );
69+ ASSERT_NE ((void *)plugin_extension_handle, (void *)NULL );
70+
71+ /* Define the cli plugin path as string (core plugin path plus cli) */
72+ fs::path plugin_cli_path (plugin_path);
73+ plugin_cli_path /= " cli" ;
74+ std::string plugin_cli_path_str (plugin_cli_path.string ());
75+
76+ /* Load cli plugins into plugin cli handle */
77+ void *args_cli[] = {
78+ metacall_value_create_string (plugin_cli_path_str.c_str (), plugin_cli_path_str.length ()),
79+ metacall_value_create_ptr (&cli_plugin_handle)
80+ };
81+
82+ result = metacallhv_s (plugin_extension_handle, " plugin_load_from_path" , args_cli, sizeof (args_cli) / sizeof (args_cli[0 ]));
83+
84+ ASSERT_NE ((void *)result, (void *)NULL );
85+ ASSERT_EQ ((int )0 , (int )metacall_value_to_int (result));
86+
87+ metacall_value_destroy (args_cli[0 ]);
88+ metacall_value_destroy (args_cli[1 ]);
89+ metacall_value_destroy (result);
90+
91+ void *func = metacall_handle_function (cli_plugin_handle, " await" );
92+
93+ ASSERT_NE ((void *)func, (void *)NULL );
94+
95+ void *args_test[] = {
96+ metacall_value_create_function (func)
97+ };
98+
99+ result = metacallhv_s (handle, " await__test" , args_test, 1 );
100+
101+ EXPECT_NE ((void *)NULL , (void *)result);
102+
103+ EXPECT_EQ ((enum metacall_value_id)METACALL_DOUBLE, (enum metacall_value_id)metacall_value_id (result));
104+
105+ EXPECT_EQ ((double )22 , (long )metacall_value_to_double (result));
106+
107+ metacall_value_destroy (args_test[0 ]);
108+ metacall_value_destroy (result);
113109
114110 /* Print inspect information */
115111 {
@@ -125,7 +121,7 @@ TEST_F(await_test, DefaultConstructor)
125121
126122 EXPECT_GT ((size_t )size, (size_t )0 );
127123
128- // std::cout << inspect_str << std::endl;
124+ std::cout << inspect_str << std::endl;
129125
130126 metacall_allocator_free (allocator, inspect_str);
131127
0 commit comments