Skip to content
Browse files

and more cleanup. nice.

  • Loading branch information...
1 parent 9a5a4e9 commit 8f0df8b4ca12f79444623c47264029c557ceddad Lucas Meijer committed Apr 15, 2012
Showing with 17 additions and 11 deletions.
  1. +3 −2 DependencyGraph.cs
  2. +8 −1 TargetGenerateSettings.cs
  3. +3 −3 Tests/DifferentInputFiles.cs
  4. +1 −3 Tests/SimpleCopyDepGraph.cs
  5. +2 −2 Tests/TargetWithoutSources.cs
View
5 DependencyGraph.cs
@@ -59,9 +59,10 @@ private void Generate(string targetFile, TargetGenerateSettings settings)
_buildHistory.AddRecord(record);
}
- public void RegisterTarget(string targetFile, TargetGenerateSettings settings)
+ public void RegisterTarget(TargetGenerateSettings settings)
{
- _graph.Add(targetFile,settings);
+ foreach(var targetFile in settings.OutputFiles)
+ _graph.Add(targetFile,settings);
}
}
}
View
9 TargetGenerateSettings.cs
@@ -7,11 +7,18 @@ public class TargetGenerateSettings
{
public ITargetGeneratingAction Action;
public HashSet<string> InputFiles { get; private set; }
+ public HashSet<string> OutputFiles { get; private set; }
private string _actionHash;
- public TargetGenerateSettings(ITargetGeneratingAction action, IEnumerable<string> inputFiles)
+ public TargetGenerateSettings(ITargetGeneratingAction action, IEnumerable<string> inputFiles, string outputFile)
+ : this(action,inputFiles, new[] {outputFile})
{
+ }
+
+ public TargetGenerateSettings(ITargetGeneratingAction action, IEnumerable<string> inputFiles, IEnumerable<string> outputFiles)
+ {
+ OutputFiles = new HashSet<string>(outputFiles);
Action = action;
_actionHash = action.GetActionHash();
InputFiles = new HashSet<string>(inputFiles);
View
6 Tests/DifferentInputFiles.cs
@@ -23,19 +23,19 @@ public void WhenInputFilesChangeTargetGetsRebuilt()
File.WriteAllText("file1", "one");
File.WriteAllText("file2", "two");
- _depGraph.RegisterTarget(defaulttargetFile, MakeInstructions(action, "file1" ));
+ _depGraph.RegisterTarget(MakeInstructions(action, "file1" ));
_depGraph.RequestTarget(defaulttargetFile);
Assert.AreEqual(1, invocationCount);
_depGraph = new DependencyGraph(_buildHistory);
- _depGraph.RegisterTarget(defaulttargetFile, MakeInstructions(action, "file1","file2"));
+ _depGraph.RegisterTarget(MakeInstructions(action, "file1","file2"));
_depGraph.RequestTarget(defaulttargetFile);
Assert.AreEqual(2, invocationCount);
}
private static TargetGenerateSettings MakeInstructions(ITargetGeneratingAction action, params string[] inputFiles)
{
- return new TargetGenerateSettings(action, inputFiles);
+ return new TargetGenerateSettings(action, inputFiles, new[]{defaulttargetFile});
}
}
}
View
4 Tests/SimpleCopyDepGraph.cs
@@ -15,7 +15,6 @@ public new void Setup()
SetupSimpleCopyDepGraph();
}
-
[Test]
public void ThrowsIfDependencyDoesNotExist()
{
@@ -64,8 +63,7 @@ public void WillNotRegeneratesWhenTargetGotManuallyUpdated()
private void SetupSimpleCopyDepGraph()
{
var action = new SimpleAction((target, settings) => File.Copy(settings.InputFiles.Single(), target, true), "hash");
- _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateSettings(action, new[] {defaultSourceFile}));
-
+ _depGraph.RegisterTarget(new TargetGenerateSettings(action, new[] {defaultSourceFile}, defaulttargetFile));
}
}
}
View
4 Tests/TargetWithoutSources.cs
@@ -46,7 +46,7 @@ public void RegenerateWhenActionHashChanges()
bool invoked = false;
var action = new SimpleAction((t, s) => { invoked=true; }, "hash2");
- _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateSettings(action, new string[0]));
+ _depGraph.RegisterTarget(new TargetGenerateSettings(action, new string[0], defaulttargetFile));
_depGraph.RequestTarget(defaulttargetFile);
Assert.IsTrue(invoked);
@@ -55,7 +55,7 @@ public void RegenerateWhenActionHashChanges()
private void SetupGraphWithOneTargetWithoutSources()
{
var simpleAction = new SimpleAction((t,s) => File.WriteAllText(t, "Hello"), "hash1");
- _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateSettings(simpleAction, new string[0]));
+ _depGraph.RegisterTarget(new TargetGenerateSettings(simpleAction, new string[0], defaulttargetFile));
}
}

0 comments on commit 8f0df8b

Please sign in to comment.
Something went wrong with that request. Please try again.