diff options
author | Bastien Nocera <hadess@hadess.net> | 2018-10-13 14:56:19 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2018-10-14 03:55:10 +0200 |
commit | 17e089919fca98df062994c974bb8624ac8bfb77 (patch) | |
tree | b3f8e92e4cd814bc5023dceb37fb131cc6621fba | |
parent | 04f2e23a27606590ff1ecba172d0bb7bbd81c1c6 (diff) | |
download | shared-mime-info-17e089919fca98df062994c974bb8624ac8bfb77.tar.gz |
build: Make tree-magic tests relative to test list file
So that the directories are relative to the test list file, which we
know the path of, rather than top_srcdir, which we can't get to if we
build with srcdir != builddir.
-rw-r--r-- | test-tree-magic.c | 11 | ||||
-rw-r--r-- | tests/tree-list | 22 |
2 files changed, 18 insertions, 15 deletions
diff --git a/test-tree-magic.c b/test-tree-magic.c index fd5cd7e8..0ff949a1 100644 --- a/test-tree-magic.c +++ b/test-tree-magic.c @@ -532,7 +532,8 @@ sniff_content_type (GFile *root) } static gboolean -handle_one_line (const char *line) +handle_one_line (const char *line, + const char *cwd) { GFile *file; GPtrArray *array; @@ -552,7 +553,7 @@ handle_one_line (const char *line) filename = items[0]; mimetypes = g_strsplit (items[1], " ", -1); - file = g_file_new_for_commandline_arg (filename); + file = g_file_new_for_commandline_arg_and_cwd (filename, cwd); array = sniff_content_type (file); if (array->len == 0) { @@ -634,7 +635,7 @@ print_matchlet (TreeMatchlet *matchlet, guint depth) int main (int argc, char **argv) { GError *error = NULL; - char *content, **lines; + char *content, **lines, *cwd; guint i; #if GLIB_CHECK_VERSION(2,36,0) @@ -678,12 +679,14 @@ int main (int argc, char **argv) lines = g_strsplit (content, "\n", -1); g_free (content); + cwd = g_path_get_dirname (argv[1]); for (i = 0; lines[i] != NULL; i++) { if (*lines[i] == '\0' || *lines[i] == '#') continue; - if (handle_one_line (lines[i]) == FALSE) + if (handle_one_line (lines[i], cwd) == FALSE) return 1; } + g_free (cwd); tree_magic_shutdown (); diff --git a/tests/tree-list b/tests/tree-list index bde9556b..38a5532d 100644 --- a/tests/tree-list +++ b/tests/tree-list @@ -1,14 +1,14 @@ # Supposed to work -tests/image-dcf x-content/image-dcf -tests/video-vcd x-content/video-vcd -tests/video-svcd x-content/video-svcd -tests/video-dvd x-content/video-dvd x-content/audio-dvd -tests/video-dvd-2 x-content/video-dvd x-content/audio-dvd -tests/video-dvd-3 x-content/video-dvd x-content/audio-dvd -tests/video-bluray x-content/video-bluray -tests/video-hddvd x-content/video-hddvd -tests/image-picturecd x-content/image-picturecd -tests/software x-content/unix-software +image-dcf x-content/image-dcf +video-vcd x-content/video-vcd +video-svcd x-content/video-svcd +video-dvd x-content/video-dvd x-content/audio-dvd +video-dvd-2 x-content/video-dvd x-content/audio-dvd +video-dvd-3 x-content/video-dvd x-content/audio-dvd +video-bluray x-content/video-bluray +video-hddvd x-content/video-hddvd +image-picturecd x-content/image-picturecd +software x-content/unix-software # Supposed to fail -x tests x-content/image-dcf +x tree-failure x-content/image-dcf |