Skip to content

Improved reliability of some tests - #4686

Merged
Dongbo Wang (daxian-dbw) merged 4 commits into
PowerShell:masterfrom
springcomp:reliability/tests
Apr 17, 2025
Merged

Improved reliability of some tests#4686
Dongbo Wang (daxian-dbw) merged 4 commits into
PowerShell:masterfrom
springcomp:reliability/tests

Conversation

@springcomp

@springcompMaxime Labelle (springcomp) commented Apr 2, 2025

Copy link
Copy Markdown
Contributor

PR Summary

TL;DR;

This pull request suggests an improvement to the TestSetup() method to initialize some data members that are used in some tests that would otherwise fail.

Summary

Some tests around history, prediction and suggestion – are failing on the local machine due to the PSConsoleReadLine._history member not being initialized.

This member is initialized the first time the PSConsoleReadLine.ReadLine() method is called, which happens in the Test method overloads.

However, some tests perform actions between the TestSetup() and the Test() methods. For instance, the following test fails because the _history member is not initialized:

List_RenderSuggestion_UpdatesWhileTyping:

[SkippableFact]publicvoidList_RenderSuggestion_ListUpdatesWhileTyping(){TestSetup(KeyMode.Cmd);intlistWidth=CheckWindowSize();// The font effect sequences of the dimmed color used in list view metadata line// are ignored in the mock console, so only the white color will be left.vardimmedColors=Tuple.Create(ConsoleColor.White,_console.BackgroundColor);varemphasisColors=Tuple.Create(PSConsoleReadLineOptions.DefaultEmphasisColor,_console.BackgroundColor);usingvardisp=SetPrediction(PredictionSource.History,PredictionViewStyle.ListView);// Different matches as more input comingSetHistory("echo -bar","eca -zoo");// ** THIS CALL FAILS BECAUSE _history IS NOT INITIALIZEDTest("ech",Keys(

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure you've added one or more new tests (Not Applicable)
  • Make sure you've tested these changes in terminals that PowerShell is commonly used in (i.e. conhost.exe, Windows Terminal, Visual Studio Code Integrated Terminal, etc.)
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed at PowerShell-Docs
      • Doc Issue filed:
Microsoft Reviewers: Open in CodeFlow

Comment threadtest/UnitTestReadLine.cs Outdated
Comment threadPSReadLine/PSReadLine.sln Outdated
Comment threadPSReadLine/PSReadLine.sln Outdated
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit b1f8c89 into PowerShell:masterApr 17, 2025
@springcomp
Maxime Labelle (springcomp) deleted the reliability/tests branch April 18, 2025 05:28
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@springcomp@daxian-dbw@StevenBucher98