Some final g_test_build_filename() porting

This should be the last users that need to be ported.

For some of the oldschool non-gtester-ified tests, we call g_test_init()
from main() because it is necessary in order to use
g_test_build_filename().
This commit is contained in:
Ryan Lortie 2013-05-29 23:49:30 -04:00
parent d7b3e558cf
commit e66abbe2ef
8 changed files with 20 additions and 38 deletions

View File

@ -13,7 +13,7 @@ main (int argc, char *argv[])
g_assert_cmpint (pid_from_env, ==, getpid ());
envvar = g_getenv ("GIO_LAUNCHED_DESKTOP_FILE");
g_assert_cmpstr (envvar, ==, SRCDIR "/appinfo-test.desktop");
g_assert_cmpstr (envvar, ==, g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL));
return 0;
}

View File

@ -357,7 +357,7 @@ test_extra_getters (void)
gchar *s;
gboolean b;
appinfo = g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL));
g_assert (appinfo != NULL);
g_assert (g_desktop_app_info_has_key (appinfo, "Terminal"));

View File

@ -1309,7 +1309,7 @@ test_load (void)
/* Uses the value of $XDG_DATA_HOME we set in main() */
loaded = g_key_file_load_from_data_dirs (file, "keyfiletest.ini", NULL, 0, &error);
#else
loaded = g_key_file_load_from_file (file, SRCDIR "/keyfiletest.ini", 0, &error);
loaded = g_key_file_load_from_file (file, g_test_get_filename (G_TEST_DIST, "keyfiletest.ini", NULL), 0, &error);
#endif
g_assert_no_error (error);
g_assert (loaded);

View File

@ -204,7 +204,7 @@ main (int argc,
if (!g_file_test (echo_script_path, G_FILE_TEST_EXISTS))
{
g_free (echo_script_path);
echo_script_path = g_build_filename (SRCDIR, "echo-script", NULL);
echo_script_path = g_test_build_filename (G_TEST_DIST, "echo-script", NULL);
}
g_free (dirname);

View File

@ -11,8 +11,6 @@
#define BUFFER_SIZE 1024
static const gchar *datapath;
static void
test_small_writes (void)
{
@ -66,13 +64,10 @@ gint main (gint argc, gchar * argv[])
const gchar encoding[] = "EUC-JP";
GIOStatus status;
if (g_getenv ("G_TEST_DATA"))
datapath = g_getenv ("G_TEST_DATA");
else
datapath = SRCDIR;
g_test_init (&argc, &argv, NULL);
filename = g_test_build_filename (G_TEST_DIST, "iochannel-test-infile", NULL);
filename = g_build_filename (datapath, "iochannel-test-infile", NULL);
setbuf (stdout, NULL); /* For debugging */
gio_r = g_io_channel_new_file (filename, "r", &gerr);

View File

@ -30,8 +30,6 @@
#include <gmodule.h>
#include <string.h>
static const gchar *datapath;
gchar* global_state;
G_MODULE_EXPORT void g_clash_func (void);
@ -75,24 +73,21 @@ test_states (const gchar *global, const gchar *gplugin_a,
static SimpleFunc plugin_clash_func = NULL;
int
main (int arg,
char *argv[])
main (int argc,
char **argv)
{
GModule *module_self, *module_a, *module_b;
gchar *plugin_a, *plugin_b;
SimpleFunc f_a, f_b, f_self;
GModuleFunc gmod_f;
g_test_init (&argc, &argv, NULL);
if (!g_module_supported ())
g_error ("dynamic modules not supported");
if (g_getenv ("G_TEST_DATA"))
datapath = g_getenv ("G_TEST_DATA");
else
datapath = ".";
plugin_a = g_build_filename (datapath, "libmoduletestplugin_a", NULL);
plugin_b = g_build_filename (datapath, "libmoduletestplugin_b", NULL);
plugin_a = g_test_build_filename (G_TEST_BUILT, "libmoduletestplugin_a", NULL);
plugin_b = g_test_build_filename (G_TEST_BUILT, "libmoduletestplugin_b", NULL);
/* module handles */

View File

@ -12,7 +12,6 @@ int main (int argc, char **argv)
FILE *infile;
char buffer[1024];
char **strings;
const char *srcdir;
char *filename;
const char *locale;
const char *test;
@ -21,12 +20,9 @@ int main (int argc, char **argv)
char *current_locale = setlocale (LC_CTYPE, NULL);
gint result = 0;
if (g_getenv ("G_TEST_DATA"))
srcdir = g_getenv ("G_TEST_DATA");
else
srcdir = SRCDIR;
g_test_init (&argc, &argv, NULL);
filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "casemap.txt", NULL);
filename = g_test_build_filename (G_TEST_DIST, "casemap.txt", NULL);
infile = fopen (filename, "r");
if (!infile)
@ -96,7 +92,7 @@ int main (int argc, char **argv)
fclose (infile);
g_free (filename);
filename = g_strconcat (srcdir, G_DIR_SEPARATOR_S, "casefold.txt", NULL);
filename = g_test_build_filename (G_TEST_DIST, "casefold.txt", NULL);
infile = fopen (filename, "r");
if (!infile)

View File

@ -308,7 +308,6 @@ process (gint line,
int
main (int argc, char **argv)
{
const gchar *srcdir;
gchar *testfile;
gchar *contents;
GError *error = NULL;
@ -321,13 +320,10 @@ main (int argc, char **argv)
GArray *ucs4;
Status status = VALID; /* Quiet GCC */
if (g_getenv ("G_TEST_DATA"))
srcdir = g_getenv ("G_TEST_DATA");
else
srcdir = SRCDIR;
testfile = g_strconcat (srcdir, G_DIR_SEPARATOR_S "utf8.txt", NULL);
g_test_init (&argc, &argv, NULL);
testfile = g_test_build_filename (G_TEST_DIST, "utf8.txt", NULL);
g_file_get_contents (testfile, &contents, NULL, &error);
if (error)
croak ("Cannot open utf8.txt: %s", error->message);