Skip to content

Commit 67ee24d

Browse files
committed
Add logging and correct some ps1 scripts to be cross-platform compatible
1 parent 18edac3 commit 67ee24d

File tree

5 files changed

+54
-14
lines changed

5 files changed

+54
-14
lines changed

build.proj

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@
378378
<PropertyGroup Condition="'$(ExcludeAuthenticators)' == 'true'">
379379
<AuthenticatorExclusions>$(LibraryRoot)src/**/Authenticators.csproj;</AuthenticatorExclusions>
380380
</PropertyGroup>
381+
<PropertyGroup Condition="'$(Framework)' == ''">
382+
<Framework>netcoreapp2.0</Framework>
383+
</PropertyGroup>
381384

382385
<CallTarget Targets="BinScopeCheck" Condition="'$(OnPremiseBuild)'" />
383386
<CallTarget Targets="RunPoliCheck" Condition="'$(OnPremiseBuild)'" />
@@ -397,7 +400,7 @@
397400
<Exec Command="dotnet sln Azure.PowerShell.sln add $(LibraryRoot)tools/ScenarioTest.ResourceManager/ScenarioTest.ResourceManager.csproj $(LibraryRoot)tools/TestFx/TestFx.csproj" />
398401
<!-- https://github.com/Microsoft/msbuild/issues/3157#issuecomment-378002971 -->
399402
<!-- https://github.com/xunit/xunit/issues/1154#issuecomment-405366373 -->
400-
<Exec Command="dotnet test Azure.PowerShell.sln --filter &quot;AcceptanceType=CheckIn%26RunType!=DesktopOnly&quot; --configuration $(Configuration) --framework netcoreapp2.0 --logger trx" />
403+
<Exec Command="dotnet test Azure.PowerShell.sln --filter &quot;AcceptanceType=CheckIn%26RunType!=DesktopOnly&quot; --configuration $(Configuration) --framework $(Framework) --logger trx" />
401404

402405
<ItemGroup>
403406
<TestResults Include="$(LibraryRoot)src/**/TestResults/*.trx" />
@@ -407,6 +410,34 @@
407410
<OnError ExecuteTargets="TestFailureErrorMessage" />
408411
</Target>
409412

413+
<Target Name="TestNet472">
414+
<Message Importance="high" Text="Running check in tests..." />
415+
<PropertyGroup>
416+
<AuthExclusions>$(LibraryRoot)src/**/Authenticators.csproj;</AuthExclusions>
417+
<AutomationExclusions>$(LibraryRoot)src/**/Automation.Test.csproj;</AutomationExclusions>
418+
<StorageExclusions>$(LibraryRoot)src/**/Storage.Test.csproj;</StorageExclusions>
419+
</PropertyGroup>
420+
421+
<MakeDir Directories="$(TestOutputDirectory)" ContinueOnError="false" />
422+
<Exec Command="dotnet new sln -n Azure.PowerShell --force" />
423+
<ItemGroup>
424+
<ModuleCsprojFiles Include="$(LibraryRoot)src/**/*.csproj" Exclude="$(AuthExclusions);$(AutomationExclusions);$(StorageExclusions)"/>
425+
</ItemGroup>
426+
<!-- https://stackoverflow.com/a/35477012/294804 -->
427+
<ItemGroup>
428+
<ModuleCsprojFilesRelative Include="@(ModuleCsprojFiles)">
429+
<RelativePath>$([MSBuild]::MakeRelative($(LibraryRoot), %(ModuleCsprojFiles.FullPath)))</RelativePath>
430+
</ModuleCsprojFilesRelative>
431+
</ItemGroup>
432+
<Exec Command="dotnet sln Azure.PowerShell.sln add @(ModuleCsprojFilesRelative->'%(RelativePath)', ' ')" />
433+
<Exec Command="dotnet sln Azure.PowerShell.sln add $(LibraryRoot)tools/ScenarioTest.ResourceManager/ScenarioTest.ResourceManager.csproj $(LibraryRoot)tools/TestFx/TestFx.csproj" />
434+
<!-- https://github.com/Microsoft/msbuild/issues/3157#issuecomment-378002971 -->
435+
<!-- https://github.com/xunit/xunit/issues/1154#issuecomment-405366373 -->
436+
<Exec Command="dotnet build Azure.PowerShell.sln --configuration $(Configuration) --framework netstandard2.0" />
437+
438+
<OnError ExecuteTargets="TestFailureErrorMessage" />
439+
</Target>
440+
410441
<Target Name="TestFailureErrorMessage">
411442
<Error Text="Test failures occured, check the files in artifacts/Test" />
412443
</Target>

src/ApiManagement/ApiManagement.ServiceManagement.Test/ScenarioTests/ApiManagementTests.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function Api-ImportExportWadlTest {
164164

165165
$context = New-AzApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName
166166

167-
$wadlPath = Join-Path "$TestOutputRoot" "Resources" "WADLYahoo.xml"
167+
$wadlPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "WADLYahoo.xml"
168168
$path = "wadlapi"
169169
$wadlApiId = getAssetName
170170

@@ -198,7 +198,7 @@ function Api-ImportExportSwaggerTest {
198198

199199
$context = New-AzApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName
200200

201-
$swaggerPath = Join-Path "$TestOutputRoot" "Resources" "SwaggerPetStoreV2.json"
201+
$swaggerPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "SwaggerPetStoreV2.json"
202202
$swaggerUrl = "http://petstore.swagger.io/v2/swagger.json"
203203
$path1 = "swaggerapifromFile"
204204
$path2 = "swaggerapifromUrl"
@@ -254,7 +254,7 @@ function Api-ImportExportWsdlTest {
254254

255255
$context = New-AzApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName
256256
$wsdlUrl = "http://fazioapisoap.azurewebsites.net/fazioService.svc?singleWSDL"
257-
$wsdlPath1 = Join-Path "$TestOutputRoot" "Resources" "Weather.wsdl"
257+
$wsdlPath1 = Join-Path (Join-Path "$TestOutputRoot" "Resources") "Weather.wsdl"
258258
$path1 = "soapapifromFile"
259259
$path2 = "soapapifromUrl"
260260
$wsdlApiId1 = getAssetName
@@ -1091,10 +1091,10 @@ function Policy-CrudTest {
10911091

10921092
# load from file get to pipeline scenarios
10931093

1094-
$tenantValidPath = Join-Path "$TestOutputRoot" "Resources" "TenantValidPolicy.xml"
1095-
$productValidPath = Join-Path "$TestOutputRoot" "Resources" "ProductValidPolicy.xml"
1096-
$apiValidPath = Join-Path "$TestOutputRoot" "Resources" "ApiValidPolicy.xml"
1097-
$operationValidPath = Join-Path "$TestOutputRoot" "Resources" "OperationValidPolicy.xml"
1094+
$tenantValidPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "TenantValidPolicy.xml"
1095+
$productValidPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "ProductValidPolicy.xml"
1096+
$apiValidPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "ApiValidPolicy.xml"
1097+
$operationValidPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "OperationValidPolicy.xml"
10981098

10991099
$context = New-AzApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName
11001100

@@ -1285,7 +1285,7 @@ function Certificate-CrudTest {
12851285

12861286
Assert-AreEqual 0 $certificates.Count
12871287

1288-
$certPath = Join-Path "$TestOutputRoot" "Resources" "powershelltest.pfx"
1288+
$certPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "powershelltest.pfx"
12891289
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
12901290
$certPassword = 'Password'
12911291
$certSubject = "CN=*.msitesting.net"
@@ -2122,7 +2122,7 @@ function BackendServiceFabric-CrudTest {
21222122

21232123
# create certificate
21242124
$certId = getAssetName
2125-
$certPath = Join-Path "$TestOutputRoot" "Resources" "powershelltest.pfx"
2125+
$certPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "powershelltest.pfx"
21262126
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
21272127
$certPassword = 'Password'
21282128
$certSubject = "CN=*.msitesting.net"
@@ -2299,7 +2299,7 @@ function ApiRevision-CrudTest {
22992299

23002300
$context = New-AzApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName
23012301

2302-
$swaggerPath = Join-Path "$TestOutputRoot" "Resources" "SwaggerPetStoreV2.json"
2302+
$swaggerPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "SwaggerPetStoreV2.json"
23032303
$path1 = "swaggerapifromFile"
23042304
$swaggerApiId1 = getAssetName
23052305
$apiRevisionId = "2"

src/ServiceFabric/ServiceFabric.Test/ScenarioTests/TestServiceFabric.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,13 @@ function Test-AddAzureRmServiceFabricApplicationCertificateRollback
317317
}
318318
Catch [System.Exception]
319319
{
320-
Assert-AreEqual $true ($PSItem.Exception.Message -match 'is different from the location of the VM') "unexpected error message: $($PSItem.Exception.Message)"
320+
$Exception = $PSitem.Exception
321+
while ($Exception.InnerException -ne $null)
322+
{
323+
$Exception = $Exception.InnerException
324+
}
325+
326+
Assert-AreEqual $true ($Exception.Message -match 'is different from the location of the VM') ("unexpected error message: " + $Exception.Message )
321327
$exceptionThrown = $true
322328
}
323329

src/Websites/Websites.Test/ScenarioTests/Common.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# ----------------------------------------------------------------------------------
1414

1515
$TestOutputRoot = [System.AppDomain]::CurrentDomain.BaseDirectory;
16-
$ResourcesPath = Join-Path $TestOutputRoot "ScenarioTests" "Resources"
16+
$ResourcesPath = Join-Path (Join-Path $TestOutputRoot "ScenarioTests") "Resources"
1717

1818
<#
1919
.SYNOPSIS

tools/TestNet472Modules.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ param(
88
)
99

1010
$dirPath = (Join-Path $PSScriptRoot -ChildPath '..')
11+
$artPath = (Join-Path $dirPath 'artifacts')
1112
$srcPath = (Join-Path $dirPath -ChildPath 'src')
1213
$libPath = (Join-Path $srcPath -ChildPath 'lib')
1314
$testConfig = (Join-Path $libPath -ChildPath 'test.net472.config')
@@ -26,14 +27,16 @@ $rmItems | %{`
2627
$testExecDir = $testExec.Directory.FullName
2728
$testExecFile = $testExec.Name
2829
$newExecPath = Join-Path $testDir -ChildPath $testExecFile
30+
$logFile = $_.Name -replace '.dll', '.log.xml'
31+
$logPath = (Join-Path $artPath $logFile)
2932
$copiedItems = (Get-ChildItem $testExecDir | Where-Object {$_.Name.StartsWith("xunit")})
3033
$copiedItems | Copy-Item -Destination $testDir
3134
try {
3235
Start-Process -FilePath $newExecPath `
3336
-Wait `
3437
-WorkingDirectory $testDir `
3538
-NoNewWindow `
36-
-ArgumentList $_.FullName, $testConfig, '-trait "AcceptanceType=CheckIn"', '-notrait "Runtype=DesktopOnly"'`
39+
-ArgumentList $_.FullName, $testConfig, '-trait "AcceptanceType=CheckIn"', '-notrait "Runtype=DesktopOnly"', "-xml $logPath" `
3740
}
3841
finally {
3942
$copiedItems | %{Remove-Item -Force (Join-Path $testDir $_.Name)}

0 commit comments

Comments
 (0)