Refactor tests to use the new cmocka test runner
## Summary Fixes https://github.com/profanity-im/profanity/issues/1907 Update functional and unit test code to comply with the current cmocka test runner. ## Changes - `UnitTest` struct to `CMUnitTest` struct - `unit_test()` macro to `cmocka_unit_test(f)` macro - `unit_test_setup_teardown()` macro to `cmocka_unit_test_setup_teardown` macro - `run_tests()` macro to `cmocka_run_group_tests()` function - Setup and teardown functions return `int` instead of `void` ## Testing ### Unit Tests `make check` ### Functional Tests I did not compile or run functional tests because they are *shelved* for now. ### Valgrind I'm not entirely sure how to fun Valgrind in this case. I did not do fancy memory management, so it should be fine.
This commit is contained in:
@@ -44,7 +44,7 @@ remove_data_dir(void** state)
|
||||
rmdir("./tests/files/xdg_data_home");
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
load_preferences(void** state)
|
||||
{
|
||||
create_config_dir(state);
|
||||
@@ -53,29 +53,33 @@ load_preferences(void** state)
|
||||
prefs_load(NULL);
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
close_preferences(void** state)
|
||||
{
|
||||
prefs_close();
|
||||
remove("./tests/files/xdg_config_home/profanity/profrc");
|
||||
remove_config_dir(state);
|
||||
rmdir("./tests/files");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
init_chat_sessions(void** state)
|
||||
{
|
||||
load_preferences(NULL);
|
||||
chat_sessions_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
close_chat_sessions(void** state)
|
||||
{
|
||||
chat_sessions_clear();
|
||||
close_preferences(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "glib.h"
|
||||
|
||||
void load_preferences(void** state);
|
||||
void close_preferences(void** state);
|
||||
int load_preferences(void** state);
|
||||
int close_preferences(void** state);
|
||||
|
||||
void init_chat_sessions(void** state);
|
||||
void close_chat_sessions(void** state);
|
||||
int init_chat_sessions(void** state);
|
||||
int close_chat_sessions(void** state);
|
||||
|
||||
int utf8_pos_to_col(char* str, int utf8_pos);
|
||||
|
||||
|
||||
@@ -6,16 +6,18 @@
|
||||
|
||||
#include "xmpp/muc.h"
|
||||
|
||||
void
|
||||
int
|
||||
muc_before_test(void** state)
|
||||
{
|
||||
muc_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
muc_after_test(void** state)
|
||||
{
|
||||
muc_close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
void muc_before_test(void** state);
|
||||
void muc_after_test(void** state);
|
||||
int muc_before_test(void** state);
|
||||
int muc_after_test(void** state);
|
||||
|
||||
void test_muc_invites_add(void** state);
|
||||
void test_muc_remove_invite(void** state);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user