Merged PR 6303540: Prepare command history before COOKED_READ in tests

[Git2Git] Merged PR 6303114: Prepare command history before COOKED_READ in tests

PR !6278637 introduced a dependency from COOKED_READ_DATA on the ability
to locate a command history for a process handle (here, `nullptr`).

The tests were blowing up because no such history had been allocated.

Closes MSFT-34812916
Closes MSFT-34813774
Closes MSFT-34815941
Closes MSFT-34817558
Closes MSFT-34817540 (Watson)

Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_wdx_dxp_windev f7517e686447fc0469f6b83df19760dc3dafd577
This commit is contained in:
Dustin Howett 2021-09-21 20:51:44 +00:00
parent 431d51de4c
commit d26353bb32
7 changed files with 36 additions and 4 deletions

View file

@ -27,6 +27,7 @@ class ApiRoutinesTests
ApiRoutines _Routines;
IApiRoutines* _pApiRoutines = &_Routines;
CommandHistory* m_pHistory;
TEST_METHOD_SETUP(MethodSetup)
{
@ -37,11 +38,20 @@ class ApiRoutinesTests
m_state->PrepareGlobalInputBuffer();
m_pHistory = CommandHistory::s_Allocate(L"cmd.exe", nullptr);
if (!m_pHistory)
{
return false;
}
// History must be prepared before COOKED_READ
return true;
}
TEST_METHOD_CLEANUP(MethodCleanup)
{
CommandHistory::s_Free(nullptr);
m_pHistory = nullptr;
m_state->CleanupGlobalInputBuffer();
m_state->CleanupGlobalScreenBuffer();

View file

@ -43,12 +43,13 @@ class CommandLineTests
m_state->PrepareGlobalScreenBuffer();
m_state->PrepareGlobalInputBuffer();
m_state->PrepareReadHandle();
m_state->PrepareCookedReadData();
m_pHistory = CommandHistory::s_Allocate(L"cmd.exe", nullptr);
if (!m_pHistory)
{
return false;
}
// History must be prepared before COOKED_READ (as it uses s_Find to get at it)
m_state->PrepareCookedReadData();
return true;
}

View file

@ -49,7 +49,6 @@ class CommandListPopupTests
m_state->PrepareGlobalScreenBuffer();
m_state->PrepareGlobalInputBuffer();
m_state->PrepareReadHandle();
m_state->PrepareCookedReadData();
m_pHistory = CommandHistory::s_Allocate(L"cmd.exe", nullptr);
// resize command history storage to 50 items so that we don't cycle on accident
// when PopupTestHelper::InitLongHistory() is called.
@ -58,6 +57,8 @@ class CommandListPopupTests
{
return false;
}
// History must be prepared before COOKED_READ (as it uses s_Find to get at it)
m_state->PrepareCookedReadData();
return true;
}

View file

@ -45,12 +45,13 @@ class CommandNumberPopupTests
m_state->PrepareGlobalScreenBuffer();
m_state->PrepareGlobalInputBuffer();
m_state->PrepareReadHandle();
m_state->PrepareCookedReadData();
m_pHistory = CommandHistory::s_Allocate(L"cmd.exe", nullptr);
if (!m_pHistory)
{
return false;
}
// History must be prepared before COOKED_READ (as it uses s_Find to get at it)
m_state->PrepareCookedReadData();
return true;
}

View file

@ -24,6 +24,7 @@ class CopyFromCharPopupTests
TEST_CLASS(CopyFromCharPopupTests);
std::unique_ptr<CommonState> m_state;
CommandHistory* m_pHistory;
TEST_CLASS_SETUP(ClassSetup)
{
@ -43,12 +44,20 @@ class CopyFromCharPopupTests
m_state->PrepareGlobalScreenBuffer();
m_state->PrepareGlobalInputBuffer();
m_state->PrepareReadHandle();
m_pHistory = CommandHistory::s_Allocate(L"cmd.exe", nullptr);
if (!m_pHistory)
{
return false;
}
// History must be prepared before COOKED_READ (as it uses s_Find to get at it)
m_state->PrepareCookedReadData();
return true;
}
TEST_METHOD_CLEANUP(MethodCleanup)
{
CommandHistory::s_Free(nullptr);
m_pHistory = nullptr;
m_state->CleanupCookedReadData();
m_state->CleanupReadHandle();
m_state->CleanupGlobalInputBuffer();

View file

@ -44,12 +44,13 @@ class CopyToCharPopupTests
m_state->PrepareGlobalScreenBuffer();
m_state->PrepareGlobalInputBuffer();
m_state->PrepareReadHandle();
m_state->PrepareCookedReadData();
m_pHistory = CommandHistory::s_Allocate(L"cmd.exe", nullptr);
if (!m_pHistory)
{
return false;
}
// History must be prepared before COOKED_READ (as it uses s_Find to get at it)
m_state->PrepareCookedReadData();
return true;
}

View file

@ -412,6 +412,7 @@ class SelectionInputTests
TEST_CLASS(SelectionInputTests);
CommonState* m_state;
CommandHistory* m_pHistory;
TEST_CLASS_SETUP(ClassSetup)
{
@ -420,12 +421,20 @@ class SelectionInputTests
m_state->PrepareGlobalFont();
m_state->PrepareGlobalScreenBuffer();
m_state->PrepareGlobalInputBuffer();
m_pHistory = CommandHistory::s_Allocate(L"cmd.exe", nullptr);
if (!m_pHistory)
{
return false;
}
// History must be prepared before COOKED_READ (as it uses s_Find to get at it)
return true;
}
TEST_CLASS_CLEANUP(ClassCleanup)
{
CommandHistory::s_Free(nullptr);
m_pHistory = nullptr;
m_state->CleanupGlobalScreenBuffer();
m_state->CleanupGlobalFont();
m_state->CleanupGlobalInputBuffer();