Files
Packer-Cn/provisioner/powershell/test-fixtures/powershell-exit_codes-provisioner.txt
Karthik P 089df02532 Powershell Provisioner Error Handling (#13334)
* WIP Testing Approach

* WIP Testing Approach

* WIP Testing Approach Work

* WIP Testing Approach

* adding acceptance test for windows Amazon EBS.

* modify wrapper string to use Set-Variable

* fixing unit tests

* cleanup

* updated approach to use -file instead of inline powershell execution.

* adding more scenarios for acceptance test.

* using writeString for file directly.

* changing variable name

* updating test case. cleanup.

* updating test case

* updating test case

* updating test case - nested try catch

* adding unit test for None Execution Policy

* adding unit test for None Execution Policy

* fix test case
2025-04-25 11:23:32 +05:30

77 lines
1.6 KiB
Plaintext

{
"type": "powershell",
"inline": ["invalid-cmdlet"],
"valid_exit_codes": ["1"]
},
{
"type": "powershell",
"inline": ["#Requires -Version 10.0"],
"valid_exit_codes": ["1"]
},
{
"type": "powershell",
"inline": ["exit 1"],
"valid_exit_codes": ["1"]
},
{
"type": "powershell",
"inline": ["}}"],
"valid_exit_codes": ["1"]
},
{
"type": "powershell",
"inline": ["$LASTEXITCODE=1"],
"valid_exit_codes": ["1"]
},
{
"type": "powershell",
"inline": ["throw 'XXX'"],
"valid_exit_codes": ["1"]
},
{
"type": "powershell",
"script": "../../provisioner/powershell/test-fixtures/scripts/set_version_latest.ps1",
"valid_exit_codes": ["0"]
},
{
"type": "powershell",
"elevated_user": "Administrator",
"elevated_password": "{{.WinRMPassword}}",
"inline": "Get-ItemProperty -Path HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
"valid_exit_codes": ["0"]
},
{
"type": "powershell",
"inline": "ping invalidhost",
"valid_exit_codes": ["1"]
},
{
"type": "powershell",
"inline": "sc.exe start command",
"valid_exit_codes": ["1060"]
},
{
"type": "powershell",
"inline": "echo 'Hi testing echo'; invalid command!; echo 'Another valid command';",
"valid_exit_codes": ["1"]
},
{
"type": "powershell",
"inline": ["$ErrorActionPreference='Stop'", "Get-Item 'C:\\nonexistent.txt'"],
"valid_exit_codes": ["1"]
},
{
"type": "powershell",
"inline": [
"try {",
" invalid command",
"} catch {",
" exit 1",
"}"
],
"valid_exit_codes": ["1"]
}