public static void RevertToOriginal(string gitroot, string GitBaseBranch, string gitExePath) { Contract.Requires(!string.IsNullOrEmpty(gitroot)); Contract.Requires(gitExePath != null); Contract.Requires(gitroot.Length < 260); Output.WritePhase("Reverting to the original git branch {0}", GitBaseBranch); RunGit(gitroot, String.Format("checkout {0}", GitBaseBranch), gitExePath); RunGit(gitroot, String.Format("reset --hard {0}", GitBaseBranch), gitExePath); }
public void PrintStatistics() { Output.WritePhase("Printing statistics"); Output.WriteLine("Number of suggestions: "); PrintList(NumberOfSuggestions); Output.WriteLine("Number of warnings: "); PrintList(NumberOfWarnings); Output.WriteLine("Execution Times: "); PrintList(RunTimes); }
public static bool TryRunClousot(string outputFile, string ClousotPath, string ClousotOptions, string rspPath) { Contract.Requires(ClousotPath != null); Output.WritePhase("Running the CC static checker -- It may take a while, please be patient"); if (!File.Exists(rspPath)) { Output.WriteError("The rsp file does not exists"); return(false); } string text = null; Process p = null; var rspFile = "@" + rspPath; try { // Run Clousot p = new Process(); p.StartInfo.FileName = ClousotPath; p.StartInfo.Arguments = rspFile + " " + ClousotOptions; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.Start(); var output = p.StandardOutput; var reader = output.ReadToEndAsync(); Contract.Assume(reader != null, "Missing contract"); p.WaitForExit(); text = reader.Result; } catch (Exception e) { Output.WriteError("Some exception happen while running Clousot. Details {0}", e.Message); return(false); } Contract.Assume(text != null); try { Helpers.IO.CreateDirAndWriteAllText(outputFile, text); } catch (Exception e) { Output.WriteError("Can't write the xml file with Clousot output. {0}File Path: {1}{0}Exception{2}", Environment.NewLine, outputFile, e.Message); return(false); } if (p.ExitCode != 0) { // The most common error is that Clousot cannot load the dll if (text.Contains(Constants.String.CannotLoadAssembly)) { Output.WriteError("Clousot can't load the assembly, did you forgot to stage the enable static checking?"); } else { Output.WriteError("Something failed in running Clousot"); } return(false); } return(true); }