@samitouri / QOSAMI-WSL / commits / bba5af9a

Fix the 'WriteWslConfig' test case to reset .wslconfig when done (#13305)

* Save state * Fix the tests

Blue committed Jul 29, 2025 at 15:35 UTC bba5af9aea744f93981b3998fed4cdb7231dbdef
1 file changed +2 -9
test/windows/UnitTests.cpp
+2 -9
@@ -2942,20 +2942,13 @@ Error code: Wsl/InstallDistro/WSL_E_DISTRO_NOT_FOUND
2942 LxssDynamicFunction<decltype(GetWslConfigSetting)> getWslConfigSetting(libWslDllPath.c_str(), "GetWslConfigSetting");
2943 LxssDynamicFunction<decltype(SetWslConfigSetting)> setWslConfigSetting(libWslDllPath.c_str(), "SetWslConfigSetting");
2944
2945 - // Delete the test config file. The original has already been saved as part of module setup.
2945 + // Reset the test config file. The original has already been saved as part of module setup.
2946 auto wslConfigFilePath = getenv("userprofile") + std::string("\\.wslconfig");
2947 - if (std::filesystem::exists(wslConfigFilePath))
2948 - {
2949 - std::error_code ec{};
2950 - VERIFY_IS_TRUE(std::filesystem::remove(wslConfigFilePath, ec));
2951 - }
2947 + WslConfigChange config{L""};
2948
2949 auto apiWslConfigFilePath = getWslConfigFilePath();
2950 VERIFY_IS_TRUE(std::filesystem::path(wslConfigFilePath) == std::filesystem::path(apiWslConfigFilePath));
2951
2956 - // Cleanup any leftover config files.
2957 - auto cleanup = wil::scope_exit([apiWslConfigFilePath] { std::filesystem::remove(apiWslConfigFilePath); });
2958 -
2952 auto wslConfigDefaults = createWslConfig(nullptr);
2953 VERIFY_IS_NOT_NULL(wslConfigDefaults);
2954 auto wslConfig = createWslConfig(apiWslConfigFilePath);