Skip to content

Commit

Permalink
Allow targets files to be active when indirectly referenced (#1203)
Browse files Browse the repository at this point in the history
* Ensure targets file is applied transitively through implicit references #596

See #596

* Ensure targets file is applied transitively through implicit references

See #596

* Test coverage for libraries that consume MUX.

Added projects LibraryThatUsesMUx and AppThatUsesMUXIndirectly
Update Nuget to ver 5.2.0.
Fixed bug: NuGet tests results are not correctly being reported (failures are being ignored) #1240
Also added check to fail pipeline if we see tests with a result other than "Passed", "Failed" or "Warning"

Filed:
Improve inner loop for Nupkg testing #1237
Test Infra: improve logic to handle multiple test runs of the same name #1248
  • Loading branch information
dotMorten authored and kmahone committed Aug 30, 2019
1 parent 01947e4 commit 74b4750
Show file tree
Hide file tree
Showing 36 changed files with 1,014 additions and 25 deletions.
2 changes: 1 addition & 1 deletion build/AzurePipelinesTemplates/MUX-InstallNuget-Steps.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
nugetVersion: 4.9.3
nugetVersion: 5.2.0

steps:
- task: NuGetToolInstaller@0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
inputs:
targetType: filePath
filePath: build\Helix\UpdateUnreliableTests.ps1
arguments: -RerunPassesRequiredToAvoidFailure '${{ parameters.rerunPassesRequiredToAvoidFailure }}'
arguments: -RerunPassesRequiredToAvoidFailure '${{ parameters.rerunPassesRequiredToAvoidFailure }}' -CheckJobAttempt $${{ parameters.checkJobAttempt }}

- task: powershell@2
displayName: 'OutputTestResults.ps1'
Expand Down
4 changes: 2 additions & 2 deletions build/AzurePipelinesTemplates/MUX-RunHelixTests-Job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ jobs:
filename: 'set'

- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.9.3'
displayName: 'Use NuGet 5.2.0'
inputs:
versionSpec: 4.9.3
versionSpec: 5.2.0

- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: 'NuGet restore build/Helix/packages.config'
Expand Down
2 changes: 2 additions & 0 deletions build/CopyFilesToStagingDir.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ if($PublishAppxFiles)

PublishFile -IfExists $FullBuildOutput\NugetPackageTestApp\AppPackages\NugetPackageTestApp_Test\ $AppxPackagesDir
PublishFile -IfExists $FullBuildOutput\NugetPackageTestAppCX\AppPackages\NugetPackageTestAppCX_Test\ $AppxPackagesDir
PublishFile -IfExists $FullBuildOutput\AppThatUsesMUXIndirectly\AppPackages\AppThatUsesMUXIndirectly_Test\ $AppxPackagesDir
}

# Publish pdbs:
Expand All @@ -71,4 +72,5 @@ PublishFile -IfExists $FullBuildOutput\MUXControlsTestAppForIslands\MUXControlsT
PublishFile -IfExists $FullBuildOutput\MUXControlsTestAppWPF\MUXControlsTestAppWPF.pdb $symbolsOutputDir
PublishFile -IfExists $FullBuildOutput\TestAppCX\TestAppCX.pdb $symbolsOutputDir
PublishFile -IfExists $FullBuildOutput\NugetPackageTestApp\NugetPackageTestApp.pdb $symbolsOutputDir
PublishFile -IfExists $FullBuildOutput\AppThatUsesMUXIndirectly\AppThatUsesMUXIndirectly.pdb $symbolsOutputDir
PublishFile -IfExists $FullBuildOutput\NugetPackageTestAppCX\NugetPackageTestAppCX.pdb $symbolsOutputDir
18 changes: 18 additions & 0 deletions build/Helix/OutputTestResults.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Write-Host "queryUri = $queryUri"
$testRuns = Invoke-RestMethod -Uri $queryUri -Method Get -Headers $azureDevOpsRestApiHeaders
[System.Collections.Generic.List[string]]$failingTests = @()
[System.Collections.Generic.List[string]]$unreliableTests = @()
[System.Collections.Generic.List[string]]$unexpectedResultTest = @()

$timesSeenByRunName = @{}
$totalTestsExecutedCount = 0
Expand Down Expand Up @@ -73,6 +74,14 @@ foreach ($testRun in ($testRuns.value | Sort-Object -Property "completedDate"))
$unreliableTests.Add($shortTestCaseTitle)
}
}
elseif ($testResult.outcome -ne "Passed")
{
# We should only see tests with result "Passed", "Failed" or "Warning"
if (-not $unexpectedResultTest.Contains($shortTestCaseTitle))
{
$unexpectedResultTest.Add($shortTestCaseTitle)
}
}
}
}

Expand All @@ -94,6 +103,15 @@ if ($failingTests.Count -gt 0)
"@
}

if ($unexpectedResultTest.Count -gt 0)
{
Write-Host @"
##vso[task.logissue type=error;]Tests with unexpected results:
##vso[task.logissue type=error;]$($unexpectedResultTest -join "$([Environment]::NewLine)##vso[task.logissue type=error;]")
"@
}

if($totalTestsExecutedCount -lt $MinimumExpectedTestsExecutedCount)
{
Write-Host "Expected at least $MinimumExpectedTestsExecutedCount tests to be executed."
Expand Down
2 changes: 2 additions & 0 deletions build/Helix/PrepareHelixPayload.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function Copy-If-Exists
Copy-Item "$repoDirectory\Artifacts\$ArtifactName\$Configuration\$Platform\Test\MUXControls.Test.dll" $payloadDir
Copy-If-Exists "$repoDirectory\Artifacts\$ArtifactName\$Configuration\$Platform\AppxPackages\MUXControlsTestApp_Test\*" $payloadDir
Copy-If-Exists "$repoDirectory\Artifacts\$ArtifactName\$Configuration\$Platform\AppxPackages\MUXControlsTestApp_Test\Dependencies\$Platform\*" $payloadDir
Copy-If-Exists "$repoDirectory\Artifacts\$ArtifactName\$Configuration\$Platform\AppxPackages\AppThatUsesMUXIndirectly_Test\*" $payloadDir
Copy-If-Exists "$repoDirectory\Artifacts\$ArtifactName\$Configuration\$Platform\AppxPackages\AppThatUsesMUXIndirectly_Test\Dependencies\$Platform\*" $payloadDir
Copy-If-Exists "$repoDirectory\Artifacts\$ArtifactName\$Configuration\$Platform\AppxPackages\IXMPTestApp_Test\*" $payloadDir
Copy-If-Exists "$repoDirectory\Artifacts\$ArtifactName\$Configuration\$Platform\AppxPackages\IXMPTestApp_Test\Dependencies\$Platform\*" $payloadDir

Expand Down
31 changes: 19 additions & 12 deletions build/Helix/UpdateUnreliableTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Param(
[string]$CollectionUri = $env:SYSTEM_COLLECTIONURI,
[string]$TeamProject = $env:SYSTEM_TEAMPROJECT,
[string]$BuildUri = $env:BUILD_BUILDURI,
[int]$JobAttempt = $env:SYSTEM_JOBATTEMPT
[int]$JobAttempt = $env:SYSTEM_JOBATTEMPT,
[bool]$CheckJobAttempt
)

. "$PSScriptRoot/AzurePipelinesHelperScripts.ps1"
Expand All @@ -30,19 +31,25 @@ $timesSeenByRunName = @{}

foreach ($testRun in $testRuns.value)
{
if (-not $timesSeenByRunName.ContainsKey($testRun.name))
{
$timesSeenByRunName[$testRun.name] = 0
}

$timesSeen = $timesSeenByRunName[$testRun.name] + 1
$timesSeenByRunName[$testRun.name] = $timesSeen

# The same build can have multiple test runs associated with it if the build owner opted to re-run a test run.
# The same build for a pull request can have multiple test runs associated with it if the build owner opted to re-run a test run.
# We should only pay attention to the current attempt version.
if ($timesSeen -ne $JobAttempt)
# NB: If in the future we have pull request builds do multiple test runs as part of the same build definition, we'll need to revisit this.
if ($CheckJobAttempt)
{
continue
if (-not $timesSeenByRunName.ContainsKey($testRun.name))
{
$timesSeenByRunName[$testRun.name] = 0
}

$timesSeen = $timesSeenByRunName[$testRun.name] + 1
$timesSeenByRunName[$testRun.name] = $timesSeen

# The same build can have multiple test runs associated with it if the build owner opted to re-run a test run.
# We should only pay attention to the current attempt version.
if ($timesSeen -ne $JobAttempt)
{
continue
}
}

$testRunResultsUri = "$($testRun.url)/results?api-version=5.0"
Expand Down
3 changes: 2 additions & 1 deletion build/NuSpecs/MUXControls.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@

<!-- Common build logic -->
<file target="build\$ID$.targets" src="MUXControls-Nuget-Common.targets"/>
<file target="buildTransitive\$ID$.targets" src="MUXControls-Nuget-Common.targets"/>

<!-- This is here for C++ based projects, see http://nugetdocsbeta.azurewebsites.net/ndocs/guides/create-uwp-packages -->
<file target="build\native\$ID$.targets" src="MUXControls-Nuget-Native.targets"/>
</files>
</package>
</package>
6 changes: 5 additions & 1 deletion build/NuSpecs/MUXControlsFrameworkPackage.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
<file target="tools" src="VisualStudioToolsManifest.xml"/>

<file target="build" src="$BUILDOUTPUT$\$BUILDFLAVOR$\$BUILDARCH$\FrameworkPackage\MicrosoftUIXamlVersion.props"/>
<file target="buildTransitive" src="$BUILDOUTPUT$\$BUILDFLAVOR$\$BUILDARCH$\FrameworkPackage\MicrosoftUIXamlVersion.props"/>
<file target="build\Common.targets" src="MUXControls-Nuget-Common.targets"/>
<file target="buildTransitive\Common.targets" src="MUXControls-Nuget-Common.targets"/>
<file target="build\$ID$.props" src="MUXControls-Nuget-FrameworkPackage.props"/>
<file target="buildTransitive\$ID$.props" src="MUXControls-Nuget-FrameworkPackage.props"/>
<file target="build\native\$ID$.targets" src="MUXControls-Nuget-FrameworkPackage.targets"/>
<file target="build\DensityStyles\Compact.xaml" src="$BUILDOUTPUT$\$BUILDFLAVOR$\$BUILDARCH$\FrameworkPackage\Compact.xaml"/>
<file target="buildTransitive\DensityStyles\Compact.xaml" src="$BUILDOUTPUT$\$BUILDFLAVOR$\$BUILDARCH$\FrameworkPackage\Compact.xaml"/>
</files>
</package>
</package>
21 changes: 14 additions & 7 deletions test/MUXControls.Test/Infra/TestEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Infra
{
public enum TestType { MuxControls, Nuget, NugetCX, WPFXAMLIsland };
public enum TestType { MuxControls, Nuget, NugetCX, WPFXAMLIsland, AppThatUsesMuxIndirectly };

// This is marked as a test class to make sure our AssemblyInitialize and AssemblyCleanup
// fixtures get executed. It won't actually host any tests.
Expand All @@ -44,21 +44,27 @@ public class TestEnvironment
#else
private const string _testAppName = "MUXControlsTestApp_8wekyb3d8bbwe!App";
#endif

private const string _wpfXamlIslandPackageName = "MUXControlsTestAppWPFPackage";
private const string _wfpXamlIslandAppName = "MUXControlsTestAppWPFPackage_8wekyb3d8bbwe!App";
private const string _testAppPackageFamilyName = "MUXControlsTestApp_8wekyb3d8bbwe";

public const string _nugetTestAppPackageName = "NugetPackageTestApp";
private const string _nugetTestAppName = "NugetPackageTestApp_8wekyb3d8bbwe!App";
private const string _nugetTestAppPackageFamilyName = "NugetPackageTestApp_8wekyb3d8bbwe";

public const string _appThatUsesMUXIndirectlyPackageName = "AppThatUsesMUXIndirectly";
private const string _appThatUsesMUXIndirectlyName = "AppThatUsesMUXIndirectly_8wekyb3d8bbwe!App";
private const string _appThatUsesMUXIndirectlyPackageFamilyName = "AppThatUsesMUXIndirectly_8wekyb3d8bbwe";

public const string _nugetTestAppCXPackageName = "NugetPackageTestAppCX";
private const string _nugetTestAppCXName = "NugetPackageTestAppCX_8wekyb3d8bbwe!App";

private const string _testAppPackageFamilyName = "MUXControlsTestApp_8wekyb3d8bbwe";
private const string _nugetTestAppPackageFamilyName = "NugetPackageTestApp_8wekyb3d8bbwe";
private const string _nugetTestAppCXPackageFamilyName = "NugetPackageTestAppCX_8wekyb3d8bbwe";

private const string _wpfXamlIslandPackageName = "MUXControlsTestAppWPFPackage";
private const string _wfpXamlIslandAppName = "MUXControlsTestAppWPFPackage_8wekyb3d8bbwe!App";
private const string _wpfXamlIslandPackageFamilyName = "MUXControlsTestAppWPFPackage_8wekyb3d8bbwe";




public static TestContext TestContext { get; private set; }

public static bool IsLogVerbose { get; private set; }
Expand Down Expand Up @@ -155,6 +161,7 @@ private static Application CreateApplication(TestType type)
if (type == TestType.Nuget) return new Application(_nugetTestAppPackageName, _nugetTestAppPackageFamilyName, _nugetTestAppName);
if (type == TestType.NugetCX) return new Application(_nugetTestAppCXPackageName, _nugetTestAppCXPackageFamilyName, _nugetTestAppCXName);
if (type == TestType.WPFXAMLIsland) return new Application(_wpfXamlIslandPackageName, _wpfXamlIslandPackageFamilyName, _wfpXamlIslandAppName, false /* isUWPApp */);
if (type == TestType.AppThatUsesMuxIndirectly) return new Application(_appThatUsesMUXIndirectlyPackageName, _appThatUsesMUXIndirectlyPackageFamilyName, _appThatUsesMUXIndirectlyName);
return new Application(_testAppPackageName, _testAppPackageFamilyName, _testAppName);
}

Expand Down
7 changes: 7 additions & 0 deletions test/MUXControlsReleaseTest/AppThatUsesMUXIndirectly/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Application
x:Class="AppThatUsesMUXIndirectly.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AppThatUsesMUXIndirectly">

</Application>
101 changes: 101 additions & 0 deletions test/MUXControlsReleaseTest/AppThatUsesMUXIndirectly/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using MUXControlsTestApp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace AppThatUsesMUXIndirectly
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new TestFrame(typeof(MainPage));

rootFrame.NavigationFailed += OnNavigationFailed;

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}

// Place the frame in the current Window
Window.Current.Content = rootFrame;
}

if (e.PrelaunchActivated == false)
{
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
}
}
Loading

0 comments on commit 74b4750

Please sign in to comment.