Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert XHarness.Tests from packages.config to PackageReference and add darc dependency #18611

Merged
merged 5 commits into from Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions eng/Version.Details.xml
Expand Up @@ -36,5 +36,9 @@
<Uri>https://github.com/dotnet/templating</Uri>
<Sha />
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.iOS.Shared" Version="8.0.0-prerelease.23401.3">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>c1216531b6c19ac4a6dcd447503e09fe28687cbd</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
1 change: 1 addition & 0 deletions eng/Versions.props
Expand Up @@ -10,6 +10,7 @@
<MicrosoftNETWorkloadEmscriptennet7Manifest70100PackageVersion>7.0.5</MicrosoftNETWorkloadEmscriptennet7Manifest70100PackageVersion>
<MicrosoftTemplateEngineTasksVersion>7.0.100-alpha.1.21601.1</MicrosoftTemplateEngineTasksVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.23113.1</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetXHarnessiOSSharedPackageVersion>8.0.0-prerelease.23401.3</MicrosoftDotNetXHarnessiOSSharedPackageVersion>
<!-- Manually updated versions -->
<EmscriptenWorkloadVersion>$(MicrosoftNETWorkloadEmscriptennet7Manifest70100PackageVersion)</EmscriptenWorkloadVersion>
<!-- custom variables -->
Expand Down
Expand Up @@ -26,7 +26,7 @@ public void TearDown ()
[Test]
public void GetTypeForAssembliesNullMonoPath ()
{
var projectDefinition = new ProjectDefinition ("MyProject", assemblyLocator.Object, factory.Object, new List<ITestAssemblyDefinition> (), "");
var projectDefinition = new ProjectDefinition ("MyProject", assemblyLocator.Object, factory.Object, new List<ITestAssemblyDefinition> ());
Assert.Throws<ArgumentNullException> (() => projectDefinition.GetTypeForAssemblies (null, Platform.iOS));
}
}
Expand Down
20 changes: 10 additions & 10 deletions tests/xharness/Xharness.Tests/Tests/AppRunnerTests.cs
Expand Up @@ -229,7 +229,7 @@ public async Task InstallOnDeviceTest ()
var processResult = new ProcessExecutionResult () { ExitCode = 1, TimedOut = false };
processManager.SetReturnsDefault (Task.FromResult (processResult));

devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false)).ReturnsAsync (mockDevices [0]);
devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false, CancellationToken.None)).ReturnsAsync (mockDevices [0]);

// Act
var appRunner = new AppRunner (processManager.Object,
Expand Down Expand Up @@ -274,7 +274,7 @@ public async Task UninstallFromDeviceTest ()
var processResult = new ProcessExecutionResult () { ExitCode = 3, TimedOut = false };
processManager.SetReturnsDefault (Task.FromResult (processResult));

devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false)).ReturnsAsync (mockDevices [1]);
devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false, CancellationToken.None)).ReturnsAsync (mockDevices [1]);

// Act
var appRunner = new AppRunner (processManager.Object,
Expand Down Expand Up @@ -323,13 +323,13 @@ public async Task RunOnSimulatorWithNoAvailableSimulatorTest ()

// Mock finding simulators
simulators
.Setup (x => x.LoadDevices (It.IsAny<ILog> (), false, false, false, true))
.Setup (x => x.LoadDevices (It.IsAny<ILog> (), false, false, false, true, CancellationToken.None))
.Returns (Task.FromResult (true));

string simulatorLogPath = Path.Combine (Path.GetTempPath (), "simulator-logs");

simulators
.Setup (x => x.FindSimulators (TestTarget.Simulator_tvOS, mainLog.Object, true, false))
.Setup (x => x.FindSimulators (TestTarget.Simulator_tvOS, mainLog.Object, true, false, CancellationToken.None))
.ReturnsAsync ((null, null));

var listenerLogFile = new Mock<IFileBackedLog> ();
Expand Down Expand Up @@ -406,7 +406,7 @@ public async Task RunOnSimulatorSuccessfullyTest ()

// Mock finding simulators
simulators
.Setup (x => x.LoadDevices (It.IsAny<ILog> (), false, false, false, true))
.Setup (x => x.LoadDevices (It.IsAny<ILog> (), false, false, false, true, CancellationToken.None))
.Returns (Task.FromResult (true));

string simulatorLogPath = Path.Combine (Path.GetTempPath (), "simulator-logs");
Expand All @@ -418,7 +418,7 @@ public async Task RunOnSimulatorSuccessfullyTest ()
simulator.SetupGet (x => x.SystemLog).Returns (Path.Combine (simulatorLogPath, "system.log"));

simulators
.Setup (x => x.FindSimulators (TestTarget.Simulator_iOS64, mainLog.Object, true, false))
.Setup (x => x.FindSimulators (TestTarget.Simulator_iOS64, mainLog.Object, true, false, CancellationToken.None))
.ReturnsAsync ((simulator.Object, null));

var testResultFilePath = Path.GetTempFileName ();
Expand Down Expand Up @@ -519,9 +519,9 @@ public async Task RunOnSimulatorSuccessfullyTest ()
[Test]
public void RunOnDeviceWithNoAvailableSimulatorTest ()
{
devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false)).ReturnsAsync ((IHardwareDevice) null);
devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false, CancellationToken.None)).ReturnsAsync ((IHardwareDevice) null);
simulators
.Setup (s => s.FindSimulators (It.IsAny<TestTarget> (), It.IsAny<ILog> (), true, false))
.Setup (s => s.FindSimulators (It.IsAny<TestTarget> (), It.IsAny<ILog> (), true, false, CancellationToken.None))
.ReturnsAsync ((null, null));

// Crash reporter
Expand Down Expand Up @@ -574,7 +574,7 @@ public async Task RunOnDeviceSuccessfullyTest ()
{
var harness = GetMockedHarness ();

devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false)).ReturnsAsync (mockDevices [1]);
devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false, CancellationToken.None)).ReturnsAsync (mockDevices [1]);

// Crash reporter
var crashReporterFactory = new Mock<ICrashSnapshotReporterFactory> ();
Expand Down Expand Up @@ -683,7 +683,7 @@ public async Task RunOnDeviceWithFailedTestsTest ()
{
var harness = GetMockedHarness ();

devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false)).ReturnsAsync (mockDevices [1]);
devices.Setup (d => d.FindDevice (It.IsAny<RunMode> (), It.IsAny<ILog> (), false, false, CancellationToken.None)).ReturnsAsync (mockDevices [1]);

// Crash reporter
var crashReporterFactory = new Mock<ICrashSnapshotReporterFactory> ();
Expand Down
Expand Up @@ -84,19 +84,19 @@ public void MacMonoSDKPathSetterTest ()
public void GenerateTestProjectsAsyncTest ()
{
var projects = new GeneratedProjects () {
new GeneratedProject { Name = "First project", Path = "", XUnit = false, ExtraArgs = "", Failure = "", TimeoutMultiplier = 1, GenerationCompleted = Task.CompletedTask, },
new GeneratedProject { Name = "Second project", Path = "", XUnit = true, ExtraArgs = "", Failure = "", TimeoutMultiplier = 1, GenerationCompleted = Task.CompletedTask, },
new GeneratedProject { Name = "First project", Path = "", XUnit = false, Failure = "", TimeoutMultiplier = 1, GenerationCompleted = Task.CompletedTask, },
new GeneratedProject { Name = "Second project", Path = "", XUnit = true, Failure = "", TimeoutMultiplier = 1, GenerationCompleted = Task.CompletedTask, },
};
var infos = new List<(string Name, string [] Assemblies, double TimeoutMultiplier)> {
( Name: "First project", Assemblies: new string [] { }, TimeoutMultiplier: 1),
( Name: "Second project", Assemblies: new string [] { }, TimeoutMultiplier: 1),
};
template.Setup (t => t.GenerateTestProjects (It.IsAny<IEnumerable<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)>> (), It.IsAny<Platform> ())).Returns (() => {
template.Setup (t => t.GenerateTestProjects (It.IsAny<IEnumerable<(string Name, string [] Assemblies, double TimeoutMultiplier)>> (), It.IsAny<Platform> ())).Returns (() => {
return projects;
});
var result = generator.GenerateTestProjects (infos, Platform.iOS);
Assert.AreEqual (projects.Count, result.Count);
template.Verify (t => t.GenerateTestProjects (It.IsAny<IEnumerable<(string Name, string [] Assemblies, string ExtraArgs, double TimeoutMultiplier)>> (), It.IsAny<Platform> ()));
template.Verify (t => t.GenerateTestProjects (It.IsAny<IEnumerable<(string Name, string [] Assemblies, double TimeoutMultiplier)>> (), It.IsAny<Platform> ()));
}
}
}
24 changes: 15 additions & 9 deletions tests/xharness/Xharness.Tests/Xharness.Tests.csproj
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -8,8 +8,7 @@
<RootNamespace>Xharness.Tests</RootNamespace>
<AssemblyName>Xharness.Tests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -19,20 +18,16 @@
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<PackageReference Include="Moq" Version="4.13.0.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Jenkins\ErrorKnowledgeBaseTests.cs" />
Expand All @@ -59,7 +54,6 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<EmbeddedResource Include="Samples\TestProject\Info.plist">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
Expand All @@ -78,11 +72,23 @@
<EmbeddedResource Include="Samples\NUnitV3SampleSuccess.xml" />
<EmbeddedResource Include="Samples\NUnitV3SampleFailure.xml" />
</ItemGroup>
<Import Project="../../../eng/Versions.props" />
<ItemGroup>
<ProjectReference Include="..\xharness.csproj">
<Project>{e1f53f80-8399-499b-8017-c414b9cd263b}</Project>
<Name>xharness</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.XHarness.iOS.Shared" Version="$(MicrosoftDotNetXHarnessiOSSharedPackageVersion)" />
<PackageReference Include="Mono.Cecil" Version="0.11.5" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<Version></Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
2 changes: 1 addition & 1 deletion tests/xharness/Xharness.Tests/app.config
Expand Up @@ -8,7 +8,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down