test-updater.py: include space and unicode in paths to test

This commit is contained in:
Shawn Hoffman 2023-03-22 11:06:30 -07:00
parent 66e414133e
commit fdc1626308
2 changed files with 10 additions and 9 deletions

View File

@ -17,6 +17,7 @@
#include "Common/CommonPaths.h" #include "Common/CommonPaths.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/HttpRequest.h" #include "Common/HttpRequest.h"
#include "Common/IOFile.h"
#include "Common/ScopeGuard.h" #include "Common/ScopeGuard.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "UpdaterCommon/Platform.h" #include "UpdaterCommon/Platform.h"
@ -44,15 +45,15 @@ const std::array<u8, 32> UPDATE_PUB_KEY_TEST = {
0x9e, 0xe0, 0x9b, 0x28, 0xc9, 0x1a, 0x60, 0xb7, 0x67, 0x1c, 0xf3, 0xf6, 0xca, 0x1b, 0xdd, 0x1a}; 0x9e, 0xe0, 0x9b, 0x28, 0xc9, 0x1a, 0x60, 0xb7, 0x67, 0x1c, 0xf3, 0xf6, 0xca, 0x1b, 0xdd, 0x1a};
// Where to log updater output. // Where to log updater output.
static FILE* log_fp = stderr; static File::IOFile log_file;
void LogToFile(const char* fmt, ...) void LogToFile(const char* fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
vfprintf(log_fp, fmt, args); log_file.WriteString(StringFromFormatV(fmt, args));
fflush(log_fp); log_file.Flush();
va_end(args); va_end(args);
} }
@ -174,8 +175,8 @@ bool VerifySignature(const std::string& data, const std::string& b64_signature)
void FlushLog() void FlushLog()
{ {
fflush(log_fp); log_file.Flush();
fclose(log_fp); log_file.Close();
} }
void TodoList::Log() const void TodoList::Log() const
@ -698,9 +699,8 @@ bool RunUpdater(std::vector<std::string> args)
if (opts.log_file) if (opts.log_file)
{ {
log_fp = fopen(opts.log_file.value().c_str(), "w"); if (!log_file.Open(opts.log_file.value(), "w"))
if (!log_fp) log_file.SetHandle(stderr);
log_fp = stderr;
else else
atexit(FlushLog); atexit(FlushLog);
} }

View File

@ -123,7 +123,7 @@ if __name__ == "__main__":
threading.Thread(target=http_server, daemon=True).start() threading.Thread(target=http_server, daemon=True).start()
with tempfile.TemporaryDirectory() as tmp_dir: with tempfile.TemporaryDirectory(suffix=" ¿ 😎") as tmp_dir:
tmp_dir = Path(tmp_dir) tmp_dir = Path(tmp_dir)
tmp_dolphin = tmp_dir.joinpath("dolphin") tmp_dolphin = tmp_dir.joinpath("dolphin")
@ -143,6 +143,7 @@ if __name__ == "__main__":
# XXX copies from just-created dir so Dolphin.ini is kept # XXX copies from just-created dir so Dolphin.ini is kept
shutil.copytree(tmp_dolphin, tmp_dolphin_next) shutil.copytree(tmp_dolphin, tmp_dolphin_next)
tmp_dolphin_next.joinpath("updater-test-file").write_text("test") tmp_dolphin_next.joinpath("updater-test-file").write_text("test")
tmp_dolphin_next.joinpath("updater-test-filἑ").write_text("test")
with tmp_dolphin_next.joinpath("build_info.txt").open("a") as f: with tmp_dolphin_next.joinpath("build_info.txt").open("a") as f:
print("test", file=f) print("test", file=f)
for ext in ("exe", "dll"): for ext in ("exe", "dll"):