Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 80fc0702d1 | |||
| 39c5a33d56 | |||
| 686404bb7f | |||
| e41071ddb0 | |||
| 13f0cedb64 | |||
| 93601521fc | |||
| 24522e8749 | |||
| 070d3bcb5e | |||
| 78501d237a | |||
| 1e2fe65dfa | |||
| 0a52154c60 | |||
| d26343057f | |||
| ba398d66ad | |||
| 412c9b78fe | |||
| 8eea004410 | |||
| e52d9195ef | |||
| 80a52c0f30 | |||
| a3ceb785fa | |||
| 9a94bfd08d | |||
| cd411e5d56 | |||
| ed8641a896 | |||
| bb9ed9106b | |||
| 5e966ff461 | |||
| 83bd1be9bf |
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -65,6 +66,12 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="xunit" version="2.1.0" targetFramework="net452" />
|
||||
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
|
||||
<package id="xunit.assert" version="2.1.0" targetFramework="net452" />
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
Steps to make a new release
|
||||
===========================
|
||||
|
||||
1. Make sure no one else is planning on doing anything that would trigger a build
|
||||
2. Check the "next build number" on [AppVeyor](https://ci.appveyor.com/project/Pilchie/xunit-runner-wpf/settings)
|
||||
3. Click on [releases](https://github.com/Pilchie/xunit.runner.wpf/releases) -> `Draft a new release`
|
||||
4. Set the version to `v1.0.nextbuildnumber` from 2
|
||||
5. Set the title to `v1.0.nextbuildnumber - Some reason for the release to exist`
|
||||
6. Click `Publish`
|
||||
7. This will create the release, and start a new build on AppVeyor
|
||||
8. Download the .nupkg from the AppVeyor artifacts page for that new build - (e.g. https://ci.appveyor.com/project/Pilchie/xunit-runner-wpf/build/1.0.15/artifacts)
|
||||
9. Go back to the release you created in 6, and add the nupkg, and write a changelog
|
||||
10. Tell [@Pilchie](https://github.com/Pilchie) to upload the nupkg to NuGet.org
|
||||
@@ -6,13 +6,15 @@ namespace Xunit.Runner.Data
|
||||
public sealed class TestCaseData
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string UniqueID { get; set; }
|
||||
public string SkipReason { get; set; }
|
||||
public string AssemblyPath { get; set; }
|
||||
public Dictionary<string, List<string>> TraitMap { get; set; }
|
||||
|
||||
public TestCaseData(string displayName, string skipReason, string assemblyPath, Dictionary<string, List<string>> traitMap)
|
||||
public TestCaseData(string displayName, string uniqueID, string skipReason, string assemblyPath, Dictionary<string, List<string>> traitMap)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
UniqueID = uniqueID;
|
||||
SkipReason = skipReason;
|
||||
AssemblyPath = assemblyPath;
|
||||
TraitMap = traitMap;
|
||||
@@ -21,6 +23,7 @@ namespace Xunit.Runner.Data
|
||||
public static TestCaseData ReadFrom(BinaryReader reader)
|
||||
{
|
||||
var displayName = reader.ReadString();
|
||||
var uniqueID = reader.ReadString();
|
||||
var skipReason = reader.ReadString();
|
||||
var assemblyPath = reader.ReadString();
|
||||
var count = reader.ReadInt32();
|
||||
@@ -40,12 +43,13 @@ namespace Xunit.Runner.Data
|
||||
traitMap.Add(key, values);
|
||||
}
|
||||
|
||||
return new TestCaseData(displayName, skipReason, assemblyPath, traitMap);
|
||||
return new TestCaseData(displayName, uniqueID, skipReason, assemblyPath, traitMap);
|
||||
}
|
||||
|
||||
public void WriteTo(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(DisplayName);
|
||||
writer.Write(UniqueID);
|
||||
writer.Write(SkipReason ?? string.Empty);
|
||||
writer.Write(AssemblyPath);
|
||||
writer.Write(TraitMap.Count);
|
||||
|
||||
@@ -18,12 +18,14 @@ namespace Xunit.Runner.Data
|
||||
public sealed class TestResultData
|
||||
{
|
||||
public string TestCaseDisplayName { get; set; }
|
||||
public string TestCaseUniqueID { get; set; }
|
||||
public TestState TestState { get; set; }
|
||||
public string Output { get; set; }
|
||||
|
||||
public TestResultData(string displayName, TestState state, string output = "")
|
||||
public TestResultData(string displayName, string uniqueID, TestState state, string output = "")
|
||||
{
|
||||
TestCaseDisplayName = displayName;
|
||||
TestCaseUniqueID = uniqueID;
|
||||
TestState = state;
|
||||
Output = output;
|
||||
}
|
||||
@@ -31,14 +33,16 @@ namespace Xunit.Runner.Data
|
||||
public static TestResultData ReadFrom(BinaryReader reader)
|
||||
{
|
||||
var displayName = reader.ReadString();
|
||||
var uniqueID = reader.ReadString();
|
||||
var state = (TestState)reader.ReadInt32();
|
||||
var output = reader.ReadString();
|
||||
return new TestResultData(displayName, state, output);
|
||||
return new TestResultData(displayName, uniqueID, state, output);
|
||||
}
|
||||
|
||||
public void WriteTo(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(TestCaseDisplayName);
|
||||
writer.Write(TestCaseUniqueID);
|
||||
writer.Write((int)TestState);
|
||||
writer.Write(Output);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,11 @@
|
||||
<Compile Include="TestDataKind.cs" />
|
||||
<Compile Include="TestResultData.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Net.Compilers">
|
||||
<Version>2.2.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Xunit.Runner.Worker
|
||||
var testCase = testCaseDiscovered.TestCase;
|
||||
var testCaseData = new TestCaseData(
|
||||
testCase.DisplayName,
|
||||
testCase.UniqueID,
|
||||
testCase.SkipReason,
|
||||
testCaseDiscovered.TestAssembly.Assembly.AssemblyPath,
|
||||
testCase.Traits);
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Xunit.Runner.Worker
|
||||
{
|
||||
Console.WriteLine("xunit.runner.worker [pipe name] [action] [assembly path]");
|
||||
Console.WriteLine("\tpipe name: Name of the pipe this worker should communicate on");
|
||||
Console.WriteLine("\taction: Action performed by the worker (run or discover tests");
|
||||
Console.WriteLine("\assembly path: Path of assembly to perform the action against");
|
||||
Console.WriteLine("\taction: Action performed by the worker (run or discover tests)");
|
||||
Console.WriteLine("\tassembly path: Path of assembly to perform the action against");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace Xunit.Runner.Worker
|
||||
|
||||
protected override bool ShouldContinue => _writer.IsConnected;
|
||||
|
||||
private void Process(string displayName, TestState state, string output = "")
|
||||
private void Process(string displayName, string uniqueID, TestState state, string output = "")
|
||||
{
|
||||
Console.WriteLine($"{state} - {displayName}");
|
||||
var result = new TestResultData(displayName, state, output);
|
||||
var result = new TestResultData(displayName, uniqueID, state, output);
|
||||
|
||||
_writer.Write(TestDataKind.Value);
|
||||
_writer.Write(result);
|
||||
@@ -46,35 +46,35 @@ namespace Xunit.Runner.Worker
|
||||
|
||||
builder.AppendLine();
|
||||
|
||||
Process(testFailed.TestCase.DisplayName, TestState.Failed, builder.ToString());
|
||||
Process(testFailed.TestCase.DisplayName, testFailed.TestCase.UniqueID, TestState.Failed, builder.ToString());
|
||||
}
|
||||
|
||||
protected override void OnTestPassed(ITestPassed testPassed)
|
||||
{
|
||||
Process(testPassed.TestCase.DisplayName, TestState.Passed);
|
||||
Process(testPassed.TestCase.DisplayName, testPassed.TestCase.UniqueID, TestState.Passed);
|
||||
}
|
||||
|
||||
protected override void OnTestSkipped(ITestSkipped testSkipped)
|
||||
{
|
||||
Process(testSkipped.TestCase.DisplayName, TestState.Skipped);
|
||||
Process(testSkipped.TestCase.DisplayName, testSkipped.TestCase.UniqueID, TestState.Skipped);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class TestDiscoverySink : BaseTestDiscoverySink
|
||||
{
|
||||
private readonly HashSet<string> _testCaseNameSet;
|
||||
private readonly HashSet<string> _testCaseUniqueIDSet;
|
||||
private readonly List<ITestCase> _testCaseList;
|
||||
|
||||
internal TestDiscoverySink(HashSet<string> testCaseDisplayNameSet, List<ITestCase> testCaseList)
|
||||
internal TestDiscoverySink(HashSet<string> testCaseUniqueIDSet, List<ITestCase> testCaseList)
|
||||
{
|
||||
_testCaseNameSet = testCaseDisplayNameSet;
|
||||
_testCaseUniqueIDSet = testCaseUniqueIDSet;
|
||||
_testCaseList = testCaseList;
|
||||
}
|
||||
|
||||
protected override void OnTestDiscovered(ITestCaseDiscoveryMessage testCaseDiscovered)
|
||||
{
|
||||
var testCase = testCaseDiscovered.TestCase;
|
||||
if (_testCaseNameSet.Contains(testCase.DisplayName))
|
||||
if (_testCaseUniqueIDSet.Contains(testCase.UniqueID))
|
||||
{
|
||||
_testCaseList.Add(testCaseDiscovered.TestCase);
|
||||
}
|
||||
@@ -82,9 +82,9 @@ namespace Xunit.Runner.Worker
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read out the set of test case display names to run.
|
||||
/// Read out the set of test case unique IDs to run.
|
||||
/// </summary>
|
||||
private static List<string> ReadTestCaseDisplayNames(Stream stream)
|
||||
private static List<string> ReadTestCaseUniqueIDs(Stream stream)
|
||||
{
|
||||
using (var reader = new ClientReader(stream))
|
||||
{
|
||||
@@ -133,14 +133,14 @@ namespace Xunit.Runner.Worker
|
||||
|
||||
internal static void RunSpecific(string assemblyFileName, Stream stream)
|
||||
{
|
||||
var testCaseNameSet = new HashSet<string>(ReadTestCaseDisplayNames(stream), StringComparer.Ordinal);
|
||||
var testCaseUniqueIDSet = new HashSet<string>(ReadTestCaseUniqueIDs(stream), StringComparer.Ordinal);
|
||||
|
||||
Go(assemblyFileName, stream, AppDomainSupport.IfAvailable,
|
||||
(xunit, configuration, writer) =>
|
||||
{
|
||||
using (var sink = new TestRunSink(writer))
|
||||
{
|
||||
var testCaseList = GetTestCaseList(xunit, configuration, testCaseNameSet);
|
||||
var testCaseList = GetTestCaseList(xunit, configuration, testCaseUniqueIDSet);
|
||||
|
||||
xunit.RunTests(testCaseList, sink,
|
||||
executionOptions: TestFrameworkOptions.ForExecution(configuration));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net46" developmentDependency="true" />
|
||||
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
|
||||
<package id="xunit.runner.utility" version="2.1.0" targetFramework="net46" />
|
||||
</packages>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -13,6 +14,8 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -74,6 +77,12 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Xunit.Runner.Wpf
|
||||
private readonly ObservableCollection<T> dataSource;
|
||||
private readonly List<T> filteredList;
|
||||
private readonly Func<T, TFilterArg, bool> filter;
|
||||
private readonly IComparer<T> sort;
|
||||
|
||||
public FilteredCollectionView(ObservableCollection<T> dataSource, Func<T, TFilterArg, bool> filter, TFilterArg filterArgument, IComparer<T> sort)
|
||||
{
|
||||
@@ -26,6 +27,7 @@ namespace Xunit.Runner.Wpf
|
||||
this.filter = filter;
|
||||
this.filterArgument = filterArgument;
|
||||
this.filteredList = new List<T>();
|
||||
this.sort = sort;
|
||||
|
||||
this.dataSource.CollectionChanged += this.dataSource_CollectionChanged;
|
||||
|
||||
@@ -71,6 +73,7 @@ namespace Xunit.Runner.Wpf
|
||||
}
|
||||
}
|
||||
|
||||
this.filteredList.Sort(sort);
|
||||
this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
}
|
||||
|
||||
@@ -115,7 +118,7 @@ namespace Xunit.Runner.Wpf
|
||||
{
|
||||
if (this.filter(item, this.filterArgument))
|
||||
{
|
||||
int index = this.filteredList.IndexOf(item);
|
||||
int index = this.filteredList.BinarySearch(item, sort);
|
||||
if (index < 0)
|
||||
{
|
||||
this.filteredList.Insert(~index, item);
|
||||
@@ -138,7 +141,7 @@ namespace Xunit.Runner.Wpf
|
||||
observable.PropertyChanged -= this.dataSource_ItemChanged;
|
||||
}
|
||||
|
||||
int index = this.filteredList.IndexOf(item);
|
||||
int index = this.filteredList.BinarySearch(item, sort);
|
||||
if (index >= 0)
|
||||
{
|
||||
this.filteredList.RemoveAt(index);
|
||||
@@ -149,7 +152,7 @@ namespace Xunit.Runner.Wpf
|
||||
private void dataSource_ItemChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
var item = (T)sender;
|
||||
int index = this.filteredList.IndexOf(item);
|
||||
int index = this.filteredList.BinarySearch(item, sort);
|
||||
if (this.filter(item, this.FilterArgument))
|
||||
{
|
||||
if (index < 0)
|
||||
@@ -196,7 +199,7 @@ namespace Xunit.Runner.Wpf
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool Contains(T item) => this.filteredList.Contains(item);
|
||||
public bool Contains(T item) => this.filteredList.BinarySearch(item, sort) >= 0;
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
@@ -216,7 +219,14 @@ namespace Xunit.Runner.Wpf
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
|
||||
|
||||
public int IndexOf(T item) => this.filteredList.IndexOf(item);
|
||||
public int IndexOf(T item)
|
||||
{
|
||||
int location = this.filteredList.BinarySearch(item, sort);
|
||||
if (location < 0)
|
||||
return -1;
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
public void Insert(int index, T item)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Xunit.Runner.Wpf
|
||||
{
|
||||
internal interface ITestAssemblyWatcher
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a new assembly to list of assemblies to be autoreloaded.
|
||||
/// </summary>
|
||||
void AddAssembly(string assemblyFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Removes an assembly from the list of assemblies ot be autoreloaded.
|
||||
/// </summary>
|
||||
void RemoveAssembly(string assemblyFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Enables watching of all assemblies.
|
||||
/// </summary>
|
||||
/// <param name="reloader">Action to perform when a file change is detected</param>
|
||||
void EnableWatch(Func<IEnumerable<string>, bool> reloader);
|
||||
|
||||
/// <summary>
|
||||
/// Disables watching of all assemblies
|
||||
/// </summary>
|
||||
void DisableWatch();
|
||||
}
|
||||
}
|
||||
@@ -34,14 +34,14 @@ namespace Xunit.Runner.Wpf.Impl
|
||||
_processInfo = StartWorkerProcess();
|
||||
}
|
||||
|
||||
private async Task<Connection> CreateConnection(string action, string argument)
|
||||
private async Task<Connection> CreateConnection(string action, string argument, CancellationToken cancellationToken)
|
||||
{
|
||||
var pipeName = GetPipeName();
|
||||
|
||||
try
|
||||
{
|
||||
var stream = new NamedPipeClientStream(pipeName);
|
||||
await stream.ConnectAsync();
|
||||
await stream.ConnectAsync(cancellationToken);
|
||||
|
||||
var writer = new ClientWriter(stream);
|
||||
writer.Write(action);
|
||||
@@ -101,7 +101,7 @@ namespace Xunit.Runner.Wpf.Impl
|
||||
|
||||
private async Task Discover(string assemblyPath, Action<List<TestCaseData>> callback, CancellationToken cancellationToken)
|
||||
{
|
||||
var connection = await CreateConnection(Constants.ActionDiscover, assemblyPath);
|
||||
var connection = await CreateConnection(Constants.ActionDiscover, assemblyPath, cancellationToken);
|
||||
await ProcessResultsCore(connection, r => r.ReadTestCaseData(), callback, cancellationToken);
|
||||
|
||||
RecycleProcess();
|
||||
@@ -109,7 +109,7 @@ namespace Xunit.Runner.Wpf.Impl
|
||||
|
||||
private async Task RunCore(string actionName, string assemblyPath, ImmutableArray<string> testCaseDisplayNames, Action<List<TestResultData>> callback, CancellationToken cancellationToken)
|
||||
{
|
||||
var connection = await CreateConnection(actionName, assemblyPath);
|
||||
var connection = await CreateConnection(actionName, assemblyPath, cancellationToken);
|
||||
|
||||
if (!testCaseDisplayNames.IsDefaultOrEmpty)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Xunit.Runner.Wpf.Impl
|
||||
{
|
||||
internal sealed class TestAssemblyWatcher : ITestAssemblyWatcher
|
||||
{
|
||||
private readonly object sync = new object();
|
||||
private readonly IDictionary<string, FileSystemWatcher> watchedAssemblies = new Dictionary<string, FileSystemWatcher>();
|
||||
private readonly Dispatcher dispatcher;
|
||||
private bool isEnabled = false;
|
||||
private ReloadDebouncer debouncer;
|
||||
|
||||
public TestAssemblyWatcher(Dispatcher dispatcher)
|
||||
{
|
||||
this.dispatcher = dispatcher;
|
||||
}
|
||||
|
||||
public void AddAssembly(string assemblyFileName)
|
||||
{
|
||||
// Assumptions about adding and removing assemblies are broken if this isn't true
|
||||
Debug.Assert(string.Equals(assemblyFileName, Path.GetFullPath(assemblyFileName), StringComparison.Ordinal));
|
||||
|
||||
lock (sync)
|
||||
{
|
||||
if (watchedAssemblies.ContainsKey(assemblyFileName))
|
||||
{
|
||||
// Already watching this assembly, nothing to do but return
|
||||
return;
|
||||
}
|
||||
|
||||
FileSystemWatcher watcher = new FileSystemWatcher
|
||||
{
|
||||
Path = Path.GetDirectoryName(assemblyFileName),
|
||||
NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.LastWrite,
|
||||
Filter = Path.GetFileName(assemblyFileName)
|
||||
};
|
||||
|
||||
watcher.Changed += new FileSystemEventHandler(OnChanged);
|
||||
watcher.Created += new FileSystemEventHandler(OnChanged);
|
||||
|
||||
watchedAssemblies[assemblyFileName] = watcher;
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
watcher.EnableRaisingEvents = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveAssembly(string assemblyFileName)
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
if (watchedAssemblies.ContainsKey(assemblyFileName))
|
||||
{
|
||||
watchedAssemblies[assemblyFileName].Dispose();
|
||||
watchedAssemblies.Remove(assemblyFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void EnableWatch(Func<IEnumerable<string>, bool> reloader)
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
isEnabled = true;
|
||||
|
||||
foreach (var watcher in watchedAssemblies.Values)
|
||||
{
|
||||
watcher.EnableRaisingEvents = true;
|
||||
}
|
||||
|
||||
this.debouncer = new ReloadDebouncer(dispatcher, reloader);
|
||||
}
|
||||
}
|
||||
|
||||
public void DisableWatch()
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
isEnabled = false;
|
||||
|
||||
foreach (var watcher in watchedAssemblies.Values)
|
||||
{
|
||||
watcher.EnableRaisingEvents = false;
|
||||
}
|
||||
|
||||
this.debouncer?.Cancel();
|
||||
this.debouncer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnChanged(object source, FileSystemEventArgs args)
|
||||
{
|
||||
debouncer?.AddAssembly(args.FullPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Because, during a build of a number of projects many file system events will be triggered for potentially many
|
||||
/// test assemblies, we need to batch our update requests. This class will do this, waiting for 100 ms after receiving
|
||||
/// a new reload request to send the reload requests. This timer resets every time a reload request is received. Note
|
||||
/// that if you continuously rebuild, this will technicially never finish batching and nothing will reload, but this
|
||||
/// assumes that file events will stop at some point.
|
||||
///
|
||||
/// If the reloader returns false, meaning that the reload was not kicked off successfully, we back off for a full second
|
||||
/// before reattempting to queue the updates.
|
||||
/// </summary>
|
||||
private class ReloadDebouncer
|
||||
{
|
||||
private readonly object sync = new object();
|
||||
private readonly Dispatcher dispatcher;
|
||||
private readonly Func<IEnumerable<string>, bool> reloader;
|
||||
|
||||
private ISet<string> assembliesToReload = new HashSet<string>();
|
||||
private bool newAssemblyAdded = false;
|
||||
private bool running = false;
|
||||
private bool cancelled = false;
|
||||
|
||||
public ReloadDebouncer(Dispatcher dispatcher, Func<IEnumerable<string>, bool> reloader)
|
||||
{
|
||||
this.dispatcher = dispatcher;
|
||||
this.reloader = reloader;
|
||||
}
|
||||
|
||||
public void AddAssembly(string assembly)
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
assembliesToReload.Add(assembly);
|
||||
|
||||
if (!Start())
|
||||
{
|
||||
newAssemblyAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
|
||||
private bool Start()
|
||||
{
|
||||
if (running)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
running = true;
|
||||
Task.Run((Action)Debounce);
|
||||
return true;
|
||||
}
|
||||
|
||||
private async void Debounce()
|
||||
{
|
||||
bool backOff = false;
|
||||
|
||||
do
|
||||
{
|
||||
await Task.Delay(backOff ? 1000 : 100);
|
||||
backOff = false;
|
||||
|
||||
lock (sync)
|
||||
{
|
||||
void Reset()
|
||||
{
|
||||
assembliesToReload = new HashSet<string>();
|
||||
running = false;
|
||||
}
|
||||
|
||||
if (cancelled)
|
||||
{
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
// New assemblies added, so we need to wait again
|
||||
if (newAssemblyAdded)
|
||||
{
|
||||
newAssemblyAdded = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// No new assemblies added, time to alert and exit
|
||||
if (!dispatcher.Invoke(() => reloader(assembliesToReload)))
|
||||
{
|
||||
// If the reloader returned false, it's still busy from the last reload request or other user action.
|
||||
// Back off for a full second to give it time, then continue as previous
|
||||
backOff = true;
|
||||
continue;
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
} while (running);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,8 @@
|
||||
<Separator />
|
||||
<MenuItem Header="_Unload" Command="{Binding AssemblyRemoveAllCommand}"/>
|
||||
<MenuItem Header="_Reload" Command="{Binding AssemblyReloadAllCommand}" />
|
||||
<Separator />
|
||||
<MenuItem Header="_Auto Reload Test Assemblies" IsCheckable="True" IsChecked="{Binding AutoReloadAssemblies}" Command="{Binding AutoReloadAssembliesCommand}" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Project">
|
||||
<MenuItem Header="_Open" />
|
||||
@@ -198,17 +200,19 @@
|
||||
Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Content="_Run All"
|
||||
Command="{Binding RunCommand}"
|
||||
Margin="3"
|
||||
Grid.Column="0" />
|
||||
Command="{Binding RunAllCommand}"
|
||||
Grid.Column="0" Margin="10,0,0,0"/>
|
||||
<Button Content="Run _Selected"
|
||||
Command="{Binding RunSelectedCommand}"
|
||||
Grid.Column="1"/>
|
||||
<Button Content="_Cancel"
|
||||
Command="{Binding CancelCommand}"
|
||||
Margin="0,3,3,3"
|
||||
Grid.Column="1" />
|
||||
Grid.Column="2" Margin="0,0,10,0" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Column="1"
|
||||
@@ -254,7 +258,7 @@
|
||||
<Image Source="Artwork\Failed_large.png" />
|
||||
<TextBlock Margin="4,0"
|
||||
FontSize="16"
|
||||
Text="{Binding TestsFailed, StringFormat={}{0:#\,0}}"
|
||||
Text="{Binding TestsFailed, StringFormat={}{0:#\,0}}"
|
||||
VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</ToggleButton>
|
||||
@@ -269,15 +273,16 @@
|
||||
<Image Source="Artwork\Skipped_large.png" />
|
||||
<TextBlock Margin="4,0"
|
||||
FontSize="16"
|
||||
Text="{Binding TestsSkipped, StringFormat={}{0:#\,0}}"
|
||||
Text="{Binding TestsSkipped, StringFormat={}{0:#\,0}}"
|
||||
VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
||||
<ListBox ItemsSource="{Binding FilteredTestCases}"
|
||||
<ListBox x:Name="TestCases" ItemsSource="{Binding FilteredTestCases}"
|
||||
SelectionMode="Extended"
|
||||
Grid.Row="1">
|
||||
SelectedItem="{Binding SelectedTestCase, Mode=TwoWay}"
|
||||
Grid.Row="1" SelectionChanged="TestCases_SelectionChanged">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="vm:TestCaseViewModel">
|
||||
<Grid>
|
||||
@@ -313,9 +318,9 @@
|
||||
Text="{Binding Output}"/>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
|
||||
<GridSplitter Grid.Column="0" VerticalAlignment="Stretch" Width="3" Background="White"/>
|
||||
|
||||
|
||||
<ProgressBar Foreground="{Binding Path=CurrentRunState, Converter={StaticResource TestStateConverter}, Mode=OneWay}"
|
||||
Minimum="0"
|
||||
Maximum="{Binding MaximumProgress}"
|
||||
|
||||
@@ -5,6 +5,8 @@ using Xunit.Runner.Wpf.Persistence;
|
||||
|
||||
namespace Xunit.Runner.Wpf
|
||||
{
|
||||
using ViewModel;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public static Window Instance { get; private set; }
|
||||
@@ -29,5 +31,26 @@ namespace Xunit.Runner.Wpf
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
private void TestCases_SelectionChanged(Object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
foreach (var item in e.AddedItems)
|
||||
{
|
||||
var model = item as TestCaseViewModel;
|
||||
if (model != null)
|
||||
{
|
||||
model.IsSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in e.RemovedItems)
|
||||
{
|
||||
var model = item as TestCaseViewModel;
|
||||
if (model != null)
|
||||
{
|
||||
model.IsSelected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,21 +14,24 @@ namespace Xunit.Runner.Wpf.Persistence
|
||||
private const string RecentAssemblyElementName = "recent_assembly";
|
||||
private const string SettingsElementName = "settings";
|
||||
private const string VersionAttributeName = "version";
|
||||
private const string AutoReloadAssembliesElementName = "auto_reload_assemblies";
|
||||
|
||||
private const int MaxRecentAssemblies = 10;
|
||||
|
||||
private static readonly Version s_latestVersion = new Version(1, 0, 0, 0);
|
||||
|
||||
private List<string> recentAssemblies;
|
||||
private bool autoReloadAssemblies;
|
||||
|
||||
private Settings()
|
||||
{
|
||||
recentAssemblies = new List<string>();
|
||||
autoReloadAssemblies = true;
|
||||
}
|
||||
|
||||
public void AddRecentAssembly(string filePath)
|
||||
{
|
||||
for (int i = recentAssemblies.Count - 1; i > 0; i--)
|
||||
for (int i = recentAssemblies.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (StringComparer.OrdinalIgnoreCase.Equals(recentAssemblies[i], filePath))
|
||||
{
|
||||
@@ -44,6 +47,13 @@ namespace Xunit.Runner.Wpf.Persistence
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleAutoReloadAssemblies()
|
||||
{
|
||||
autoReloadAssemblies = !autoReloadAssemblies;
|
||||
}
|
||||
|
||||
public bool GetAutoReloadAssemblies() => autoReloadAssemblies;
|
||||
|
||||
public ImmutableArray<string> GetRecentAssemblies()
|
||||
{
|
||||
return this.recentAssemblies.ToImmutableArray();
|
||||
@@ -66,6 +76,8 @@ namespace Xunit.Runner.Wpf.Persistence
|
||||
xml.Add(recentAssembliesElement);
|
||||
}
|
||||
|
||||
xml.Add(new XElement(AutoReloadAssembliesElementName, autoReloadAssemblies));
|
||||
|
||||
xml.Save(xmlFile);
|
||||
}
|
||||
}
|
||||
@@ -103,6 +115,17 @@ namespace Xunit.Runner.Wpf.Persistence
|
||||
}
|
||||
}
|
||||
|
||||
var autoReloadAssembliesElement = xml.Element(AutoReloadAssembliesElementName);
|
||||
if (autoReloadAssembliesElement != null)
|
||||
{
|
||||
if (!bool.TryParse(autoReloadAssembliesElement.Value, out var autoReloadAssemblies))
|
||||
{
|
||||
autoReloadAssemblies = true;
|
||||
}
|
||||
|
||||
settings.autoReloadAssemblies = autoReloadAssemblies;
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
private readonly Settings settings;
|
||||
|
||||
private readonly ITestUtil testUtil;
|
||||
private readonly ITestAssemblyWatcher assemblyWatcher;
|
||||
private readonly HashSet<string> allTestCaseUniqueIDs = new HashSet<string>();
|
||||
private readonly ObservableCollection<TestCaseViewModel> allTestCases = new ObservableCollection<TestCaseViewModel>();
|
||||
private readonly TraitCollectionView traitCollectionView = new TraitCollectionView();
|
||||
private CancellationTokenSource filterCancellationTokenSource = new CancellationTokenSource();
|
||||
@@ -32,10 +34,21 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
private CancellationTokenSource cancellationTokenSource;
|
||||
private bool isBusy;
|
||||
private SearchQuery searchQuery = new SearchQuery();
|
||||
private bool autoReloadAssemblies;
|
||||
|
||||
public ObservableCollection<TestAssemblyViewModel> Assemblies { get; } = new ObservableCollection<TestAssemblyViewModel>();
|
||||
public FilteredCollectionView<TestCaseViewModel, SearchQuery> FilteredTestCases { get; }
|
||||
public ObservableCollection<TraitViewModel> Traits => this.traitCollectionView.Collection;
|
||||
public bool AutoReloadAssemblies
|
||||
{
|
||||
get => autoReloadAssemblies;
|
||||
set
|
||||
{
|
||||
var oldVal = autoReloadAssemblies;
|
||||
autoReloadAssemblies = value;
|
||||
RaisePropertyChanged(nameof(AutoReloadAssemblies), oldVal, autoReloadAssemblies);
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<RecentAssemblyViewModel> RecentAssemblies { get; } = new ObservableCollection<RecentAssemblyViewModel>();
|
||||
|
||||
@@ -44,7 +57,8 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
public ICommand ExitCommand { get; }
|
||||
public ICommand WindowLoadedCommand { get; }
|
||||
public RelayCommand<CancelEventArgs> WindowClosingCommand { get; }
|
||||
public RelayCommand RunCommand { get; }
|
||||
public RelayCommand RunAllCommand { get; }
|
||||
public RelayCommand RunSelectedCommand { get; }
|
||||
public RelayCommand CancelCommand { get; }
|
||||
public ICommand TraitCheckedChangedCommand { get; }
|
||||
public ICommand TraitSelectionChangedCommand { get; }
|
||||
@@ -53,6 +67,7 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
public ICommand AssemblyReloadAllCommand { get; }
|
||||
public ICommand AssemblyRemoveCommand { get; }
|
||||
public ICommand AssemblyRemoveAllCommand { get; }
|
||||
public ICommand AutoReloadAssembliesCommand { get; }
|
||||
|
||||
public CommandBindingCollection CommandBindings { get; }
|
||||
|
||||
@@ -68,6 +83,7 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
CommandBindings = CreateCommandBindings();
|
||||
|
||||
this.testUtil = new Xunit.Runner.Wpf.Impl.RemoteTestUtil(Dispatcher.CurrentDispatcher);
|
||||
this.assemblyWatcher = new Impl.TestAssemblyWatcher(Dispatcher.CurrentDispatcher);
|
||||
this.TestCasesCaption = "Test Cases (0)";
|
||||
|
||||
this.FilteredTestCases = new FilteredCollectionView<TestCaseViewModel, SearchQuery>(
|
||||
@@ -78,7 +94,8 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
this.ExitCommand = new RelayCommand(OnExecuteExit);
|
||||
this.WindowLoadedCommand = new RelayCommand(OnExecuteWindowLoaded);
|
||||
this.WindowClosingCommand = new RelayCommand<CancelEventArgs>(OnExecuteWindowClosing);
|
||||
this.RunCommand = new RelayCommand(OnExecuteRun, CanExecuteRun);
|
||||
this.RunAllCommand = new RelayCommand(OnExecuteRunAll, CanExecuteRunAll);
|
||||
this.RunSelectedCommand = new RelayCommand(OnExecuteRunSelected, CanExecuteRunSelected);
|
||||
this.CancelCommand = new RelayCommand(OnExecuteCancel, CanExecuteCancel);
|
||||
this.TraitCheckedChangedCommand = new RelayCommand<TraitViewModel>(OnExecuteTraitCheckedChanged);
|
||||
this.TraitsClearCommand = new RelayCommand(OnExecuteTraitsClear);
|
||||
@@ -86,8 +103,10 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
this.AssemblyReloadAllCommand = new RelayCommand(OnExecuteAssemblyReloadAll);
|
||||
this.AssemblyRemoveCommand = new RelayCommand(OnExecuteAssemblyRemove, CanExecuteAssemblyRemove);
|
||||
this.AssemblyRemoveAllCommand = new RelayCommand(OnExecuteAssemblyRemoveAll);
|
||||
this.AutoReloadAssembliesCommand = new RelayCommand(OnToggleAutoReloadAssemblies);
|
||||
|
||||
RebuildRecentAssembliesMenu();
|
||||
AutoReloadAssemblies = this.settings.GetAutoReloadAssemblies();
|
||||
}
|
||||
|
||||
private void RebuildRecentAssembliesMenu()
|
||||
@@ -157,8 +176,32 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
|
||||
private void TestCases_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
TestCasesCaption = $"Test Cases ({FilteredTestCases.Count:#,0})";
|
||||
MaximumProgress = FilteredTestCases.Count;
|
||||
UpdateTestCaseInfo(useSelected: false);
|
||||
ClearSelectionFlags();
|
||||
}
|
||||
|
||||
private void ClearSelectionFlags()
|
||||
{
|
||||
foreach (var test in this.allTestCases)
|
||||
{
|
||||
test.IsSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateTestCaseInfo(bool useSelected)
|
||||
{
|
||||
var count = FilteredTestCases.Count;
|
||||
if (useSelected)
|
||||
{
|
||||
var selected = FilteredTestCases.Count(tc => tc.IsSelected);
|
||||
if (selected > 0)
|
||||
{
|
||||
count = selected;
|
||||
}
|
||||
}
|
||||
|
||||
TestCasesCaption = $"Test Cases ({count:#,0})";
|
||||
MaximumProgress = count;
|
||||
}
|
||||
|
||||
public List<TestAssemblyViewModel> SelectedAssemblies
|
||||
@@ -177,14 +220,32 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
public int TestsCompleted
|
||||
{
|
||||
get { return testsCompleted; }
|
||||
set { Set(ref testsCompleted, value);
|
||||
|
||||
if (TaskbarManager.IsPlatformSupported)
|
||||
{
|
||||
var tb = TaskbarManager.Instance;
|
||||
tb.SetProgressState(GetTaskBarState());
|
||||
tb.SetProgressValue(value, this.MaximumProgress);
|
||||
}
|
||||
set
|
||||
{
|
||||
Set(ref testsCompleted, value);
|
||||
UpdateProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private TestCaseViewModel selectedTest;
|
||||
public TestCaseViewModel SelectedTestCase
|
||||
{
|
||||
get { return selectedTest; }
|
||||
|
||||
set
|
||||
{
|
||||
Set(ref selectedTest, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateProgress()
|
||||
{
|
||||
if (TaskbarManager.IsPlatformSupported)
|
||||
{
|
||||
var tb = TaskbarManager.Instance;
|
||||
tb.SetProgressState(GetTaskBarState());
|
||||
tb.SetProgressValue(this.TestsCompleted, this.MaximumProgress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,14 +287,24 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
public int MaximumProgress
|
||||
{
|
||||
get { return maximumProgress; }
|
||||
set { Set(ref maximumProgress, value); }
|
||||
|
||||
set
|
||||
{
|
||||
Set(ref maximumProgress, value);
|
||||
UpdateProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private TestState currentRunState;
|
||||
public TestState CurrentRunState
|
||||
{
|
||||
get { return currentRunState; }
|
||||
set { Set(ref currentRunState, value); }
|
||||
|
||||
set
|
||||
{
|
||||
Set(ref currentRunState, value);
|
||||
UpdateProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private string output = string.Empty;
|
||||
@@ -336,12 +407,26 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
foreach (var assemblyViewModel in newAssemblyViewModels)
|
||||
{
|
||||
assemblyViewModel.State = AssemblyState.Ready;
|
||||
assemblyWatcher.AddAssembly(assemblyViewModel.FileName);
|
||||
}
|
||||
|
||||
RebuildRecentAssembliesMenu();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReloadAssemblies(IEnumerable<string> assemblies)
|
||||
{
|
||||
if (IsBusy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var testAssemblies = Assemblies.Where(assembly => assemblies.Contains(assembly.FileName));
|
||||
Application.Current.Dispatcher.InvokeAsync(() => ReloadAssemblies(testAssemblies));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task ReloadAssemblies(IEnumerable<TestAssemblyViewModel> assemblies)
|
||||
{
|
||||
try
|
||||
@@ -377,6 +462,7 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
{
|
||||
foreach (var assembly in assemblies.ToList())
|
||||
{
|
||||
assemblyWatcher.RemoveAssembly(assembly.FileName);
|
||||
RemoveAssemblyTestCases(assembly.FileName);
|
||||
Assemblies.Remove(assembly);
|
||||
}
|
||||
@@ -391,6 +477,7 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
{
|
||||
if (string.Compare(this.allTestCases[i].AssemblyFileName, assemblyPath, StringComparison.OrdinalIgnoreCase) == 0)
|
||||
{
|
||||
this.allTestCaseUniqueIDs.Remove(this.allTestCases[i].UniqueID);
|
||||
this.allTestCases.RemoveAt(i);
|
||||
}
|
||||
else
|
||||
@@ -401,10 +488,10 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloading an assembly could have changed the traits. There is no easy way
|
||||
/// to selectively edit this list (traits can cross assembly boundaries). Just
|
||||
/// Reloading an assembly could have changed the traits. There is no easy way
|
||||
/// to selectively edit this list (traits can cross assembly boundaries). Just
|
||||
/// do a full reload instead.
|
||||
/// way to
|
||||
/// way to
|
||||
/// </summary>
|
||||
private void RebuildTraits()
|
||||
{
|
||||
@@ -421,7 +508,8 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
set
|
||||
{
|
||||
isBusy = value;
|
||||
RunCommand.RaiseCanExecuteChanged();
|
||||
RunAllCommand.RaiseCanExecuteChanged();
|
||||
RunSelectedCommand.RaiseCanExecuteChanged();
|
||||
CancelCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
@@ -463,19 +551,44 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
=> (fileName?.EndsWith(".config", StringComparison.OrdinalIgnoreCase) ?? false) ||
|
||||
(fileName?.EndsWith(".json", StringComparison.OrdinalIgnoreCase) ?? false);
|
||||
|
||||
private bool CanExecuteRun()
|
||||
private bool CanExecuteRunAll()
|
||||
=> !IsBusy && FilteredTestCases.Any();
|
||||
|
||||
private async void OnExecuteRun()
|
||||
private bool CanExecuteRunSelected()
|
||||
=> !IsBusy && SelectedTestCase != null;
|
||||
|
||||
private async void OnExecuteRunAll()
|
||||
{
|
||||
Debug.Assert(this.runningTests == null);
|
||||
UpdateTestCaseInfo(useSelected: false);
|
||||
|
||||
await ExecuteTestSessionOperation(RunTests);
|
||||
await ExecuteTestSessionOperation(RunFilteredTests);
|
||||
|
||||
this.runningTests = null;
|
||||
}
|
||||
|
||||
private List<Task> RunTests()
|
||||
private List<Task> RunFilteredTests()
|
||||
{
|
||||
return RunTests(FilteredTestCases.ToImmutableList());
|
||||
}
|
||||
|
||||
private async void OnExecuteRunSelected()
|
||||
{
|
||||
Debug.Assert(this.runningTests == null);
|
||||
Debug.Assert(this.SelectedTestCase != null);
|
||||
UpdateTestCaseInfo(useSelected: true);
|
||||
|
||||
await ExecuteTestSessionOperation(RunSelectedTests);
|
||||
|
||||
this.runningTests = null;
|
||||
}
|
||||
|
||||
private List<Task> RunSelectedTests()
|
||||
{
|
||||
return RunTests(ImmutableList.CreateRange(this.FilteredTestCases.Where(tc => tc.IsSelected)));
|
||||
}
|
||||
|
||||
private List<Task> RunTests(ImmutableList<TestCaseViewModel> tests)
|
||||
{
|
||||
Debug.Assert(this.isBusy);
|
||||
Debug.Assert(this.cancellationTokenSource != null);
|
||||
@@ -488,7 +601,7 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
CurrentRunState = TestState.NotRun;
|
||||
Output = string.Empty;
|
||||
|
||||
this.runningTests = FilteredTestCases.ToImmutableList();
|
||||
this.runningTests = tests;
|
||||
|
||||
foreach (var tc in this.runningTests)
|
||||
{
|
||||
@@ -513,7 +626,7 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
{
|
||||
if (testCase.AssemblyFileName == assemblyFileName)
|
||||
{
|
||||
builder.Add(testCase.DisplayName);
|
||||
builder.Add(testCase.UniqueID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,6 +670,9 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
|
||||
foreach (var testCase in testCases)
|
||||
{
|
||||
if (this.allTestCaseUniqueIDs.Contains(testCase.UniqueID))
|
||||
continue;
|
||||
|
||||
traitWorkerList.Clear();
|
||||
|
||||
// Get or create traits.
|
||||
@@ -579,6 +695,7 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
|
||||
var testCaseViewModel = new TestCaseViewModel(
|
||||
testCase.DisplayName,
|
||||
testCase.UniqueID,
|
||||
testCase.SkipReason,
|
||||
testCase.AssemblyPath,
|
||||
traitWorkerList);
|
||||
@@ -588,6 +705,7 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
TestsSkipped++;
|
||||
}
|
||||
|
||||
this.allTestCaseUniqueIDs.Add(testCase.UniqueID);
|
||||
this.allTestCases.Add(testCaseViewModel);
|
||||
}
|
||||
}
|
||||
@@ -598,7 +716,7 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
|
||||
foreach (var result in testResultData)
|
||||
{
|
||||
var testCase = this.runningTests.Single(x => x.DisplayName == result.TestCaseDisplayName);
|
||||
var testCase = this.runningTests.Single(x => x.UniqueID == result.TestCaseUniqueID);
|
||||
testCase.State = result.TestState;
|
||||
|
||||
TestsCompleted++;
|
||||
@@ -677,6 +795,29 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
{
|
||||
RemoveAssemblies(Assemblies.ToArray());
|
||||
}
|
||||
private void OnToggleAutoReloadAssemblies()
|
||||
{
|
||||
ToggleReloadAssemblies();
|
||||
}
|
||||
|
||||
private void ToggleReloadAssemblies()
|
||||
{
|
||||
this.settings.ToggleAutoReloadAssemblies();
|
||||
AutoReloadAssemblies = this.settings.GetAutoReloadAssemblies();
|
||||
UpdateAutoReloadStatus();
|
||||
}
|
||||
|
||||
private void UpdateAutoReloadStatus()
|
||||
{
|
||||
if (AutoReloadAssemblies)
|
||||
{
|
||||
assemblyWatcher.EnableWatch(ReloadAssemblies);
|
||||
}
|
||||
else
|
||||
{
|
||||
assemblyWatcher.DisableWatch();
|
||||
}
|
||||
}
|
||||
|
||||
public bool FilterPassedTests
|
||||
{
|
||||
@@ -720,7 +861,17 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
public static TestComparer Instance { get; } = new TestComparer();
|
||||
|
||||
public int Compare(TestCaseViewModel x, TestCaseViewModel y)
|
||||
=> StringComparer.Ordinal.Compare(x.DisplayName, y.DisplayName);
|
||||
{
|
||||
int result = StringComparer.OrdinalIgnoreCase.Compare(x.DisplayName, y.DisplayName);
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
||||
result = StringComparer.Ordinal.Compare(x.DisplayName, y.DisplayName);
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
||||
return StringComparer.Ordinal.Compare(x.UniqueID, y.UniqueID);
|
||||
}
|
||||
|
||||
private TestComparer() { }
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
private TestState _state = TestState.NotRun;
|
||||
|
||||
public string DisplayName { get; }
|
||||
public string UniqueID { get; }
|
||||
public string SkipReason { get; }
|
||||
public string AssemblyFileName { get; }
|
||||
public ImmutableArray<TraitViewModel> Traits { get; }
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
public bool HasSkipReason => !string.IsNullOrEmpty(this.SkipReason);
|
||||
|
||||
@@ -22,9 +24,10 @@ namespace Xunit.Runner.Wpf.ViewModel
|
||||
set { Set(ref _state, value); }
|
||||
}
|
||||
|
||||
public TestCaseViewModel(string displayName, string skipReason, string assemblyFileName, IEnumerable<TraitViewModel> traits)
|
||||
public TestCaseViewModel(string displayName, string uniqueID, string skipReason, string assemblyFileName, IEnumerable<TraitViewModel> traits)
|
||||
{
|
||||
this.DisplayName = displayName;
|
||||
this.UniqueID = uniqueID;
|
||||
this.SkipReason = skipReason;
|
||||
this.AssemblyFileName = assemblyFileName;
|
||||
this.Traits = traits.ToImmutableArray();
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="CommonServiceLocator" version="1.3" targetFramework="net452" />
|
||||
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net46" developmentDependency="true" />
|
||||
<package id="MvvmLight" version="5.3.0.0" targetFramework="net46" />
|
||||
<package id="MvvmLightLibs" version="5.3.0.0" targetFramework="net46" />
|
||||
<package id="NuGet.CommandLine" version="3.4.3" targetFramework="net46" developmentDependency="true" />
|
||||
<package id="System.Collections" version="4.0.10" targetFramework="net46" />
|
||||
<package id="System.Collections.Immutable" version="1.1.37" targetFramework="net452" />
|
||||
<package id="System.Diagnostics.Debug" version="4.0.10" targetFramework="net46" />
|
||||
<package id="System.Globalization" version="4.0.10" targetFramework="net46" />
|
||||
<package id="System.Linq" version="4.0.0" targetFramework="net46" />
|
||||
<package id="System.Resources.ResourceManager" version="4.0.0" targetFramework="net46" />
|
||||
<package id="System.Runtime" version="4.0.20" targetFramework="net46" />
|
||||
<package id="System.Runtime.Extensions" version="4.0.10" targetFramework="net46" />
|
||||
<package id="System.Threading" version="4.0.10" targetFramework="net46" />
|
||||
<package id="NuGet.CommandLine" version="2.8.3" targetFramework="net46" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Collections.Immutable" version="1.4.0-preview1-25305-02" targetFramework="net46" />
|
||||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Globalization" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Linq" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Runtime" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Threading" version="4.3.0" targetFramework="net46" />
|
||||
<package id="Tvl.NuGet.BuildTasks" version="1.0.0-alpha002" targetFramework="net46" developmentDependency="true" />
|
||||
<package id="WindowsAPICodePack-Core" version="1.1.2" targetFramework="net46" />
|
||||
<package id="WindowsAPICodePack-Shell" version="1.1.1" targetFramework="net46" />
|
||||
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<Import Project="..\packages\Tvl.NuGet.BuildTasks.1.0.0-alpha002\build\Tvl.NuGet.BuildTasks.props" Condition="Exists('..\packages\Tvl.NuGet.BuildTasks.1.0.0-alpha002\build\Tvl.NuGet.BuildTasks.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -68,10 +70,10 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.1.1.37\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="System.Collections.Immutable, Version=1.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.1.4.0-preview1-25305-02\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
||||
@@ -106,6 +108,8 @@
|
||||
<Compile Include="Impl\RemoteTestUtil.Connection.cs" />
|
||||
<Compile Include="Impl\RemoteTestUtil.BackgroundRunner.cs" />
|
||||
<Compile Include="Impl\RemoteTestUtil.cs" />
|
||||
<Compile Include="Impl\TestAssemblyWatcher.cs" />
|
||||
<Compile Include="ITestAssemblyWatcher.cs" />
|
||||
<Compile Include="ITestUtil.cs" />
|
||||
<Compile Include="Persistence\Settings.cs" />
|
||||
<Compile Include="Persistence\Storage.cs" />
|
||||
@@ -149,14 +153,16 @@
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<AppDesigner Include="Properties\" />
|
||||
<None Include="xunit.runner.wpf.nuspec">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="xunit.runner.wpf.targets">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<NuGetManifest Include="xunit.runner.wpf.nuspec">
|
||||
<Version>$(NuPkgVersion)</Version>
|
||||
</NuGetManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
@@ -197,9 +203,13 @@
|
||||
<Resource Include="Artwork\Application.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="AfterBuild">
|
||||
<Exec Command=""$(SolutionDir)packages\NuGet.CommandLine.3.4.3\tools\NuGet.exe" pack xunit.runner.wpf.nuspec -Version $(NuPkgVersion) -OutputDirectory ." WorkingDirectory="$(OutDir)" LogStandardErrorAsError="true" ConsoleToMSBuild="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
|
||||
</Exec>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Tvl.NuGet.BuildTasks.1.0.0-alpha002\build\Tvl.NuGet.BuildTasks.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Tvl.NuGet.BuildTasks.1.0.0-alpha002\build\Tvl.NuGet.BuildTasks.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Tvl.NuGet.BuildTasks.1.0.0-alpha002\build\Tvl.NuGet.BuildTasks.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Tvl.NuGet.BuildTasks.1.0.0-alpha002\build\Tvl.NuGet.BuildTasks.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Tvl.NuGet.BuildTasks.1.0.0-alpha002\build\Tvl.NuGet.BuildTasks.targets" Condition="Exists('..\packages\Tvl.NuGet.BuildTasks.1.0.0-alpha002\build\Tvl.NuGet.BuildTasks.targets')" />
|
||||
</Project>
|
||||
Reference in New Issue
Block a user