diff options
-rw-r--r-- | tests/scripts/python/testapi.py | 13 | ||||
-rw-r--r-- | tests/scripts/test-scripts.cpp | 22 |
2 files changed, 29 insertions, 6 deletions
diff --git a/tests/scripts/python/testapi.py b/tests/scripts/python/testapi.py index 7825d015b..f3682ec1a 100644 --- a/tests/scripts/python/testapi.py +++ b/tests/scripts/python/testapi.py @@ -117,10 +117,7 @@ def test_lists(): weechat.list_free(ptr_list) -def weechat_init(): - """Main function.""" - weechat.register('SCRIPT_NAME', 'SCRIPT_AUTHOR', 'SCRIPT_VERSION', - 'SCRIPT_LICENSE', 'SCRIPT_DESCRIPTION', '', '') +def cmd_test_cb(data, buf, args): weechat.prnt('', '>>>') weechat.prnt('', '>>> ------------------------------') weechat.prnt('', '>>> Testing ' + 'SCRIPT_LANGUAGE' + ' API') @@ -129,3 +126,11 @@ def weechat_init(): test_strings() test_lists() weechat.prnt('', ' > TESTS END') + return weechat.WEECHAT_RC_OK + + +def weechat_init(): + """Main function.""" + weechat.register('SCRIPT_NAME', 'SCRIPT_AUTHOR', 'SCRIPT_VERSION', + 'SCRIPT_LICENSE', 'SCRIPT_DESCRIPTION', '', '') + weechat.hook_command('SCRIPT_NAME', '', '', '', '', 'cmd_test_cb', '') diff --git a/tests/scripts/test-scripts.cpp b/tests/scripts/test-scripts.cpp index e4dc441d1..aa5e36aee 100644 --- a/tests/scripts/test-scripts.cpp +++ b/tests/scripts/test-scripts.cpp @@ -28,9 +28,11 @@ extern "C" #endif #include <stdio.h> #include <string.h> +#include <sys/time.h> #include "src/core/weechat.h" #include "src/core/wee-string.h" #include "src/core/wee-hook.h" +#include "src/core/wee-util.h" #include "src/plugins/plugin.h" } @@ -132,6 +134,8 @@ TEST(Scripts, API) char path_testapigen[PATH_MAX], path_testapi[PATH_MAX]; char *path_testapi_output_dir, str_command[4096]; char *test_scripts_dir; + struct timeval time_start, time_end; + long long diff; const char *ptr_test_scripts_dir; const char *languages[][2] = { { "python", "py" }, @@ -207,15 +211,29 @@ TEST(Scripts, API) languages[i][1]); run_cmd (str_command); + /* get date/time before running tests */ + gettimeofday (&time_start, NULL); + + /* run tests */ + snprintf (str_command, sizeof (str_command), + "/testapi.%s", + languages[i][1]); + run_cmd (str_command); + + /* compute elapsed time */ + gettimeofday (&time_end, NULL); + diff = util_timeval_diff (&time_start, &time_end); + /* display results */ printf ("\n"); printf (">>> Tests %s: %d tests, %d OK, %d errors, " - "%d unexpected messages\n", + "%d unexpected messages, %lld ms\n", languages[i][0], api_tests_count, api_tests_ok, api_tests_errors, - api_tests_other); + api_tests_other, + diff / 1000); printf ("\n"); /* unload script */ |