winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 9454ff9d6f0bbbda4709cafc911275f617800e4a
parent 1113fff87e2ce41d1943918c45c291ed0f07c545
Author: JohnMcPMS <johnmcp@microsoft.com>
Date:   Wed, 29 Sep 2021 20:05:57 -0700

Fix REST tests that deadlock, logto file target, and test timeout in script (#1529)


Diffstat:
Msrc/AppInstallerCLITests/CustomHeader.cpp | 1+
Msrc/AppInstallerCLITests/Run-TestsInPackage.ps1 | 38++++++++++++++++++++++++--------------
Msrc/AppInstallerCLITests/TestRestRequestHandler.cpp | 6+++++-
Msrc/AppInstallerCLITests/main.cpp | 2+-
4 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/src/AppInstallerCLITests/CustomHeader.cpp b/src/AppInstallerCLITests/CustomHeader.cpp @@ -50,6 +50,7 @@ namespace if (!headers.has(customHeader.first) || (utility::conversions::to_utf8string(customHeader.second).compare(utility::conversions::to_utf8string(headers[customHeader.first]))) != 0) { + response.set_body(utf16string{ L"Bad Request" }); response.set_status_code(web::http::status_codes::BadRequest); return pplx::task_from_result(response); } diff --git a/src/AppInstallerCLITests/Run-TestsInPackage.ps1 b/src/AppInstallerCLITests/Run-TestsInPackage.ps1 @@ -46,8 +46,9 @@ function Wait-ForFileClose([string]$Path) { $Local:FileInfo = [System.IO.FileInfo]::new($Path) $Local:SleepCount = 0 + $Local:SleepCountMax = 600 - while ($Local:SleepCount -lt 300) + while ($Local:SleepCount -lt $Local:SleepCountMax) { try { @@ -61,6 +62,11 @@ function Wait-ForFileClose([string]$Path) $Local:SleepCount = $Local:SleepCount + 1 } } + + if ($Local:SleepCount -ge $Local:SleepCountMax) + { + throw "Timed out waiting for file close: $Path" + } } if ([String]::IsNullOrEmpty($BuildRoot)) @@ -133,19 +139,24 @@ Invoke-CommandInDesktopPackage -PackageFamilyName WinGetDevCLI_8wekyb3d8bbwe -Ap if ($ScriptWait) { - Write-Host "Waiting for output files to be closed..." - Start-Sleep 5 - if (![String]::IsNullOrEmpty($LogTarget)) + try { - Wait-ForFileClose $LogTarget - } + Write-Host "Waiting for output files to be closed..." + Start-Sleep 5 + if (![String]::IsNullOrEmpty($LogTarget)) + { + Wait-ForFileClose $LogTarget + } - if (![String]::IsNullOrEmpty($TestResultsTarget)) + if (![String]::IsNullOrEmpty($TestResultsTarget)) + { + Wait-ForFileClose $TestResultsTarget + } + Write-Host "Done" + } + finally { - Wait-ForFileClose $TestResultsTarget + Write-Host "Remove registered package" + Get-AppxPackage WinGetDevCLI | Remove-AppxPackage } - Write-Host "Done" - - Write-Host "Remove registered package" - Get-AppxPackage WinGetDevCLI | Remove-AppxPackage -}- \ No newline at end of file +} diff --git a/src/AppInstallerCLITests/TestRestRequestHandler.cpp b/src/AppInstallerCLITests/TestRestRequestHandler.cpp @@ -13,7 +13,11 @@ std::shared_ptr<TestRestRequestHandler> GetTestRestRequestHandler( pplx::task<web::http::http_response> { web::http::http_response response; - if (!sampleResponseString.empty()) + if (sampleResponseString.empty()) + { + response.set_body(utf16string{}); + } + else { response.set_body(web::json::value::parse(sampleResponseString)); } diff --git a/src/AppInstallerCLITests/main.cpp b/src/AppInstallerCLITests/main.cpp @@ -73,7 +73,7 @@ int main(int argc, char** argv) else if ("-logto"s == argv[i]) { ++i; - Logging::AddFileLogger(std::string_view{ argv[i] }); + Logging::AddFileLogger(std::filesystem::path{ argv[i] }); } else if ("-tdd"s == argv[i]) {