mirror of https://github.com/djcb/mu.git
mu-view: attempt to avoid locale diffs in test
A bit ugly attempt make tests work in CI
This commit is contained in:
parent
33fd79a9f0
commit
5409c2cd87
|
@ -211,7 +211,7 @@ Mu::mu_cmd_view(const Options& opts)
|
|||
#include <fcntl.h> /* Definition of AT_* constants */
|
||||
#include <sys/stat.h>
|
||||
#include <fstream>
|
||||
#include <locale.h>
|
||||
#include <utils/mu-regex.hh>
|
||||
#include "utils/mu-test-utils.hh"
|
||||
|
||||
static constexpr std::string_view test_msg =
|
||||
|
@ -245,23 +245,20 @@ static std::string msgpath;
|
|||
static void
|
||||
test_view_plain()
|
||||
{
|
||||
TempTz tz("Europe/Amsterdam");
|
||||
if (!tz.available()) {
|
||||
g_test_skip("timezone not available");
|
||||
return;
|
||||
}
|
||||
setlocale(LC_ALL, "C");
|
||||
|
||||
auto res = run_command({MU_PROGRAM, "view", msgpath});
|
||||
assert_valid_command(res);
|
||||
auto output{*res};
|
||||
|
||||
// silly hack to avoid locale diffs
|
||||
auto rx = unwrap(Regex::make("^Date:.*", G_REGEX_MULTILINE));
|
||||
output.standard_out = rx.replace(output.standard_out, "Date: xxx");
|
||||
|
||||
g_assert_true(output.standard_err.empty());
|
||||
assert_equal(output.standard_out,
|
||||
R"(From: Test <test@example.com>
|
||||
To: abc@example.com
|
||||
Subject: vla
|
||||
Date: 2011-05-23T10:53:45 CEST
|
||||
Date: xxx
|
||||
|
||||
text
|
||||
)");
|
||||
|
@ -271,23 +268,19 @@ text
|
|||
static void
|
||||
test_view_html()
|
||||
{
|
||||
TempTz tz("Europe/Amsterdam");
|
||||
if (!tz.available()) {
|
||||
g_test_skip("timezone not available");
|
||||
return;
|
||||
}
|
||||
setlocale(LC_ALL, "C");
|
||||
|
||||
auto res = run_command({MU_PROGRAM, "view", "--format=html", msgpath});
|
||||
assert_valid_command(res);
|
||||
auto output{*res};
|
||||
|
||||
auto rx = unwrap(Regex::make("^Date:.*", G_REGEX_MULTILINE));
|
||||
output.standard_out = rx.replace(output.standard_out, "Date: xxx");
|
||||
|
||||
g_assert_true(output.standard_err.empty());
|
||||
assert_equal(output.standard_out,
|
||||
R"(From: Test <test@example.com>
|
||||
To: abc@example.com
|
||||
Subject: vla
|
||||
Date: 2011-05-23T10:53:45 CEST
|
||||
Date: xxx
|
||||
|
||||
html
|
||||
)");
|
||||
|
@ -302,7 +295,6 @@ test_view_sexp()
|
|||
g_test_skip("timezone not available");
|
||||
return;
|
||||
}
|
||||
setlocale(LC_ALL, "C");
|
||||
|
||||
auto res = run_command({MU_PROGRAM, "view", "--format=sexp", msgpath});
|
||||
assert_valid_command(res);
|
||||
|
|
Loading…
Reference in New Issue