mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 18:43:54 -06:00
Move the AttachConsole in the feature tests in the retry loop (#17180)
These feature tests continue to plague us. Seems like the most likely outcome nowadays is that the test fails to attach immediately, so we don't even get to the retry loop. Easy enough. Let's move the AttachConsole into the loop too.
This commit is contained in:
parent
a5835b01b1
commit
015055c246
@ -237,13 +237,23 @@ MODULE_SETUP(ModuleSetup)
|
||||
// to the one that belongs to the CMD.exe in the new OpenConsole.exe window.
|
||||
VERIFY_WIN32_BOOL_SUCCEEDED_RETURN(FreeConsole());
|
||||
|
||||
VERIFY_WIN32_BOOL_SUCCEEDED_RETURN(AttachConsole(dwFindPid));
|
||||
BOOL attached = FALSE;
|
||||
|
||||
int tries = 0;
|
||||
DWORD delay;
|
||||
// This will wait for up to 32s in total (from 10ms to 163840ms)
|
||||
for (delay = 10; delay < 30000u; delay *= 2)
|
||||
{
|
||||
if (!attached)
|
||||
{
|
||||
attached = AttachConsole(dwFindPid);
|
||||
if (!attached)
|
||||
{
|
||||
WaitForSingleObject(GetCurrentThread(), delay);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tries++;
|
||||
Log::Comment(NoThrowString().Format(L"Attempt #%d to confirm we've attached", tries));
|
||||
|
||||
@ -281,6 +291,7 @@ MODULE_SETUP(ModuleSetup)
|
||||
}
|
||||
};
|
||||
|
||||
VERIFY_WIN32_BOOL_SUCCEEDED_RETURN(attached, L"Make sure successfully attached to the console");
|
||||
VERIFY_IS_LESS_THAN(delay, 30000u, L"Make sure we set up the new console in time");
|
||||
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user