Skip to content

Instantly share code, notes, and snippets.

@staxmanade
Created November 13, 2012 04:37
Show Gist options
  • Save staxmanade/4063952 to your computer and use it in GitHub Desktop.
Save staxmanade/4063952 to your computer and use it in GitHub Desktop.
Hack p4merge into approval tests
[SetUpFixture]
public class HackToSetupApprovalTestsToFindP4Merge
{
[SetUp]
public void SetUpFixture()
{
var field = typeof(FirstWorkingReporter).GetField("reporters", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
var currentItems = (IEnumerable<IEnvironmentAwareReporter>)field.GetValue(DiffReporter.INSTANCE);
var newitems = new[] { P4MergeDiffReporter.INSTANCE }.Concat(currentItems).ToArray();
field.SetValue(DiffReporter.INSTANCE, newitems);
}
}
public class P4MergeDiffReporter : GenericDiffReporter
{
private static readonly string PATH = DotNet4Utilities.GetPathInProgramFilesX86("Perforce\\p4merge.exe");
public static readonly P4MergeDiffReporter INSTANCE = new P4MergeDiffReporter();
public P4MergeDiffReporter()
: base(PATH, "Could not find P4Merge at {0}, please install it".FormatWith(new object[] { PATH }))
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment