From fdc16263089ef2fb93a102c39cc9926ca1f91667 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 22 Mar 2023 11:06:30 -0700 Subject: [PATCH] test-updater.py: include space and unicode in paths to test --- Source/Core/UpdaterCommon/UpdaterCommon.cpp | 16 ++++++++-------- Tools/test-updater.py | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/Core/UpdaterCommon/UpdaterCommon.cpp b/Source/Core/UpdaterCommon/UpdaterCommon.cpp index 426943ce83..408c313c95 100644 --- a/Source/Core/UpdaterCommon/UpdaterCommon.cpp +++ b/Source/Core/UpdaterCommon/UpdaterCommon.cpp @@ -17,6 +17,7 @@ #include "Common/CommonPaths.h" #include "Common/FileUtil.h" #include "Common/HttpRequest.h" +#include "Common/IOFile.h" #include "Common/ScopeGuard.h" #include "Common/StringUtil.h" #include "UpdaterCommon/Platform.h" @@ -44,15 +45,15 @@ const std::array UPDATE_PUB_KEY_TEST = { 0x9e, 0xe0, 0x9b, 0x28, 0xc9, 0x1a, 0x60, 0xb7, 0x67, 0x1c, 0xf3, 0xf6, 0xca, 0x1b, 0xdd, 0x1a}; // Where to log updater output. -static FILE* log_fp = stderr; +static File::IOFile log_file; void LogToFile(const char* fmt, ...) { va_list args; va_start(args, fmt); - vfprintf(log_fp, fmt, args); - fflush(log_fp); + log_file.WriteString(StringFromFormatV(fmt, args)); + log_file.Flush(); va_end(args); } @@ -174,8 +175,8 @@ bool VerifySignature(const std::string& data, const std::string& b64_signature) void FlushLog() { - fflush(log_fp); - fclose(log_fp); + log_file.Flush(); + log_file.Close(); } void TodoList::Log() const @@ -698,9 +699,8 @@ bool RunUpdater(std::vector args) if (opts.log_file) { - log_fp = fopen(opts.log_file.value().c_str(), "w"); - if (!log_fp) - log_fp = stderr; + if (!log_file.Open(opts.log_file.value(), "w")) + log_file.SetHandle(stderr); else atexit(FlushLog); } diff --git a/Tools/test-updater.py b/Tools/test-updater.py index 4cb5d07d46..c4af196fc2 100644 --- a/Tools/test-updater.py +++ b/Tools/test-updater.py @@ -123,7 +123,7 @@ if __name__ == "__main__": 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_dolphin = tmp_dir.joinpath("dolphin") @@ -143,6 +143,7 @@ if __name__ == "__main__": # XXX copies from just-created dir so Dolphin.ini is kept shutil.copytree(tmp_dolphin, tmp_dolphin_next) 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: print("test", file=f) for ext in ("exe", "dll"):