mirror of https://github.com/djcb/mu.git
test: don't "uniqify" link names during test
This commit is contained in:
parent
1868e4f977
commit
e43452fa18
|
@ -155,7 +155,7 @@ get_target_fullpath(const std::string& src, const std::string& targetpath,
|
||||||
if (auto&& res = check_subdir(src, in_cur); !res)
|
if (auto&& res = check_subdir(src, in_cur); !res)
|
||||||
return Err(std::move(res.error()));
|
return Err(std::move(res.error()));
|
||||||
|
|
||||||
char *srcfile{g_path_get_basename(src.c_str())};
|
const auto srcfile{to_string_gchar(g_path_get_basename(src.c_str()))};
|
||||||
|
|
||||||
/* create targetpath; note: make the filename *cough* unique by
|
/* create targetpath; note: make the filename *cough* unique by
|
||||||
* including a hash of the srcname in the targetname. This helps if
|
* including a hash of the srcname in the targetname. This helps if
|
||||||
|
@ -165,15 +165,13 @@ get_target_fullpath(const std::string& src, const std::string& targetpath,
|
||||||
if (unique_names)
|
if (unique_names)
|
||||||
fulltargetpath = join_paths(targetpath,
|
fulltargetpath = join_paths(targetpath,
|
||||||
in_cur ? "cur" : "new",
|
in_cur ? "cur" : "new",
|
||||||
format("%u_%s",
|
format("%08x-%s",
|
||||||
g_str_hash(src.c_str()),
|
g_str_hash(src.c_str()),
|
||||||
srcfile));
|
srcfile.c_str()));
|
||||||
else
|
else
|
||||||
fulltargetpath = join_paths(targetpath,
|
fulltargetpath = join_paths(targetpath,
|
||||||
in_cur ? "cur" : "new",
|
in_cur ? "cur" : "new",
|
||||||
srcfile);
|
srcfile.c_str());
|
||||||
g_free(srcfile);
|
|
||||||
|
|
||||||
return fulltargetpath;
|
return fulltargetpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,8 @@ black_hole(void)
|
||||||
void
|
void
|
||||||
Mu::mu_test_init(int *argc, char ***argv)
|
Mu::mu_test_init(int *argc, char ***argv)
|
||||||
{
|
{
|
||||||
|
g_setenv("MU_TEST", "yes", TRUE);
|
||||||
|
|
||||||
g_test_init(argc, argv, NULL);
|
g_test_init(argc, argv, NULL);
|
||||||
|
|
||||||
if (!g_test_verbose())
|
if (!g_test_verbose())
|
||||||
|
|
|
@ -36,7 +36,7 @@ static inline std::string test_random_tmpdir() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mu wrapper for g_test_init
|
* mu wrapper for g_test_init. Sets environment variable MU_TEST to 1.
|
||||||
*
|
*
|
||||||
* @param argc
|
* @param argc
|
||||||
* @param argv
|
* @param argv
|
||||||
|
|
|
@ -178,7 +178,11 @@ output_link(const Option<Message>& msg, const OutputInfo& info, const Options& o
|
||||||
else if (info.footer)
|
else if (info.footer)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (auto&& res = maildir_link(msg->path(), opts.find.linksdir); !res) {
|
/* during test, do not create "unique names" (i.e., names with path
|
||||||
|
* hashes), so we get a predictable result */
|
||||||
|
const auto unique_names{!g_getenv("MU_TEST")&&!g_test_initialized()};
|
||||||
|
|
||||||
|
if (auto&& res = maildir_link(msg->path(), opts.find.linksdir, unique_names); !res) {
|
||||||
res.error().fill_g_error(err);
|
res.error().fill_g_error(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue