Permalink
Browse files

One less proxy object, what's not to like?

  • Loading branch information...
1 parent 8f9472d commit eaf2c54e7eaf13212d38609b270b9591f5d195f0 @drunkcod committed Mar 4, 2012
View
@@ -4,17 +4,6 @@
namespace Cone.Build
{
- [Serializable]
- public class CrossDomainRunTestsCommand
- {
- public ICrossDomainLogger Logger;
- public string[] Paths;
-
- public void Execute() {
- new CrossDomainConeRunner().RunTests(Logger, Paths);
- }
- }
-
public class ConeTask : MarshalByRefObject, ITask, ICrossDomainLogger
{
const string SenderName = "Cone";
@@ -25,13 +14,9 @@ public class ConeTask : MarshalByRefObject, ITask, ICrossDomainLogger
public bool Execute() {
try {
noFailures = true;
- var testDomain = AppDomain.CreateDomain("TestDomain", null, new AppDomainSetup {
- ApplicationBase = System.IO.Path.GetDirectoryName(Path),
- ShadowCopyFiles = "true"
- });
-
- testDomain.DoCallBack(new CrossDomainRunTestsCommand { Logger = this, Paths = new[] { Path } }.Execute);
- AppDomain.Unload(testDomain);
+ CrossDomainConeRunner.RunTestsInTemporaryDomain(this,
+ System.IO.Path.GetDirectoryName(Path),
+ new []{ Path });
return noFailures;
} catch(Exception e) {
BuildEngine.LogErrorEvent(new BuildErrorEventArgs("RuntimeFailure", string.Empty, string.Empty, 0, 0, 0, 0, string.Format("{0}", e), string.Empty, SenderName));
@@ -40,7 +25,7 @@ public class ConeTask : MarshalByRefObject, ITask, ICrossDomainLogger
}
void ICrossDomainLogger.Info(string message) {
- BuildEngine.LogMessageEvent(new BuildMessageEventArgs(message, string.Empty, SenderName, MessageImportance.High));
+ BuildEngine.LogMessageEvent(new BuildMessageEventArgs(message.TrimEnd(), string.Empty, SenderName, MessageImportance.High));
}
void ICrossDomainLogger.Failure(string file, int line, int column, string message) {
@@ -31,12 +31,31 @@ public class CrossDomainLoggerAdapater : IConeLogger
}
}
- public class CrossDomainConeRunner : MarshalByRefObject
+ public class CrossDomainConeRunner
{
- public void RunTests(ICrossDomainLogger logger, string[] assemblyPaths) {
- new SimpleConeRunner() {
- ShowProgress = false
- }.RunTests(new CrossDomainLoggerAdapater(logger), Array.ConvertAll(assemblyPaths, Assembly.LoadFrom));
+ [Serializable]
+ class RunTestsCommand
+ {
+ public ICrossDomainLogger Logger;
+ public string[] AssemblyPaths;
+
+ public void Execute() {
+ new SimpleConeRunner() {
+ ShowProgress = false
+ }.RunTests(new CrossDomainLoggerAdapater(Logger), Array.ConvertAll(AssemblyPaths, Assembly.LoadFrom));
+ }
+ }
+
+ public static void RunTestsInTemporaryDomain(ICrossDomainLogger logger, string applicationBase, string[] assemblyPaths) {
+ var testDomain = AppDomain.CreateDomain("TestDomain", null, new AppDomainSetup {
+ ApplicationBase = applicationBase,
+ ShadowCopyFiles = "true"
+ });
+ testDomain.DoCallBack(new RunTestsCommand {
+ Logger = logger,
+ AssemblyPaths = assemblyPaths
+ }.Execute);
+ AppDomain.Unload(testDomain);
}
}
}
View
Binary file not shown.
View
Binary file not shown.

0 comments on commit eaf2c54

Please sign in to comment.