-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use agent's temp dir if available (#6673)
* Use agent's temp dir if available * check for path length as well * Minor fix. Added L0 tests * Move temp-path helper to common helpers * PR comments * resolve merge conflict
- Loading branch information
1 parent
4e7965f
commit d7699c0
Showing
17 changed files
with
152 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
Tasks/Common/PowershellHelpers/Tests/Get-TempDirectoryPath.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[CmdletBinding()] | ||
param() | ||
|
||
. $PSScriptRoot\..\..\..\..\Tests\lib\Initialize-Test.ps1 | ||
$module = Microsoft.PowerShell.Core\Import-Module $PSScriptRoot\.. -PassThru | ||
|
||
## test 1 | ||
Register-Mock Get-VstsTaskVariable { "C:\agent\temp" } -- -Name "agent.tempDirectory" | ||
$env:Temp = "C:\env\temp\longPath" | ||
|
||
# Act | ||
$tempDir = & $module Get-TempDirectoryPath | ||
|
||
# Assert | ||
Assert-AreEqual -Expected "C:\agent\temp" -Actual $tempDir -Message "Agent temp dir should be used if shorter than env temp" | ||
|
||
# Cleanup | ||
Unregister-Mock Get-VstsTaskVariable | ||
|
||
|
||
## test 2 | ||
Register-Mock Get-VstsTaskVariable { "C:\agent\temp\longPath" } -- -Name "agent.tempDirectory" | ||
$env:Temp = "C:\env\temp" | ||
|
||
# Act | ||
$tempDir = & $module Get-TempDirectoryPath | ||
|
||
# Assert | ||
Assert-AreEqual -Expected "C:\env\temp" -Actual $tempDir -Message "Env temp dir should be used if shorter than agent temp" | ||
|
||
# Cleanup | ||
Unregister-Mock Get-VstsTaskVariable | ||
|
||
|
||
## test 3 | ||
Register-Mock Get-VstsTaskVariable { $null } -- -Name "agent.tempDirectory" | ||
$env:Temp = "C:\env\temp\longPath" | ||
|
||
# Act | ||
$tempDir = & $module Get-TempDirectoryPath | ||
|
||
# Assert | ||
Assert-AreEqual -Expected "C:\env\temp\longPath" -Actual $tempDir -Message "Env temp dir should be used if agent version is less than 2.115.0" | ||
|
||
# Cleanup | ||
Unregister-Mock Get-VstsTaskVariable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
"version": { | ||
"Major": 1, | ||
"Minor": 7, | ||
"Patch": 2 | ||
"Patch": 3 | ||
}, | ||
"demands": [ | ||
"Cmd" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
"version": { | ||
"Major": 1, | ||
"Minor": 7, | ||
"Patch": 2 | ||
"Patch": 3 | ||
}, | ||
"demands": [ | ||
"Cmd" | ||
|
Oops, something went wrong.