...
 
Commits (2)
......@@ -32,8 +32,13 @@ Bug fixes::
* core: fix forced highlight on messages sent to other buffers (issue #1277)
* buflist: fix warning displayed when script buffers.pl is loaded (issue #1274)
* irc: fix parsing of "time" message tag on FreeBSD (issue #1289)
* relay: fix memory leak in connection of client
Tests::
* unit: add tests on IRC configuration functions
Build::
* core: add C compiler flag "-fsigned--char" to force "char" data type to be always signed (issue #1277)
......
......@@ -95,6 +95,9 @@ The main WeeChat directories are:
|       python/ | Python scripts to generate and run the scripting API tests.
|    unit/ | Unit tests.
|       core/ | Unit tests for core functions.
|       gui/ | Unit tests for interfaces functions.
|       plugins/ | Unit tests for plugins.
|          irc/ | Unit tests for IRC plugin.
| doc/ | Documentation.
| po/ | Translations files (gettext).
| debian/ | Debian packaging.
......@@ -383,20 +386,24 @@ WeeChat "core" is located in following directories:
|    unit/ | Root of unit tests.
|       test-plugins.cpp | Tests: plugins.
|       core/ | Root of unit tests for core.
|          test-arraylist.cpp | Tests: arraylists.
|          test-eval.cpp | Tests: evaluation of expressions.
|          test-hashtble.cpp | Tests: hashtables.
|          test-hdata.cpp | Tests: hdata.
|          test-hook.cpp | Tests: hooks.
|          test-infolist.cpp | Tests: infolists.
|          test-list.cpp | Tests: lists.
|          test-secure.cpp | Tests: secured data.
|          test-string.cpp | Tests: strings.
|          test-url.cpp | Tests: URLs.
|          test-utf8.cpp | Tests: UTF-8.
|          test-util.cpp | Tests: utility functions.
|       gui/ | Root of unit tests for GUI.
|          test-line.cpp | Tests: lines.
|          test-core-arraylist.cpp | Tests: arraylists.
|          test-core-eval.cpp | Tests: evaluation of expressions.
|          test-core-hashtble.cpp | Tests: hashtables.
|          test-core-hdata.cpp | Tests: hdata.
|          test-core-hook.cpp | Tests: hooks.
|          test-core-infolist.cpp | Tests: infolists.
|          test-core-list.cpp | Tests: lists.
|          test-core-secure.cpp | Tests: secured data.
|          test-core-string.cpp | Tests: strings.
|          test-core-url.cpp | Tests: URLs.
|          test-core-utf8.cpp | Tests: UTF-8.
|          test-core-util.cpp | Tests: utility functions.
|       gui/ | Root of unit tests for interfaces.
|          test-gui-line.cpp | Tests: lines.
|       plugins/ | Root of unit tests for plugins.
|          irc/ | Root of unit tests for IRC plugin.
|             test-irc-config.cpp | Tests: IRC configuration.
|===
[[documentation_translations]]
......
......@@ -97,6 +97,9 @@ Les répertoires principaux de WeeChat sont :
|       python/ | Scripts Python pour générer et lancer les tests de l'API script.
|    unit/ | Tests unitaires.
|       core/ | Tests unitaires pour les fonctions du cœur.
|       gui/ | Tests unitaires pour les fonctions de l'interface.
|       plugins/ | Tests unitaires pour les extensions.
|          irc/ | Tests unitaires pour l'extension IRC.
| doc/ | Documentation.
| po/ | Fichiers de traductions (gettext).
| debian/ | Empaquetage Debian.
......@@ -385,20 +388,23 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|    unit/ | Racine des tests unitaires.
|       test-plugins.cpp | Tests : extensions.
|       core/ | Racine des tests unitaires pour le cœur.
|          test-arraylist.cpp | Tests : listes avec tableau (« arraylists »).
|          test-eval.cpp | Tests : évaluation d'expressions.
|          test-hashtble.cpp | Tests : tables de hachage.
|          test-hdata.cpp | Tests : hdata.
|          test-hook.cpp | Tests : hooks.
|          test-infolist.cpp | Tests : infolists.
|          test-list.cpp | Tests : listes.
|          test-secure.cpp | Tests : données sécurisées.
|          test-string.cpp | Tests : chaînes.
|          test-url.cpp | Tests : URLs.
|          test-utf8.cpp | Tests : UTF-8.
|          test-util.cpp | Tests : fonctions utiles.
|       gui/ | Racine des tests unitaires pour la GUI.
|          test-line.cpp | Tests : lignes.
|          test-core-arraylist.cpp | Tests : listes avec tableau (« arraylists »).
|          test-core-eval.cpp | Tests : évaluation d'expressions.
|          test-core-hashtble.cpp | Tests : tables de hachage.
|          test-core-hdata.cpp | Tests : hdata.
|          test-core-hook.cpp | Tests : hooks.
|          test-core-infolist.cpp | Tests : infolists.
|          test-core-list.cpp | Tests : listes.
|          test-core-secure.cpp | Tests : données sécurisées.
|          test-core-string.cpp | Tests : chaînes.
|          test-core-url.cpp | Tests : URLs.
|          test-core-utf8.cpp | Tests : UTF-8.
|          test-core-util.cpp | Tests : fonctions utiles.
|       gui/ | Racine des tests unitaires pour les interfaces.
|          test-gui-line.cpp | Tests : lignes.
|       plugins/ | Racine des tests unitaires pour les extensions.
|          irc/ | Racine des tests unitaires pour l'extension IRC.
|             test-irc-config.cpp | Tests : configuration IRC.
|===
[[documentation_translations]]
......
......@@ -101,6 +101,12 @@ qweechat::
|       python/ | スクリプト API テストを生成、実行する Python スクリプト
|    unit/ | 単体テスト
|       core/ | コア関数の単体テスト
// TRANSLATION MISSING
|       gui/ | Unit tests for interfaces functions.
// TRANSLATION MISSING
|       plugins/ | Unit tests for plugins.
// TRANSLATION MISSING
|          irc/ | Unit tests for IRC plugin.
| doc/ | 文書
| po/ | 翻訳ファイル (gettext)
| debian/ | Debian パッケージ用
......@@ -389,20 +395,27 @@ WeeChat "core" は以下のディレクトリに配置されています:
|    unit/ | 単体テスト用のルートディレクトリ
|       test-plugins.cpp | テスト: プラグイン
|       core/ | core 向け単体テスト用のルートディレクトリ
|          test-arraylist.cpp | テスト: 配列リスト
|          test-eval.cpp | テスト: 式の評価
|          test-hashtble.cpp | テスト: ハッシュテーブル
|          test-hdata.cpp | テスト: hdata
|          test-hook.cpp | テスト: フック
|          test-infolist.cpp | テスト: インフォリスト
|          test-list.cpp | テスト: リスト
|          test-secure.cpp | テスト: データ保護
|          test-string.cpp | テスト: 文字列
|          test-url.cpp | テスト: URL
|          test-utf8.cpp | テスト: UTF-8
|          test-util.cpp | テスト: ユーティリティ関数
|       gui/ | GUI に関する単体テスト用のルートディレクトリ
|          test-line.cpp | テスト: 行
|          test-core-arraylist.cpp | テスト: 配列リスト
|          test-core-eval.cpp | テスト: 式の評価
|          test-core-hashtble.cpp | テスト: ハッシュテーブル
|          test-core-hdata.cpp | テスト: hdata
|          test-core-hook.cpp | テスト: フック
|          test-core-infolist.cpp | テスト: インフォリスト
|          test-core-list.cpp | テスト: リスト
|          test-core-secure.cpp | テスト: データ保護
|          test-core-string.cpp | テスト: 文字列
|          test-core-url.cpp | テスト: URL
|          test-core-utf8.cpp | テスト: UTF-8
|          test-core-util.cpp | テスト: ユーティリティ関数
// TRANSLATION MISSING
|       gui/ | Root of unit tests for interfaces.
|          test-gui-line.cpp | テスト: 行
// TRANSLATION MISSING
|       plugins/ | Root of unit tests for plugins.
// TRANSLATION MISSING
|          irc/ | Root of unit tests for IRC plugin.
// TRANSLATION MISSING
|             test-irc-config.cpp | Tests: IRC configuration.
|===
[[documentation_translations]]
......
......@@ -189,6 +189,7 @@ extern char **irc_config_nicks_hide_password;
extern int irc_config_num_nicks_hide_password;
extern int irc_config_display_channel_modes_arguments (const char *modes);
extern int irc_config_check_autojoin (const char *autojoin);
extern int irc_config_server_check_value_cb (const void *pointer, void *data,
struct t_config_option *option,
const char *value);
......
......@@ -6107,7 +6107,7 @@ irc_protocol_get_message_tag_time (struct t_hashtable *tags)
if (strchr (tag_time, '-'))
{
/* date is with ISO 8601 format: "2012-11-24T07:41:02.018Z" */
strptime (tag_time, "%Y-%m-%dT%H:%M:%S%z", &tm_date);
strptime (tag_time, "%Y-%m-%dT%H:%M:%S", &tm_date);
if (tm_date.tm_year > 0)
{
time_msg = mktime (&tm_date);
......
......@@ -22,25 +22,31 @@ enable_language(CXX)
remove_definitions(-DHAVE_CONFIG_H)
include_directories(${CPPUTEST_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR})
# unit tests
set(LIB_WEECHAT_UNIT_TESTS_SRC
# unit tests (core)
set(LIB_WEECHAT_UNIT_TESTS_CORE_SRC
unit/test-plugins.cpp
unit/core/test-arraylist.cpp
unit/core/test-eval.cpp
unit/core/test-hashtable.cpp
unit/core/test-hdata.cpp
unit/core/test-hook.cpp
unit/core/test-infolist.cpp
unit/core/test-list.cpp
unit/core/test-secure.cpp
unit/core/test-string.cpp
unit/core/test-url.cpp
unit/core/test-utf8.cpp
unit/core/test-util.cpp
unit/gui/test-line.cpp
unit/core/test-core-arraylist.cpp
unit/core/test-core-eval.cpp
unit/core/test-core-hashtable.cpp
unit/core/test-core-hdata.cpp
unit/core/test-core-hook.cpp
unit/core/test-core-infolist.cpp
unit/core/test-core-list.cpp
unit/core/test-core-secure.cpp
unit/core/test-core-string.cpp
unit/core/test-core-url.cpp
unit/core/test-core-utf8.cpp
unit/core/test-core-util.cpp
unit/gui/test-gui-line.cpp
scripts/test-scripts.cpp
)
add_library(weechat_unit_tests STATIC ${LIB_WEECHAT_UNIT_TESTS_SRC})
add_library(weechat_unit_tests_core STATIC ${LIB_WEECHAT_UNIT_TESTS_CORE_SRC})
# unit tests (plugins)
set(LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC
unit/plugins/irc/test-irc-config.cpp
)
add_library(weechat_unit_tests_plugins MODULE ${LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC})
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
list(APPEND EXTRA_LIBS "intl")
......@@ -59,7 +65,7 @@ set(LIBS
${PROJECT_BINARY_DIR}/src/gui/libweechat_gui_common.a
${PROJECT_BINARY_DIR}/src/gui/curses/headless/libweechat_gui_headless.a
${PROJECT_BINARY_DIR}/src/gui/curses/headless/libweechat_ncurses_fake.a
${CMAKE_CURRENT_BINARY_DIR}/libweechat_unit_tests.a
${CMAKE_CURRENT_BINARY_DIR}/libweechat_unit_tests_core.a
# due to circular references, we must link two times with libweechat_core.a
${PROJECT_BINARY_DIR}/src/core/libweechat_core.a
${EXTRA_LIBS}
......@@ -69,7 +75,7 @@ target_link_libraries(tests ${LIBS})
add_dependencies(tests
weechat_core weechat_plugins weechat_gui_common weechat_gui_headless
weechat_ncurses_fake
weechat_unit_tests)
weechat_unit_tests_core)
# test for cmake (ctest)
add_test(NAME unit
......@@ -78,4 +84,5 @@ add_test(NAME unit
set_property(TEST unit PROPERTY
ENVIRONMENT "WEECHAT_TESTS_ARGS=-p;"
"WEECHAT_EXTRA_LIBDIR=${PROJECT_BINARY_DIR}/src;"
"WEECHAT_TESTS_SCRIPTS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/scripts/python")
"WEECHAT_TESTS_SCRIPTS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/scripts/python"
"WEECHAT_TESTS_PLUGINS_LIB=${CMAKE_CURRENT_BINARY_DIR}/libweechat_unit_tests_plugins.so")
......@@ -19,22 +19,22 @@
AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" $(CPPUTEST_CFLAGS) -I$(abs_top_srcdir)
noinst_LIBRARIES = lib_weechat_unit_tests.a
lib_weechat_unit_tests_a_SOURCES = unit/test-plugins.cpp \
unit/core/test-arraylist.cpp \
unit/core/test-eval.cpp \
unit/core/test-hashtable.cpp \
unit/core/test-hdata.cpp \
unit/core/test-hook.cpp \
unit/core/test-infolist.cpp \
unit/core/test-list.cpp \
unit/core/test-secure.cpp \
unit/core/test-string.cpp \
unit/core/test-url.cpp \
unit/core/test-utf8.cpp \
unit/core/test-util.cpp \
unit/gui/test-line.cpp \
noinst_LIBRARIES = lib_weechat_unit_tests_core.a
lib_weechat_unit_tests_core_a_SOURCES = unit/test-plugins.cpp \
unit/core/test-core-arraylist.cpp \
unit/core/test-core-eval.cpp \
unit/core/test-core-hashtable.cpp \
unit/core/test-core-hdata.cpp \
unit/core/test-core-hook.cpp \
unit/core/test-core-infolist.cpp \
unit/core/test-core-list.cpp \
unit/core/test-core-secure.cpp \
unit/core/test-core-string.cpp \
unit/core/test-core-url.cpp \
unit/core/test-core-utf8.cpp \
unit/core/test-core-util.cpp \
unit/gui/test-gui-line.cpp \
scripts/test-scripts.cpp
noinst_PROGRAMS = tests
......@@ -46,7 +46,7 @@ tests_LDADD = ./../src/core/lib_weechat_core.a \
../src/gui/lib_weechat_gui_common.a \
../src/gui/curses/headless/lib_weechat_gui_headless.a \
../src/gui/curses/headless/lib_weechat_ncurses_fake.a \
lib_weechat_unit_tests.a \
lib_weechat_unit_tests_core.a \
../src/core/lib_weechat_core.a \
$(PLUGINS_LFLAGS) \
$(GCRYPT_LFLAGS) \
......@@ -54,8 +54,15 @@ tests_LDADD = ./../src/core/lib_weechat_core.a \
$(CURL_LFLAGS) \
$(CPPUTEST_LFLAGS) \
-lm
tests_LDFLAGS = -rdynamic
tests_SOURCES = tests.cpp \
tests.h
lib_LTLIBRARIES = lib_weechat_unit_tests_plugins.la
lib_weechat_unit_tests_plugins_la_SOURCES = unit/plugins/irc/test-irc-config.cpp
lib_weechat_unit_tests_plugins_la_LDFLAGS = -module -no-undefined
EXTRA_DIST = CMakeLists.txt
......@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <dlfcn.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
......@@ -52,6 +53,10 @@ extern "C"
#define WEECHAT_TESTS_HOME "./tmp_weechat_test"
/* lib with tests on plugins when autotools is used to compile */
#define WEECHAT_TESTS_PLUGINS_LIB_DEFAULT \
"./tests/.libs/lib_weechat_unit_tests_plugins.so.0.0.0"
/* import tests from libs */
/* core */
IMPORT_TEST_GROUP(Plugins);
......@@ -108,8 +113,11 @@ test_print_cb (const void *pointer, void *data, struct t_gui_buffer *buffer,
(void) highlight;
/* keep only messages displayed on core buffer */
if (strcmp (gui_buffer_get_string (buffer, "full_name"), "core.weechat") != 0)
if (strcmp (gui_buffer_get_string (buffer, "full_name"),
"core.weechat") != 0)
{
return WEECHAT_RC_OK;
}
printf ("%s%s%s\n", /* with color: "\33[34m%s%s%s\33[0m\n" */
(prefix && prefix[0]) ? prefix : "",
......@@ -165,7 +173,10 @@ int
main (int argc, char *argv[])
{
int rc, length, weechat_argc;
char *weechat_tests_args, *args, **weechat_argv;
char *weechat_tests_args, *args, **weechat_argv, *tests_plugins_lib;
const char *tests_plugins_lib_default = WEECHAT_TESTS_PLUGINS_LIB_DEFAULT;
const char *ptr_path;
void *handle;
/* setup environment: English language, no specific timezone */
setenv ("LC_ALL", LOCALE_TESTS, 1);
......@@ -225,6 +236,19 @@ main (int argc, char *argv[])
plugin_auto_load (NULL, 0, 1, 0, 0, NULL);
}
/* load plugins tests */
tests_plugins_lib = getenv ("WEECHAT_TESTS_PLUGINS_LIB");
ptr_path = (tests_plugins_lib && tests_plugins_lib[0]) ?
tests_plugins_lib : tests_plugins_lib_default;
printf ("Loading tests on plugins: \"%s\"\n", ptr_path);
handle = dlopen (ptr_path, RTLD_GLOBAL | RTLD_NOW);
if (!handle)
{
fprintf (stderr, "ERROR: unable to load tests on plugins: %s\n",
dlerror ());
return 1;
}
/* display WeeChat version and directories */
run_cmd ("/command core version");
run_cmd ("/debug dirs");
......@@ -247,5 +271,7 @@ main (int argc, char *argv[])
(rc == 0) ? 32 : 31, /* 32 = green (OK), 31 = red (error) */
(rc == 0) ? "OK" : "ERROR");
dlclose (handle);
return rc;
}
/*
* test-arraylist.cpp - test arraylist functions
* test-core-arraylist.cpp - test arraylist functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-eval.cpp - test evaluation functions
* test-core-eval.cpp - test evaluation functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-hashtable.cpp - test hashtable functions
* test-core-hashtable.cpp - test hashtable functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-hdata.cpp - test hdata functions
* test-core-hdata.cpp - test hdata functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-hook.cpp - test hook functions
* test-core-hook.cpp - test hook functions
*
* Copyright (C) 2018-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-infolist.cpp - test infolist functions
* test-core-infolist.cpp - test infolist functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-list.cpp - test list functions
* test-core-list.cpp - test list functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-secure.cpp - test secured data functions
* test-core-secure.cpp - test secured data functions
*
* Copyright (C) 2018-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-string.cpp - test string functions
* test-core-string.cpp - test string functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-url.cpp - test URL functions
* test-core-url.cpp - test URL functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-utf8.cpp - test UTF-8 string functions
* test-core-utf8.cpp - test UTF-8 string functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-util.cpp - test util functions
* test-core-util.cpp - test util functions
*
* Copyright (C) 2014-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-eval.cpp - test evaluation functions
* test-gui-line.cpp - test line functions
*
* Copyright (C) 2018-2019 Sébastien Helleu <flashcode@flashtux.org>
*
......
/*
* test-irc-config.cpp - test IRC configuration functions
*
* Copyright (C) 2019 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CppUTest/TestHarness.h"
extern "C"
{
#include "src/plugins/irc/irc-config.h"
}
TEST_GROUP(IrcConfig)
{
};
/*
* Tests functions:
* irc_config_check_autojoin
*/
TEST(IrcConfig, CheckAutojoin)
{
/* NULL/empty string */
LONGS_EQUAL(1, irc_config_check_autojoin(NULL));
LONGS_EQUAL(1, irc_config_check_autojoin(""));
/* wrong delimiter: space instead of comma */
LONGS_EQUAL(0, irc_config_check_autojoin("#chan1 #chan2 #chan3"));
/* no spaces allowed around comma */
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1, #chan2"));
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1 ,#chan2"));
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1 , #chan2"));
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1, #chan2, #chan3"));
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1 ,#chan2 ,#chan3"));
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1 , #chan2 , #chan3"));
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1,#chan2 key1, key2"));
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1,#chan2 key1 ,key2"));
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1,#chan2 key1 , key2"));
/* too many keys */
LONGS_EQUAL(0, irc_config_check_autojoin ("#chan1,#chan2 key1,key2,key3"));
/* correct values */
LONGS_EQUAL(1, irc_config_check_autojoin ("#chan1"));
LONGS_EQUAL(1, irc_config_check_autojoin ("#chan1 "));
LONGS_EQUAL(1, irc_config_check_autojoin ("#chan1 "));
LONGS_EQUAL(1, irc_config_check_autojoin (" #chan1"));
LONGS_EQUAL(1, irc_config_check_autojoin (" #chan1"));
LONGS_EQUAL(1, irc_config_check_autojoin (" #chan1 "));
LONGS_EQUAL(1, irc_config_check_autojoin (" #chan1 "));
LONGS_EQUAL(1, irc_config_check_autojoin ("#c1,#c2"));
LONGS_EQUAL(1, irc_config_check_autojoin ("#c1,#c2,#c3"));
LONGS_EQUAL(1, irc_config_check_autojoin ("#c1,#c2,#c3 key1"));
LONGS_EQUAL(1, irc_config_check_autojoin ("#c1,#c2,#c3 key1,key2"));
LONGS_EQUAL(1, irc_config_check_autojoin ("#c1,#c2,#c3 key1,key2,key3"));
}