Exemplo n.º 1
0
        static void Launch(ResolvedDiffTool tool, string path1, string path2)
        {
            Guard.AgainstNull(tool, nameof(tool));
            var command           = tool.BuildCommand(path1, path2);
            var isDiffToolRunning = ProcessCleanup.IsRunning(command);

            if (isDiffToolRunning)
            {
                if (tool.SupportsAutoRefresh)
                {
                    return;
                }

                if (!tool.IsMdi)
                {
                    ProcessCleanup.Kill(command);
                }
            }

            var arguments = tool.BuildArguments(path1, path2);

            try
            {
                Process.Start(tool.ExePath, arguments);
            }
            catch (Exception exception)
            {
                var message = $@"Failed to launch diff tool.
{tool.ExePath} {arguments}";
                throw new Exception(message, exception);
            }
        }
Exemplo n.º 2
0
    public static void Launch(ResolvedDiffTool diffTool, string receivedPath, string verifiedPath)
    {
        var arguments = $"{diffTool.ArgumentPrefix} \"{receivedPath}\" \"{verifiedPath}\"";

        using var process = new Process
              {
                  StartInfo = new ProcessStartInfo
                  {
                      FileName        = diffTool.ExePath,
                      Arguments       = arguments,
                      UseShellExecute = false,
                      CreateNoWindow  = false,
                  }
              };
        process.StartWithCatch();
    }
Exemplo n.º 3
0
    static Tests()
    {
        BuildServerDetector.Detected = false;
        var diffToolPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "../../../../FakeDiffTool/bin/FakeDiffTool.exe"));

        tool = new ResolvedDiffTool(
            name: DiffTool.VisualStudio,
            exePath: diffToolPath,
            buildArguments: (path1, path2) => $"\"{path1}\" \"{path2}\"",
            isMdi: false,
            supportsAutoRefresh: true,
            binaryExtensions: new string[] {});

        DiffTools.ResolvedDiffTools = new List <ResolvedDiffTool>
        {
            tool
        };

        DiffTools.ExtensionLookup = new Dictionary <string, ResolvedDiffTool>
        {
            { "txt", tool },
            { "knownBin", tool },
        };
        var binPath = AllFiles.Files["jpg"];

        AllFiles.Files = new Dictionary <string, EmptyFile>
        {
            { "knownBin", binPath },
        };

        SharedVerifySettings.RegisterFileConverter <TypeToSplit>(
            "txt",
            (split, settings) => new ConversionResult(
                split.Info,
                new List <Stream>
        {
            new MemoryStream(Encoding.UTF8.GetBytes(split.Property1)),
            new MemoryStream(Encoding.UTF8.GetBytes(split.Property2))
        }));
        DiffRunner.MaxInstancesToLaunch(uint.MaxValue);
    }
Exemplo n.º 4
0
 // ReSharper disable once UnusedParameter.Global
 public static bool TryGetTextDiff(string extension, out ResolvedDiffTool diffTool)
 {
     diffTool = ResolvedDiffTools.LastOrDefault();
     return(diffTool != null);
 }