Skip to content

Commit

Permalink
refactored runners to use the CommandProcessExecutor and starting to …
Browse files Browse the repository at this point in the history
…refactor direct console access to use the IUserDisplay interface
  • Loading branch information
NotMyself committed Feb 17, 2011
1 parent b8d5595 commit e1183aa
Show file tree
Hide file tree
Showing 19 changed files with 86,072 additions and 19 deletions.
Binary file added lib/Growl.Connector/Growl.Connector.dll
Binary file not shown.
Binary file added lib/Growl.Connector/Growl.CoreLibrary.dll
Binary file not shown.
25 changes: 25 additions & 0 deletions lib/Growl.Connector/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Growl.NET GNTP Connector Library
-----------------------------------------------
Copyright (c) 2008 - Growl for Windows
All rights reserved

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

Binary file added lib/log4net.1.2.10/lib/1.0/log4net.dll
Binary file not shown.
28,655 changes: 28,655 additions & 0 deletions lib/log4net.1.2.10/lib/1.0/log4net.xml

Large diffs are not rendered by default.

Binary file added lib/log4net.1.2.10/lib/1.1/log4net.dll
Binary file not shown.
28,655 changes: 28,655 additions & 0 deletions lib/log4net.1.2.10/lib/1.1/log4net.xml

Large diffs are not rendered by default.

Binary file added lib/log4net.1.2.10/lib/2.0/log4net.dll
Binary file not shown.
28,655 changes: 28,655 additions & 0 deletions lib/log4net.1.2.10/lib/2.0/log4net.xml

Large diffs are not rendered by default.

Binary file added lib/log4net.1.2.10/log4net.1.2.10.nupkg
Binary file not shown.
8 changes: 8 additions & 0 deletions src/Giles.Core/Configuration/GilesConfig.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Giles.Core.Runners;
using Giles.Core.UI;

namespace Giles.Core.Configuration
{
public class GilesConfig : INotifyPropertyChanged
{
public IDictionary<string, RunnerAssembly> TestRunners = new Dictionary<string, RunnerAssembly>();

public IEnumerable<IUserDisplay> UserDisplay = Enumerable.Empty<IUserDisplay>();

public string TestAssemblyPath { get; set; }

Expand Down Expand Up @@ -38,5 +44,7 @@ public long BuildDelay
NotifyPropertyChanged("BuildDelay");
}
}

public CommandProcessExecutor Executor { get; set; }
}
}
5 changes: 5 additions & 0 deletions src/Giles.Core/Configuration/GilesConfigFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.IO;
using System.Linq;
using Giles.Core.IO;
using Giles.Core.Runners;
using Giles.Core.UI;
using Machine.Specifications.Utility;

namespace Giles.Core.Configuration
Expand Down Expand Up @@ -30,6 +32,9 @@ public GilesConfig Build()
LocateTestRunners();
config.TestAssemblyPath = testAssemblyPath;
config.SolutionPath = solutionPath;

config.UserDisplay = new[] {new ConsoleUserDisplay()};
config.Executor = new CommandProcessExecutor();
return config;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Giles.Core/Giles.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@
<Compile Include="IO\IFileWatcherFactory.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Runners\BuildRunner.cs" />
<Compile Include="Runners\CommandProcessExecutor.cs" />
<Compile Include="Runners\IRunner.cs" />
<Compile Include="Runners\RunnerBase.cs" />
<Compile Include="Runners\TestRunner.cs" />
<Compile Include="UI\ConsoleUserDisplay.cs" />
<Compile Include="UI\IUserDisplay.cs" />
<Compile Include="Watchers\SourceWatcher.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
7 changes: 1 addition & 6 deletions src/Giles.Core/Runners/BuildRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ public void Run()
Console.WriteLine("Building...");

watch.Start();
buildProcess.Start();
var output = buildProcess.StandardOutput.ReadToEnd();

buildProcess.WaitForExit();
buildProcess.Close();
buildProcess.Dispose();
config.Executor.Execute(settings.MsBuild, config.SolutionPath);
watch.Stop();

Console.WriteLine("Building complete in {0} seconds.", watch.Elapsed.TotalSeconds);
Expand Down
40 changes: 40 additions & 0 deletions src/Giles.Core/Runners/CommandProcessExecutor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Diagnostics;

namespace Giles.Core.Runners
{
public class CommandProcessExecutor
{
public Process SetupProcess(string fileName, string arguments)
{
return new Process
{
StartInfo =
{
FileName = fileName,
Arguments = arguments,
UseShellExecute = false,
RedirectStandardOutput = true
}
};
}

public ExecutionResult Execute(string executable, string arguments)
{
var output = string.Empty;
var process = SetupProcess(executable, arguments);
process.Start();
output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
process.Close();
process.Dispose();
return new ExecutionResult {ExitCode = process.ExitCode, Output = output};
}
}

public class ExecutionResult
{
public string Output { get; set; }
public int ExitCode { get; set; }
}
}
16 changes: 4 additions & 12 deletions src/Giles.Core/Runners/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,14 @@ void ExecuteRunner(KeyValuePair<string, RunnerAssembly> x)
if (x.Value.Options.Count > 0)
args += " " + x.Value.Options.Aggregate((working, next) => working + next);

var testProcess = SetupProcess(x.Value.Path, args);
testProcess.Start();
var output = testProcess.StandardOutput.ReadToEnd();

testProcess.WaitForExit();

var exitCode = testProcess.ExitCode;

testProcess.Close();
testProcess.Dispose();

var result = config.Executor.Execute(x.Value.Path, args);

Console.WriteLine("\n\n======= {0} TEST RUNNER RESULTS =======", x.Key.ToUpper().Replace(".EXE", string.Empty));
Console.ForegroundColor = exitCode != 0 ?
Console.ForegroundColor = result.ExitCode != 0 ?
ConsoleColor.Red : defaultConsoleColor;

Console.WriteLine(output);
Console.WriteLine(result.Output);

Console.ForegroundColor = defaultConsoleColor;
}
Expand Down
7 changes: 7 additions & 0 deletions src/Giles.Core/UI/ConsoleUserDisplay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Giles.Core.UI
{
public class ConsoleUserDisplay : IUserDisplay
{

}
}
7 changes: 7 additions & 0 deletions src/Giles.Core/UI/IUserDisplay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Giles.Core.UI
{
public interface IUserDisplay
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ public class when_building : a_giles_config

It recognized_the_mspec_test_runner_options = () =>
config.TestRunners.First(x => x.Key == "mspec.exe").Value.Options.ShouldBeEmpty();


It should_configure_the_console_user_display = () =>
config.UserDisplay.Count().ShouldBeGreaterThan(0);

It should_configure_a_command_process_executor = () =>
config.Executor.ShouldNotBeNull();

}

}

0 comments on commit e1183aa

Please sign in to comment.