Skip to content
Browse files

store the hash of each action so we know that if the way something is…

… buitl changes, that requires a regeneration too
  • Loading branch information...
1 parent 8dc7dd9 commit a0175d9d28aaae9ca566bb22bc433655f97d3271 Lucas Meijer committed Apr 14, 2012
Showing with 36 additions and 10 deletions.
  1. +1 −1 BuildHistory.cs
  2. +20 −5 TargetGenerateSettings.cs
  3. +1 −2 Tests/DifferentInputFiles.cs
  4. +1 −1 Tests/SimpleCopyDepGraph.cs
  5. +13 −1 Tests/TargetWithoutSources.cs
View
2 BuildHistory.cs
@@ -14,7 +14,7 @@ public void AddRecord(GenerationRecord record)
public GenerationRecord FindRecordFor(string targetFile)
{
- GenerationRecord result = null;
+ GenerationRecord result;
_records.TryGetValue(targetFile,out result);
return result;
}
View
25 TargetGenerateSettings.cs
@@ -1,18 +1,33 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
namespace bs
{
public class TargetGenerateSettings
{
- public HashSet<string> InputFiles;
+ public HashSet<string> InputFiles { get; private set; }
+ public string ActionHash { get; private set; }
+
+ public TargetGenerateSettings(HashSet<string> inputFiles, string actionHash)
+ {
+ InputFiles = inputFiles;
+ ActionHash = actionHash;
+ }
//todo: figure out how to write a sane Equals
public override bool Equals(object obj)
{
- if (obj == null) return false;
+ if (obj == null)
+ return false;
+
var other = obj as TargetGenerateSettings;
- if (other == null) return false;
- return other.InputFiles.Equals(InputFiles);
+ if (other == null)
+ return false;
+
+ if (ActionHash != other.ActionHash)
+ return false;
+
+ return other.InputFiles.SetEquals(InputFiles);
}
public override int GetHashCode()
View
3 Tests/DifferentInputFiles.cs
@@ -38,8 +38,7 @@ private static TargetGenerateInstructions MakeInstructions(ITargetGeneratingActi
var targetBuildInstructions = new TargetGenerateInstructions();
targetBuildInstructions.Action = action;
- targetBuildInstructions.Settings = new TargetGenerateSettings();
- targetBuildInstructions.Settings.InputFiles = new HashSet<string>(inputFiles);
+ targetBuildInstructions.Settings = new TargetGenerateSettings(new HashSet<string>(inputFiles), action.GetActionHash());
return targetBuildInstructions;
}
}
View
2 Tests/SimpleCopyDepGraph.cs
@@ -67,7 +67,7 @@ private void SetupSimpleCopyDepGraph()
_depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateInstructions()
{
Action = action,
- Settings = new TargetGenerateSettings() { InputFiles = new HashSet<string>(new[]{defaultSourceFile})}
+ Settings = new TargetGenerateSettings(new HashSet<string>(new[]{defaultSourceFile}), action.GetActionHash())
});
}
}
View
14 Tests/TargetWithoutSources.cs
@@ -5,6 +5,7 @@
namespace bs.Tests
{
+ [TestFixture]
class TargetWithoutSources : DependencyGraphTests
{
[SetUp]
@@ -40,7 +41,18 @@ public void WillGenerateTargetIfItWasNeverBuiltBefore()
[Test]
public void RegenerateWhenActionHashChanges()
{
+ _depGraph.RequestTarget(defaulttargetFile);
+ _depGraph = new DependencyGraph(_buildHistory);
+ bool invoked = false;
+ var action = new SimpleAction((t, s) => { invoked=true; }, "hash2");
+ _depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateInstructions()
+ {
+ Action = action,
+ Settings = new TargetGenerateSettings(new HashSet<string>(), action.GetActionHash())
+ });
+ _depGraph.RequestTarget(defaulttargetFile);
+ Assert.IsTrue(invoked);
}
@@ -53,7 +65,7 @@ private void SetupGraphWithOneTargetWithoutSources()
_depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateInstructions()
{
Action = simpleAction,
- Settings = new TargetGenerateSettings() { InputFiles = new HashSet<string>()}
+ Settings = new TargetGenerateSettings(new HashSet<string>(),simpleAction.GetActionHash())
});
}

0 comments on commit a0175d9

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