From f43e9914684192da1ce1a1bf39e200f0cb821945 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 16 Nov 2022 23:27:37 +0200 Subject: [PATCH] tests: update Minor updates for the new CLI --- mu/tests/test-mu-cmd-cfind.cc | 10 ++++----- mu/tests/test-mu-cmd.cc | 40 ++++++++++++----------------------- mu/tests/test-mu-query.cc | 4 ++-- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/mu/tests/test-mu-cmd-cfind.cc b/mu/tests/test-mu-cmd-cfind.cc index 8aec0c2b..1a0dbeba 100644 --- a/mu/tests/test-mu-cmd-cfind.cc +++ b/mu/tests/test-mu-cmd-cfind.cc @@ -40,8 +40,8 @@ static std::string fill_contacts_cache(const std::string& path) { auto cmdline = format("/bin/sh -c '" - "%s init --muhome=%s --maildir=%s --quiet; " - "%s index --muhome=%s --quiet'", + "%s --quiet init --muhome=%s --maildir=%s ; " + "%s --quiet index --muhome=%s '", MU_PROGRAM, path.c_str(), MU_TESTMAILDIR, @@ -65,7 +65,7 @@ test_mu_cfind_plain(void) { gchar *cmdline, *output, *erroutput; - cmdline = g_strdup_printf("%s cfind --muhome=%s --format=plain " + cmdline = g_strdup_printf("%s --nocolor cfind --muhome=%s --format=plain " "'testmu\\.xxx?'", MU_PROGRAM, CONTACTS_CACHE.c_str()); @@ -103,7 +103,7 @@ test_mu_cfind_bbdb(void) old_tz = set_tz("Europe/Helsinki"); - cmdline = g_strdup_printf("%s cfind --muhome=%s --format=bbdb " + cmdline = g_strdup_printf("%s --nocolor cfind --muhome=%s --format=bbdb " "'testmu\\.xxx?'", MU_PROGRAM, CONTACTS_CACHE.c_str()); @@ -296,7 +296,7 @@ test_mu_cfind_csv(void) { gchar *cmdline, *output, *erroutput; - cmdline = g_strdup_printf("%s cfind --muhome=%s --format=csv " + cmdline = g_strdup_printf("%s --nocolor cfind --muhome=%s --format=csv " "'testmu\\.xxx?'", MU_PROGRAM, CONTACTS_CACHE.c_str()); diff --git a/mu/tests/test-mu-cmd.cc b/mu/tests/test-mu-cmd.cc index 4933c66b..9693538c 100644 --- a/mu/tests/test-mu-cmd.cc +++ b/mu/tests/test-mu-cmd.cc @@ -47,8 +47,8 @@ fill_database(void) GError* err; cmdline = g_strdup_printf("/bin/sh -c '" - "%s init --muhome=%s --maildir=%s --quiet; " - "%s index --muhome=%s --quiet'", + "%s --quiet init --muhome=%s --maildir=%s ; " + "%s --quiet index --muhome=%s '", MU_PROGRAM, DBPATH.c_str(), MU_TESTMAILDIR2, @@ -91,8 +91,7 @@ search_func(const char* query, unsigned expected) cmdline = g_strdup_printf("%s find --muhome=%s %s", MU_PROGRAM, DBPATH.c_str(), query); - g_message("[%u] %s", expected, query); - + g_debug("%s", cmdline); g_assert(g_spawn_command_line_sync(cmdline, &output, &erroutput, NULL, NULL)); if (g_test_verbose()) g_print("\nOutput:\n%s", output); @@ -307,9 +306,8 @@ test_mu_extract_01(void) tmpdir = test_mu_common_get_random_tmpdir(); g_assert(g_mkdir_with_parents(tmpdir, 0700) == 0); - cmdline = g_strdup_printf("%s extract --muhome=%s %s%cFoo%ccur%cmail5", + cmdline = g_strdup_printf("%s extract %s%cFoo%ccur%cmail5", MU_PROGRAM, - tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, G_DIR_SEPARATOR, @@ -354,7 +352,7 @@ get_file_size(const char* path) rv = stat(path, &statbuf); if (rv != 0) { - /* g_warning ("error: %s", g_strerror (errno)); */ + g_debug ("error: %s", g_strerror (errno)); return -1; } @@ -372,11 +370,10 @@ test_mu_extract_02(void) g_assert(g_mkdir_with_parents(tmpdir, 0700) == 0); - cmdline = g_strdup_printf("%s extract --muhome=%s -a " + cmdline = g_strdup_printf("%s extract -a " "--target-dir=%s %s%cFoo%ccur%cmail5", MU_PROGRAM, tmpdir, - tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, G_DIR_SEPARATOR, @@ -399,7 +396,6 @@ test_mu_extract_02(void) size = get_file_size(att2); g_assert_cmpint(size, ==, 17674); - g_free(output); g_free(tmpdir); g_free(cmdline); @@ -418,11 +414,10 @@ test_mu_extract_03(void) g_assert(g_mkdir_with_parents(tmpdir, 0700) == 0); - cmdline = g_strdup_printf("%s extract --muhome=%s --parts 3 " + cmdline = g_strdup_printf("%s extract --parts 3 " "--target-dir=%s %s%cFoo%ccur%cmail5", MU_PROGRAM, tmpdir, - tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, G_DIR_SEPARATOR, @@ -459,11 +454,10 @@ test_mu_extract_overwrite(void) g_assert(g_mkdir_with_parents(tmpdir, 0700) == 0); - cmdline = g_strdup_printf("%s extract --muhome=%s -a " + cmdline = g_strdup_printf("%s extract -a " "--target-dir=%s %s%cFoo%ccur%cmail5", MU_PROGRAM, tmpdir, - tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, G_DIR_SEPARATOR, @@ -491,11 +485,10 @@ test_mu_extract_overwrite(void) g_free(cmdline); /* this should work now, because we have specified --overwrite */ - cmdline = g_strdup_printf("%s extract --muhome=%s -a --overwrite " + cmdline = g_strdup_printf("%s extract -a --overwrite " "--target-dir=%s %s%cFoo%ccur%cmail5", MU_PROGRAM, tmpdir, - tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, G_DIR_SEPARATOR, @@ -522,12 +515,11 @@ test_mu_extract_by_name(void) g_assert(g_mkdir_with_parents(tmpdir, 0700) == 0); - cmdline = g_strdup_printf("%s extract --muhome=%s " + cmdline = g_strdup_printf("%s extract " "--target-dir=%s %s%cFoo%ccur%cmail5 " "sittingbull.jpg", MU_PROGRAM, tmpdir, - tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, G_DIR_SEPARATOR, @@ -559,9 +551,8 @@ test_mu_view_01(void) tmpdir = test_mu_common_get_random_tmpdir(); g_assert(g_mkdir_with_parents(tmpdir, 0700) == 0); - cmdline = g_strdup_printf("%s view --muhome=%s %s%cbar%ccur%cmail4", + cmdline = g_strdup_printf("%s view %s%cbar%ccur%cmail4", MU_PROGRAM, - tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, G_DIR_SEPARATOR, @@ -613,11 +604,10 @@ test_mu_view_multi(void) tmpdir = test_mu_common_get_random_tmpdir(); g_assert(g_mkdir_with_parents(tmpdir, 0700) == 0); - cmdline = g_strdup_printf("%s view --muhome=%s " + cmdline = g_strdup_printf("%s view " "%s%cbar%ccur%cmail5 " "%s%cbar%ccur%cmail5", MU_PROGRAM, - tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, G_DIR_SEPARATOR, @@ -649,11 +639,10 @@ test_mu_view_multi_separate(void) tmpdir = test_mu_common_get_random_tmpdir(); g_assert(g_mkdir_with_parents(tmpdir, 0700) == 0); - cmdline = g_strdup_printf("%s view --terminate --muhome=%s " + cmdline = g_strdup_printf("%s view --terminate " "%s%cbar%ccur%cmail5 " "%s%cbar%ccur%cmail5", MU_PROGRAM, - tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, G_DIR_SEPARATOR, @@ -716,10 +705,9 @@ test_mu_mkdir_01(void) tmpdir = test_mu_common_get_random_tmpdir(); g_assert(g_mkdir_with_parents(tmpdir, 0700) == 0); - cmdline = g_strdup_printf("%s mkdir --muhome=%s %s%ctest1 %s%ctest2", + cmdline = g_strdup_printf("%s mkdir %s%ctest1 %s%ctest2", MU_PROGRAM, tmpdir, - tmpdir, G_DIR_SEPARATOR, tmpdir, G_DIR_SEPARATOR); diff --git a/mu/tests/test-mu-query.cc b/mu/tests/test-mu-query.cc index 283f2e9a..7016b08a 100644 --- a/mu/tests/test-mu-query.cc +++ b/mu/tests/test-mu-query.cc @@ -50,8 +50,8 @@ make_database(const std::string& testdir) g_setenv("MUHOME", tmpdir, 1); const auto cmdline{format("/bin/sh -c '" - "%s init --maildir=%s --quiet ; " - "%s index --quiet'", + "%s --quiet init --maildir=%s ; " + "%s --quiet index'", MU_PROGRAM, testdir.c_str(), MU_PROGRAM)};