Skip to content

Update smoke test script to support different PowerShell version #17579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2022

Conversation

dingmeng-xue
Copy link
Member

Description

  • Change script block and parameterize:
    • Retry and Sleep
    • Since: version of PowerShell with .NET Core
  • Append ErrorActionPreference rather than adding it to each script block

Checklist

  • I have read the Submitting Changes section of CONTRIBUTING.md
  • The title of the PR is clear and informative
  • The appropriate ChangeLog.md file(s) has been updated:
    • For any service, the ChangeLog.md file can be found at src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
    • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header -- no new version header should be added
  • The PR does not introduce breaking changes
  • If applicable, the changes made in the PR have proper test coverage
  • For public API changes to cmdlets:
    • a cmdlet design review was approved for the changes in this repository (Microsoft internal only)
      • {Please put the link here}
    • the markdown help files have been regenerated using the commands listed here

lijinpei2008
lijinpei2008 previously approved these changes Mar 24, 2022
Copy link
Contributor

@lijinpei2008 lijinpei2008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script works well in local environments including PowerShell Core and Windows PowerShell

Comment on lines 177 to 178
if($null -ne $_.Since -and "Core" -eq $PSVersionTable.PSEdition) {
if($PSVersionTable.PSVersion -lt [System.Version]$_.Since) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if($null -ne $_.Since -and "Core" -eq $PSVersionTable.PSEdition) {
if($PSVersionTable.PSVersion -lt [System.Version]$_.Since) {
if($null -ne $_.Since -and "Core" -eq $PSVersionTable.PSEdition -and $PSVersionTable.PSVersion -lt [System.Version]$_.Since) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged them into one line.

Comment on lines 188 to 189
Retry-AzCommand -Name $testName -Command $script -Retry $retry -Sleep $sleep
$testInfo.PassedCount += 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Retry-AzCommand -Name $testName -Command $script -Retry $retry -Sleep $sleep
$testInfo.PassedCount += 1
Retry-AzCommand -Name $testName -Command $script -Retry $retry -Sleep $sleep
$testInfo.PassedCount += 1

Add a space to keep same indent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code. The problem indeed is indent of other lines is incorrect.

LucasYao93
LucasYao93 previously approved these changes Mar 24, 2022
@LucasYao93
Copy link
Contributor

The script works well in local environments.

Platform Version Status
Powershell 7.1.4 Pass
Winows Powershell 5.1.22000.282 Pass

Copy link
Contributor

@BethanyZhou BethanyZhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@BethanyZhou BethanyZhou merged commit 69fe9d3 into main Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants