Permalink
Browse files

Fix #38 but MD assemblies are delay-signed :-(

  • Loading branch information...
1 parent 03e52a6 commit 96481116c069bb5e138090bc665161fb5a311fb4 @praeclarum committed May 17, 2012
Showing with 68 additions and 9 deletions.
  1. +1 −0 QuickTestRunner/Program.cs
  2. +1 −0 QuickTestRunner/QuickTestRunner.csproj
  3. +38 −7 QuickTestVS/QuickTest.cs
  4. +28 −2 QuickTestVS/TestWindow.cs
@@ -16,6 +16,7 @@ public class Program
public static void Main (string[] args)
{
TestPlan plan = TestPlan.Open (args[0]);
+
new Program {
_plan = plan,
}.Run ();
@@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <NoStdLib>false</NoStdLib>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
View
@@ -75,11 +75,13 @@ public Test GetTest (Guid id)
public class TestPlan
{
public string AssemblyPath { get; set; }
+ public List<TestAssemblyReference> References { get; set; }
public List<Test> Tests { get; set; }
public TestPlan ()
{
AssemblyPath = "";
+ References = new List<TestAssemblyReference> ();
Tests = new List<Test> ();
}
@@ -129,27 +131,39 @@ public void Run ()
}
}
- List<IGrouping<string, string>> _referenceAssemblies;
+ List<IGrouping<string, string>> _systemReferenceAssemblies;
/// <summary>
/// http://blogs.msdn.com/b/msbuild/archive/2007/04/12/new-reference-assemblies-location.aspx
/// </summary>
- void AddReferenceAssemblies ()
+ void AddSystemReferenceAssemblies ()
{
var dir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ProgramFiles), "Reference Assemblies");
var dlls = Directory.EnumerateFiles (dir, "*.dll", SearchOption.AllDirectories);
- _referenceAssemblies = dlls.GroupBy (x => Path.GetFileNameWithoutExtension (x)).ToList ();
+ _systemReferenceAssemblies = dlls.GroupBy (x => Path.GetFileNameWithoutExtension (x)).ToList ();
}
System.Reflection.Assembly CurrentDomain_AssemblyResolve (object sender, ResolveEventArgs args)
{
- if (_referenceAssemblies == null) {
- AddReferenceAssemblies ();
+ var name = args.Name;
+
+ //
+ // Try to find it in our known references
+ //
+ foreach (var r in References) {
+ if (name.StartsWith (r.Name + ",")) {
+ return Assembly.LoadFrom (r.Path);
+ }
}
- var name = args.Name;
+ //
+ // Otherwise, scan the system
+ //
+ if (_systemReferenceAssemblies == null) {
+ AddSystemReferenceAssemblies ();
+ }
- foreach (var ra in _referenceAssemblies) {
+ foreach (var ra in _systemReferenceAssemblies) {
if (args.Name.StartsWith (ra.Key)) {
foreach (var raa in ra) {
return Assembly.LoadFrom (raa);
@@ -162,6 +176,23 @@ System.Reflection.Assembly CurrentDomain_AssemblyResolve (object sender, Resolve
}
[Serializable]
+ public class TestAssemblyReference
+ {
+ public string Name { get; set; }
+ public string Version { get; set; }
+ public string Culture { get; set; }
+ public string PublicKeyToken { get; set; }
+ public string Path { get; set; }
+ public bool StrongName { get; set; }
+
+ public override string ToString ()
+ {
+ return string.Format ("{0}, Version={1}, Culture={2}, PublicKeyToken={3} @{4}",
+ Name, Version, string.IsNullOrEmpty (Culture) ? "neutral" : Culture, PublicKeyToken, Path);
+ }
+ }
+
+ [Serializable]
public class TestArgument
{
public string Name { get; set; }
View
@@ -441,6 +441,9 @@ void RunRows (IEnumerable<int> rowIndices)
var plan = new TestPlan ();
+ //
+ // Find all the tests that need to run
+ //
var nargs = _paramInfos.Count;
foreach (var rowIndex in rowIndices) {
@@ -458,10 +461,33 @@ void RunRows (IEnumerable<int> rowIndices)
if (plan.Tests.Count == 0) return;
- plan.AssemblyPath = GetAssemblyPath (_funcElm.ProjectItem.ContainingProject);
+ //
+ // Get the extra info needed by the test plan
+ //
+ var project = _funcElm.ProjectItem.ContainingProject;
+ plan.AssemblyPath = GetAssemblyPath (project);
+ try {
+ var references = ((dynamic)project.Object).References;
+
+ foreach (var item in references) {
+ plan.References.Add (new TestAssemblyReference {
+ Name = item.Name,
+ Version = item.Version,
+ Culture = item.Culture,
+ PublicKeyToken = item.PublicKeyToken.ToString ().ToLowerInvariant (),
+ Path = item.Path,
+ StrongName = item.StrongName,
+ });
+ }
+ }
+ catch (Exception) {
+ }
+
+ //
+ // Run it
+ //
Progress.Visible = true;
SetStatus (InfoStatusIcon, "Test run in progress");
-
ThreadPool.QueueUserWorkItem (delegate {
RunTests (plan);
});

0 comments on commit 9648111

Please sign in to comment.