Skip to content

Commit

Permalink
Fallback to and from vs 15 (#4404)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsciple authored May 25, 2017
1 parent 4452d5b commit fb7ec14
Show file tree
Hide file tree
Showing 20 changed files with 88 additions and 54 deletions.
7 changes: 0 additions & 7 deletions Tasks/Common/MSBuildHelpers/PathFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,7 @@ function Select-MSBuildPath {
return $path
}

# Do not fallback from 15.0.
if ($PreferredVersion -eq '15.0') {
Write-Error (Get-VstsLocString -Key 'MSB_MSBuild15NotFoundionArchitecture0' -ArgumentList $Architecture)
return
}

# Attempt to fallback.
$versions = $versions | Where-Object { $_ -ne '15.0' } # Fallback is only between 14.0-4.0.
Write-Verbose "Specified version '$PreferredVersion' and architecture '$Architecture' not found. Attempting to fallback."
}

Expand Down
9 changes: 6 additions & 3 deletions Tasks/Common/MSBuildHelpers/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,24 @@ describe('Common-MSBuildHelpers Suite', function () {
it('(Select-MSBuildPath) defaults method to version if no location', (done) => {
psr.run(path.join(__dirname, 'Select-MSBuildPath.DefaultsMethodToVersionIfNoLocation.ps1'), done);
})
it('(Select-MSBuildPath) does not fallback from 15', (done) => {
psr.run(path.join(__dirname, 'Select-MSBuildPath.DoesNotFallbackFrom15.ps1'), done);
})
it('(Select-MSBuildPath) errors if version not found', (done) => {
psr.run(path.join(__dirname, 'Select-MSBuildPath.ErrorsIfVersionNotFound.ps1'), done);
})
it('(Select-MSBuildPath) falls back from 14', (done) => {
psr.run(path.join(__dirname, 'Select-MSBuildPath.FallsBackFrom14.ps1'), done);
})
it('(Select-MSBuildPath) falls back from 15', (done) => {
psr.run(path.join(__dirname, 'Select-MSBuildPath.FallsBackFrom15.ps1'), done);
})
it('(Select-MSBuildPath) falls back to version if no location specified', (done) => {
psr.run(path.join(__dirname, 'Select-MSBuildPath.FallsBackToVersionIfNoLocationSpecified.ps1'), done);
})
it('(Select-MSBuildPath) falls forward from 12', (done) => {
psr.run(path.join(__dirname, 'Select-MSBuildPath.FallsForwardFrom12.ps1'), done);
})
it('(Select-MSBuildPath) falls forward from 14', (done) => {
psr.run(path.join(__dirname, 'Select-MSBuildPath.FallsForwardFrom14.ps1'), done);
})
it('(Select-MSBuildPath) returns latest version', (done) => {
psr.run(path.join(__dirname, 'Select-MSBuildPath.ReturnsLatestVersion.ps1'), done);
})
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '1

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 2
Assert-WasCalled Get-MSBuildPath -Times 3
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[cmdletbinding()]
param()

# Arrange.
. $PSScriptRoot\..\..\..\..\Tests\lib\Initialize-Test.ps1
Microsoft.PowerShell.Core\Import-Module $PSScriptRoot\..
Register-Mock Write-Warning
Register-Mock Get-MSBuildPath { 'Some resolved location' } -- -Version '14.0' -Architecture 'Some architecture'

# Act.
$actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '15.0' -Architecture 'Some architecture'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 2
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '1

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 2
Assert-WasCalled Get-MSBuildPath -Times 3
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[cmdletbinding()]
param()

# Arrange.
. $PSScriptRoot\..\..\..\..\Tests\lib\Initialize-Test.ps1
Microsoft.PowerShell.Core\Import-Module $PSScriptRoot\..
Register-Mock Write-Warning
Register-Mock Get-MSBuildPath { 'Some resolved location' } -- -Version '15.0' -Architecture 'Some architecture'

# Act.
$actual = Select-MSBuildPath -Method 'Version' -Location '' -PreferredVersion '14.0' -Architecture 'Some architecture'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-MSBuildPath -Times 2
Assert-AreEqual -Expected 'Some resolved location' -Actual $actual
4 changes: 2 additions & 2 deletions Tasks/MSBuild/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 117,
"Patch": 1
"Minor": 118,
"Patch": 0
},
"demands": [
"msbuild"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/MSBuild/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 117,
"Patch": 1
"Minor": 118,
"Patch": 0
},
"demands": [
"msbuild"
Expand Down
6 changes: 0 additions & 6 deletions Tasks/VSBuild/Select-VSVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ function Select-VSVersion {
return $PreferredVersion
}

# Error. Do not fallback from 15.0.
if ($PreferredVersion -eq '15.0') {
throw (Get-VstsLocString -Key 'VSVersion15NotFound' -ArgumentList $PreferredVersion)
}

# Attempt to fallback.
$versions = $versions | Where-Object { $_ -ne '15.0' } # Fallback is only between 14.0-10.0.
Write-Verbose "Version '$PreferredVersion' not found. Looking for fallback version."
}

Expand Down
9 changes: 6 additions & 3 deletions Tasks/VSBuild/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ describe('VSBuild Suite', function () {
});

if (psm.testSupported()) {
it('(Select-VSVersion) errors if 15 not found', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.ErrorsIf15NotFound.ps1'), done);
})
it('(Select-VSVersion) falls back from 14', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom14.ps1'), done);
})
it('(Select-VSVersion) falls back from 15', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FallsBackFrom15.ps1'), done);
})
it('(Select-VSVersion) falls forward from 12', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom12.ps1'), done);
})
it('(Select-VSVersion) falls forward from 14', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FallsForwardFrom14.ps1'), done);
})
it('(Select-VSVersion) finds latest', (done) => {
psr.run(path.join(__dirname, 'Select-VSVersion.FindsLatest.ps1'), done);
})
Expand Down
11 changes: 0 additions & 11 deletions Tasks/VSBuild/Tests/Select-VSVersion.ErrorsIf15NotFound.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion Tasks/VSBuild/Tests/Select-VSVersion.FallsBackFrom14.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-VSVersion -PreferredVersion '14.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 2
Assert-WasCalled Get-VSPath -Times 3
Assert-AreEqual -Expected '12.0' -Actual $actual
16 changes: 16 additions & 0 deletions Tasks/VSBuild/Tests/Select-VSVersion.FallsBackFrom15.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[CmdletBinding()]
param()

# Arrange.
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1
. $PSScriptRoot\..\Select-VSVersion.ps1
Register-Mock Write-Warning
Register-Mock Get-VSPath { "Some resolved location" } -- -Version '14.0'

# Act.
$actual = Select-VSVersion -PreferredVersion '15.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 2
Assert-AreEqual -Expected '14.0' -Actual $actual
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ $actual = Select-VSVersion -PreferredVersion '12.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 2
Assert-WasCalled Get-VSPath -Times 3
Assert-AreEqual -Expected '14.0' -Actual $actual
16 changes: 16 additions & 0 deletions Tasks/VSBuild/Tests/Select-VSVersion.FallsForwardFrom14.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[CmdletBinding()]
param()

# Arrange.
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1
. $PSScriptRoot\..\Select-VSVersion.ps1
Register-Mock Write-Warning
Register-Mock Get-VSPath { "Some resolved location" } -- -Version '15.0'

# Act.
$actual = Select-VSVersion -PreferredVersion '14.0'

# Assert.
Assert-WasCalled Write-Warning
Assert-WasCalled Get-VSPath -Times 2
Assert-AreEqual -Expected '15.0' -Actual $actual
2 changes: 1 addition & 1 deletion Tasks/VSBuild/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 117,
"Minor": 118,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/VSBuild/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 117,
"Minor": 118,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamarinAndroid/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 117,
"Minor": 118,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamarinAndroid/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 117,
"Minor": 118,
"Patch": 0
},
"demands": [
Expand Down

0 comments on commit fb7ec14

Please sign in to comment.