OSDN Git Service

GUITest: Find the latest installer and use it for testing.
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 10 Jan 2021 22:45:54 +0000 (07:45 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 10 Jan 2021 22:45:54 +0000 (07:45 +0900)
Testing/GoogleTest/GUITests/GUITestUtils.cpp
Testing/GoogleTest/GUITests/pch.h

index 4880beb..70b5b05 100644 (file)
@@ -172,7 +172,21 @@ std::filesystem::path getInstallerPath()
                if (pos != std::wstring::npos)\r
                        return argstr.substr(pos + std::size("--installerpath=") - 1);\r
        }\r
-       return "../../../Build/WinMerge-2.16.8-x64-PerUser-Setup.exe";\r
+       std::regex re{ "WinMerge-.*-x64-PerUser-Setup.exe" };\r
+       std::filesystem::path path;\r
+       std::filesystem::file_time_type time;\r
+       for (auto& ent : std::filesystem::directory_iterator("../../../Build"))\r
+       {\r
+               if (std::regex_match(ent.path().filename().string(), re))\r
+               {\r
+                       if (time < ent.last_write_time())\r
+                       {\r
+                               time = ent.last_write_time();\r
+                               path = ent.path();\r
+                       }\r
+               }\r
+       }\r
+       return path;\r
 }\r
 \r
 HWND execWinMerge(const std::string& args)\r
index 31fe514..709ed89 100644 (file)
@@ -15,6 +15,7 @@
 #include <cassert>\r
 #include <ctime>\r
 #include <filesystem>\r
+#include <regex>\r
 #include <tchar.h>\r
 #include <gtest/gtest.h>\r
 #include <gtest/gtest-param-test.h>\r