Skip to content

Commit

Permalink
Starting changes to support multiple test assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
codereflection committed Dec 1, 2011
1 parent 6d569fa commit b7b755b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/Giles.Core/Configuration/GilesConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class GilesConfig : INotifyPropertyChanged
public IDictionary<string, RunnerAssembly> TestRunners = new Dictionary<string, RunnerAssembly>();
public List<IUserDisplay> UserDisplay = new List<IUserDisplay>();
private long buildDelay = 500;
public string TestAssemblyPath { get; set; }
public List<string> TestAssemblies { get; set; }
public string SolutionPath { get; set; }

public long BuildDelay
Expand Down
11 changes: 6 additions & 5 deletions src/Giles.Core/Configuration/GilesConfigBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
using Giles.Core.UI;
using System.Collections.Generic;
using Giles.Core.UI;

namespace Giles.Core.Configuration
{
public class GilesConfigBuilder
{
readonly GilesConfig config = new GilesConfig();
readonly string solutionPath;
readonly string testAssemblyPath;
readonly List<string> testAssemblies;

public GilesConfigBuilder(string solutionPath, string testAssemblyPath)
public GilesConfigBuilder(string solutionPath, List<string> testAssemblies)
{
this.solutionPath = solutionPath;
this.testAssemblyPath = testAssemblyPath;
this.testAssemblies = testAssemblies;
}

public GilesConfig Build()
{
config.TestAssemblyPath = testAssemblyPath;
config.TestAssemblies = testAssemblies;
config.SolutionPath = "" + solutionPath + "";

config.UserDisplay.Add(new ConsoleUserDisplay());
Expand Down
2 changes: 1 addition & 1 deletion src/Giles.Core/Watchers/SourceWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void RunNow()
var listener = GetListener.Invoke(config);

var manager = new GilesAppDomainManager();
var runResult = manager.Run(config.TestAssemblyPath);
var runResult = manager.Run(config.TestAssemblies.FirstOrDefault());
runResult.Each(result =>
{
result.Messages.Each(m => listener.WriteLine(m, "Output"));
Expand Down
5 changes: 3 additions & 2 deletions src/Giles.Specs/Core/Configuration/GilesConfigBuilderSpecs.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Giles.Core.Configuration;
Expand Down Expand Up @@ -31,7 +32,7 @@ public class a_giles_config
fileSystem.GetDirectoryName(solutionPath).Returns(solutionFolder);
projectRoot = @"c:\solutionRoot";
builder = new GilesConfigBuilder(solutionPath, testAssemblyPath);
builder = new GilesConfigBuilder(solutionPath, new List<string> { testAssemblyPath });
};
}

Expand All @@ -45,7 +46,7 @@ public class when_building : a_giles_config
config.TestRunners.All(x => x.Value.Path == testRunnerExe).ShouldBeTrue();

It assigned_the_test_assembly_path = () =>
config.TestAssemblyPath.ShouldEqual(testAssemblyPath);
config.TestAssemblies.ShouldContain(testAssemblyPath);

It assigned_the_solution_path = () =>
config.SolutionPath.ShouldEqual(solutionPath);
Expand Down
57 changes: 37 additions & 20 deletions src/Giles/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,27 @@
using Giles.Options;
using Ninject;

namespace Giles {
class Program {
namespace Giles
{
class Program
{
static SourceWatcher sourceWatcher;
static GilesConfig config;
static bool quitRequested;
static IList<InteractiveMenuOption> menuOptions;
static StandardKernel kernel;

static void Main(string[] args) {
static void Main(string[] args)
{
var options = new CLOptions();

Console.WriteLine(GetGilesFunnyLine());

var parser = new CommandLineParser(
new CommandLineParserSettings(false, Console.Error));

if (!parser.ParseArguments(args, options)) {
if (!parser.ParseArguments(args, options))
{
Console.WriteLine("Unable to determine what command lines arguments were used, check the help above!\nThe minimum needed is the -s [solution file path].");
Environment.Exit(1);
}
Expand Down Expand Up @@ -54,7 +58,7 @@ static GilesConfig GetGilesConfigFor(CLOptions options)
solutionPath = Path.GetFullPath(solutionPath);
testAssemblyPath = Path.GetFullPath(testAssemblyPath);

return SetupGilesConfig(solutionPath, testAssemblyPath);
return SetupGilesConfig(solutionPath, new List<string> { testAssemblyPath });
}

static string GetGilesFunnyLine()
Expand All @@ -67,7 +71,8 @@ static string GetGilesFunnyLine()
name.Version.Build);
}

static SourceWatcher StartSourceWatcher() {
static SourceWatcher StartSourceWatcher()
{
var watcher = kernel.Get<SourceWatcher>();

// HACK: Only *.cs files? Really?
Expand Down Expand Up @@ -100,20 +105,23 @@ private static string FindTestAssembly(string solutionPath)
return assemblies.Count() == 0 ? null : assemblies.First();
}

static GilesConfig SetupGilesConfig(string solutionPath, string testAssemblyPath) {
static GilesConfig SetupGilesConfig(string solutionPath, List<string> testAssemblies)
{

var builder = new GilesConfigBuilder(solutionPath, testAssemblyPath);
var builder = new GilesConfigBuilder(solutionPath, testAssemblies);
return builder.Build();
}

static void ConsoleSetup() {
static void ConsoleSetup()
{
Console.Clear();
Console.Title = GetGilesFunnyLine();
Console.WriteLine("Giles - your own personal watcher");
Console.WriteLine("\t\"I'd like to test that theory...\"\n\n");
}

static InteractiveMenuOption[] GetInteractiveMenuOptions() {
static InteractiveMenuOption[] GetInteractiveMenuOptions()
{
return new[]
{
new InteractiveMenuOption { HandlesKey = key => key == "?", Task = DisplayInteractiveMenuOptions },
Expand All @@ -128,8 +136,10 @@ static InteractiveMenuOption[] GetInteractiveMenuOptions() {
}


static void MainFeedbackLoop() {
while (!quitRequested) {
static void MainFeedbackLoop()
{
while (!quitRequested)
{
var keyValue = Console.ReadKey(true).KeyChar.ToString().ToLower();

menuOptions
Expand All @@ -139,11 +149,13 @@ static void MainFeedbackLoop() {
Console.WriteLine("Until next time...");
}

static void RequestQuit() {
static void RequestQuit()
{
quitRequested = true;
}

static void SetBuildDelay() {
static void SetBuildDelay()
{
config.BuildDelay = GetUserValue(config.BuildDelay);
}

Expand All @@ -155,14 +167,16 @@ static void DisplayErrors()
Console.WriteLine("Please run some tests first...");
}

static void DisplayVerboseResults() {
static void DisplayVerboseResults()
{
if (LastRunResults.GilesTestListener != null)
LastRunResults.GilesTestListener.DisplayVerboseResults();
else
Console.WriteLine("Please run some tests first...");
}

static T GetUserValue<T>(T defaultValue) {
static T GetUserValue<T>(T defaultValue)
{
Console.Write("Enter new value ({0}): ", defaultValue);
var newValue = Console.ReadLine();

Expand All @@ -172,16 +186,18 @@ static T GetUserValue<T>(T defaultValue) {
return (T)Convert.ChangeType(newValue, typeof(T));
}

static void DisplayConfig() {
static void DisplayConfig()
{
Console.WriteLine("\nCurrent Configuration");
Console.WriteLine(" Build Delay: " + config.BuildDelay);
Console.WriteLine(" Solution: " + config.SolutionPath);
Console.WriteLine(" Test Assembly: " + config.TestAssemblyPath);
Console.WriteLine(" Test Assembly: " + config.TestAssemblies);
config.TestRunners.Each(r => Console.WriteLine(" " + r.Key + " Has been enabled"));
Console.WriteLine();
}

static void DisplayInteractiveMenuOptions() {
static void DisplayInteractiveMenuOptions()
{
Console.WriteLine("Interactive Console Options:");
Console.WriteLine(" ? = Display options");
Console.WriteLine(" C = Clear the window");
Expand All @@ -195,7 +211,8 @@ static void DisplayInteractiveMenuOptions() {
}
}

public class InteractiveMenuOption {
public class InteractiveMenuOption
{
public Func<string, bool> HandlesKey;
public Action Task;
}
Expand Down

0 comments on commit b7b755b

Please sign in to comment.