Skip to content

Commit

Permalink
Fix REST tests that deadlock, logto file target, and test timeout in …
Browse files Browse the repository at this point in the history
…script (#1529)
  • Loading branch information
JohnMcPMS authored Sep 30, 2021
1 parent 1113fff commit 9454ff9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/AppInstallerCLITests/CustomHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
37 changes: 24 additions & 13 deletions src/AppInstallerCLITests/Run-TestsInPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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))
Expand Down Expand Up @@ -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
}
}
6 changes: 5 additions & 1 deletion src/AppInstallerCLITests/TestRestRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLITests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down

0 comments on commit 9454ff9

Please sign in to comment.