Beispiel #1
0
        public BuildRunResults RunBuild(string projectName, string buildExecutable)
        {
            var timer = Stopwatch.StartNew();
            _buildExecutable = buildExecutable;
			var outputDir = getOutputDir();
            Process process = new Process();
            process.StartInfo = new ProcessStartInfo(_buildExecutable, string.Format("\"{0}\"", projectName) + " /property:OutDir=" + outputDir);
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;

            process.Start();
            string line;
            var buildResults = new BuildRunResults(projectName);
			var lines = new List<string>();
            while ((line = process.StandardOutput.ReadLine()) != null)
				lines.Add(line);
            process.WaitForExit();
            timer.Stop();
			var parser = new MSBuildOutputParser(buildResults, lines.ToArray());
            parser.Parse();
            buildResults.SetTimeSpent(timer.Elapsed);
            return buildResults;
        }
Beispiel #2
0
        private BuildRunResults runBuild(string buildExecutable, string arguments, string target, Func<bool> abortIfTrue)
        {
            if (_configuration.MSBuildAdditionalParameters.Length > 0)
                arguments += " " + _configuration.MSBuildAdditionalParameters;
            var timer = Stopwatch.StartNew();
            DebugLog.Debug.WriteInfo("Running build: {0} {1}", buildExecutable, arguments);
            Process process = new Process();
            process.StartInfo = new ProcessStartInfo(buildExecutable, arguments);
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;

            process.Start();
            string line;
            var buildResults = new BuildRunResults(target);
            var lines = new List<string>();
            while ((line = process.StandardOutput.ReadLine()) != null)
            {
                if (abortIfTrue.Invoke())
                {
                    process.Kill();
                    process.WaitForExit();
                    AutoTest.Core.DebugLog.Debug.WriteDebug("Aborting build run");
                    return new BuildRunResults(target);
                }
                lines.Add(line);
            }
            process.WaitForExit();
            timer.Stop();
            var parser = new MSBuildOutputParser(buildResults, lines.ToArray());
            parser.Parse();
            buildResults.SetTimeSpent(timer.Elapsed);
            return buildResults;
        }
        public BuildRunResults RunBuild(Project project, string buildExecutable)
        {
            var timer = Stopwatch.StartNew();
            _buildExecutable = buildExecutable;
			var properties = buildProperties(project);
            var arguments = string.Format("\"{0}\"", project.Key) + properties;
            DebugLog.Debug.WriteMessage(string.Format("Running build: {0} {1}", _buildExecutable, arguments));
            Process process = new Process();
            process.StartInfo = new ProcessStartInfo(_buildExecutable, arguments);
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;

            process.Start();
            string line;
            var buildResults = new BuildRunResults(project.Key);
			var lines = new List<string>();
            while ((line = process.StandardOutput.ReadLine()) != null)
				lines.Add(line);
            process.WaitForExit();
            timer.Stop();
			var parser = new MSBuildOutputParser(buildResults, lines.ToArray());
            parser.Parse();
            buildResults.SetTimeSpent(timer.Elapsed);
            return buildResults;
        }
 public BuildRunResults PostProcessBuildResults(BuildRunResults runResults)
 {
     var buildProject = runResults.Project;
     if (_tmpProjects.Contains(buildProject))
         runResults.UpdateProject(getOriginalProject(buildProject));
     return runResults;
 }
 public void Should_add_build_errors()
 {
     var results = new BuildRunResults("project");
     results.AddError(new BuildMessage());
     _runResultCache.Merge(results);
     _runResultCache.Errors.Length.ShouldEqual(1);
     _runResultCache.Errors[0].Key.ShouldEqual("project");
 }
Beispiel #6
0
 public void Merge(BuildRunResults results)
 {
     lock (_padLock)
     {
         mergeBuildList(_errors, results.Project, results.Errors);
         mergeBuildList(_warnings, results.Project, results.Warnings);
     }
 }
 public void Should_add_build_warnings()
 {
     var results = new BuildRunResults("project");
     results.AddWarning(new BuildMessage());
     _runResultCache.Merge(results);
     _runResultCache.Warnings.Length.ShouldEqual(1);
     _runResultCache.Warnings[0].Key.ShouldEqual("project");
 }
 public void Merge(BuildRunResults results)
 {
     lock (_padLock)
     {
         Debug.WriteDebug("Merging build run results");
         mergeBuildList(_errors, results.Project, results.Errors);
         mergeBuildList(_warnings, results.Project, results.Warnings);
     }
 }
        public void Should_not_merge_same_build_errors_from_different_project()
        {
            var results = new BuildRunResults("project");
            results.AddError(new BuildMessage() { File = "some file", ErrorMessage = "some error message" });
            _runResultCache.Merge(results);

            results = new BuildRunResults("another project");
            results.AddError(new BuildMessage() { File = "some file", ErrorMessage = "some error message" });
            _runResultCache.Merge(results);
            _runResultCache.Errors.Length.ShouldEqual(2);
        }
 public void Should_merge_build_errors()
 {
     var results = new BuildRunResults("project");
     results.AddError(new BuildMessage() {File = "some file", ErrorMessage = "some error message"});
     _runResultCache.Merge(results);
     
     results = new BuildRunResults("project");
     results.AddError(new BuildMessage() { File = "some file", ErrorMessage = "some error message" });
     results.AddError(new BuildMessage() { File = "some other file", ErrorMessage = "some other error message" });
     _runResultCache.Merge(results);
     _runResultCache.Errors.Length.ShouldEqual(2);
 }
        public void Should_parse_errors()
        {
			var resultfile = string.Format("TestResources{0}MSBuild{0}msbuild_errors.txt", Path.DirectorySeparatorChar);
            var result = new BuildRunResults("");
            var parser = new MSBuildOutputParser(result, File.ReadAllLines(resultfile));
            parser.Parse();
            result.ErrorCount.ShouldEqual(1);
            result.Errors[0].File
                .Replace('/', Path.DirectorySeparatorChar)
                .ShouldEqual("/home/ack/src/AutoTest.Net/src/AutoTest.Core/Messaging/MessageConsumers/ProjectChangeConsumer.cs".Replace('/', Path.DirectorySeparatorChar));
            result.Errors[0].LineNumber.ShouldEqual(62);
            result.Errors[0].LinePosition.ShouldEqual(50);
            result.Errors[0].ErrorMessage.ShouldEqual("CS1003: ; expected");
        }
        public void Should_remove_cached_build_errors_that_now_works()
        {
            var results = new BuildRunResults("project");
            results.AddError(new BuildMessage() { File = "some file", ErrorMessage = "some error message" });
            _runResultCache.Merge(results);

            results = new BuildRunResults("another project");
            results.AddError(new BuildMessage() { File = "some file", ErrorMessage = "some error message" });
            _runResultCache.Merge(results);

            results = new BuildRunResults("project");
            _runResultCache.Merge(results);
            _runResultCache.Errors.Length.ShouldEqual(1);
        }
        public void Should_find_build_warning_delta()
        {
            _runResultCache.EnabledDeltas();
            var results = new BuildRunResults("project");
            results.AddWarning(new BuildMessage() { File = "some file", ErrorMessage = "some warning message" });
            _runResultCache.Merge(results);
            _runResultCache.PopDeltas();

            results = new BuildRunResults("project");
            results.AddWarning(new BuildMessage() { File = "some other file", ErrorMessage = "some other warning message" });
            _runResultCache.Merge(results);
            var deltas = _runResultCache.PopDeltas();

            deltas.AddedWarnings.Length.ShouldEqual(1);
            deltas.RemovedWarnings.Length.ShouldEqual(1);
        }
        public void Should_parse_so_called_compatible_msbuild_output()
        {
			// Test will fail on other platforms than windows because of Path.GetDirectoryName
			if (!isWindows())
				return;
            var resultfile = string.Format("TestResources{0}MSBuild{0}msbuild_windows.txt", Path.DirectorySeparatorChar);
            var result = new BuildRunResults("");
            var parser = new MSBuildOutputParser(result, File.ReadAllLines(resultfile));
            parser.Parse();
            result.ErrorCount.ShouldEqual(3);
            result.Errors[0].File
                .Replace('/', Path.DirectorySeparatorChar)
                .ShouldEqual(@"C:\Users\ack\src\EventStore\EventStore\Program.cs");
            result.Errors[0].LineNumber.ShouldEqual(20);
            result.Errors[0].LinePosition.ShouldEqual(20);
            result.Errors[0].ErrorMessage.ShouldEqual("CS1002: ; expected");
        }
        public void Should_parse_so_called_compatible_msbuild_output_with_warnings()
        {
			// Test will fail on other platforms than windows because of Path.GetDirectoryName
			if (!isWindows())
				return;
            var resultfile = string.Format("TestResources{0}MSBuild{0}msbuild_windows_warnings.txt", Path.DirectorySeparatorChar);
            var result = new BuildRunResults("");
            var parser = new MSBuildOutputParser(result, File.ReadAllLines(resultfile));
            parser.Parse();
            result.Warnings.Length.ShouldEqual(1);
            result.Warnings[0].File
                .Replace('/', Path.DirectorySeparatorChar)
                .ShouldEqual(@"C:\Users\ack\src\EventStore\EventStore\Program.cs");
            result.Warnings[0].LineNumber.ShouldEqual(21);
            result.Warnings[0].LinePosition.ShouldEqual(8);
            result.Warnings[0].ErrorMessage.ShouldEqual("CS0219: The variable 'a' is assigned but its value is never used");
        }
        public BuildRunResults PostProcessBuildResults(BuildRunResults buildResults)
        {
            if (!_isActive)
                return buildResults;
            if (buildResults == null)
                return null;

            //rewritePdbs(buildResults);

            updateBuildProject(ref buildResults);

            foreach (var x in buildResults.Errors)
            {
                updateMessage(x);
            }
            foreach (var x in buildResults.Warnings)
            {
                updateMessage(x);
            }
            return buildResults;
        }
        public void Should_parse_warning()
        {
			var resultfile = string.Format("TestResources{0}MSBuild{0}msbuild_warnings.txt", Path.DirectorySeparatorChar);
            var result = new BuildRunResults("");
            var parser = new MSBuildOutputParser(result, File.ReadAllLines(resultfile));
            parser.Parse();
            result.WarningCount.ShouldEqual(2);
			
            result.Warnings[0].File
                .Replace('/', Path.DirectorySeparatorChar)
                .ShouldEqual("/home/ack/src/AutoTest.Net/src/AutoTest.Core/BuildRunners/MSBuildOutputParser.cs".Replace('/', Path.DirectorySeparatorChar));
            result.Warnings[0].LineNumber.ShouldEqual(21);
            result.Warnings[0].LinePosition.ShouldEqual(29);
            result.Warnings[0].ErrorMessage.ShouldEqual("CS1717: Assignment made to same variable; did you mean to assign something else?");
			
			result.Warnings[1].File
                .Replace('/', Path.DirectorySeparatorChar)
                .ShouldEqual("/home/ack/src/AutoTest.Net/src/AutoTest.Test/Core/BuildRunners/MSBuildOutputParserTest.cs".Replace('/', Path.DirectorySeparatorChar));
            result.Warnings[1].LineNumber.ShouldEqual(27);
            result.Warnings[1].LinePosition.ShouldEqual(29);
            result.Warnings[1].ErrorMessage.ShouldEqual("CS1717: Assignment made to same variable; did you mean to assign something else?");
        }
Beispiel #18
0
        private static BuildRunResults runBuild(string buildExecutable, string arguments, string target)
        {
            var timer = Stopwatch.StartNew();
            DebugLog.Debug.WriteInfo("Running build: {0} {1}", buildExecutable, arguments);
            Process process = new Process();
            process.StartInfo = new ProcessStartInfo(buildExecutable, arguments);
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;

            process.Start();
            string line;
            var buildResults = new BuildRunResults(target);
            var lines = new List<string>();
            while ((line = process.StandardOutput.ReadLine()) != null)
                lines.Add(line);
            process.WaitForExit();
            timer.Stop();
            var parser = new MSBuildOutputParser(buildResults, lines.ToArray());
            parser.Parse();
            buildResults.SetTimeSpent(timer.Elapsed);
            return buildResults;
        }
 public BuildRunResults PostProcessBuildResults(BuildRunResults runResults)
 {
     return runResults;
 }
Beispiel #20
0
		public void SetDataFrom(BinaryReader reader)
		{
			_results = new BuildRunResults("");
			_results.SetDataFrom(reader);
		}
Beispiel #21
0
 public BuildRunMessage(BuildRunResults results)
 {
     _results = results;
 }
 public BuildRunMessage(BuildRunResults results)
 {
     _results = results;
 }
 public MSBuildOutputParser(BuildRunResults results, string[] lines)
 {
     _results = results;
     _lines = lines;
 }
 private BuildRunResults postProcessBuildReports(BuildRunResults report)
 {
     foreach (var preProcessor in _preBuildProcessors)
         report = preProcessor.PostProcessBuildResults(report);
     return report;
 }
 public void SetDataFrom(BinaryReader reader)
 {
     _results = new BuildRunResults("");
     _results.SetDataFrom(reader);
 }
 public void SetUp()
 {
     _results = new BuildRunResults("");
 }
        public void Should_parse_msbuild_solution_errors()
        {
			// Test will fail on other platforms than windows because of Path.GetDirectoryName
			if (!isWindows())
				return;
            var resultfile = getPath(string.Format("TestResources{0}MSBuild{0}msbuild_solution_error.txt", Path.DirectorySeparatorChar));
            var result = new BuildRunResults("");
            var parser = new MSBuildOutputParser(result, File.ReadAllLines(resultfile));
            parser.Parse();
            result.Errors.Length.ShouldEqual(1);
            result.Errors[0].File
                .Replace('/', Path.DirectorySeparatorChar)
                .ShouldEqual(@"C:\Some\Solution\File.sln");
            result.Errors[0].LineNumber.ShouldEqual(200);
            result.Errors[0].LinePosition.ShouldEqual(0);
            result.Errors[0].ErrorMessage.ShouldEqual("MSB 5023: Error parsing solution file.");
        }
        public void Should_parse_succeeded()
        {
			var resultfile = string.Format("TestResources{0}MSBuild{0}msbuild_succeeded.txt", Path.DirectorySeparatorChar);
            var result = new BuildRunResults("");
            var parser = new MSBuildOutputParser(result, File.ReadAllLines(resultfile));
            parser.Parse();
            result.WarningCount.ShouldEqual(0);
            result.ErrorCount.ShouldEqual(0);
        }
 public void Merge(BuildRunResults results)
 {
     HasMergedBuildResults = true;
 }
 BuildRunResults IPreProcessBuildruns.PostProcessBuildResults(BuildRunResults buildResults)
 {
     return buildResults;
 }
        public void Should_clear_cache_when_issuing_clear_with_deltas()
        {
            var results = new BuildRunResults("another project");
            results.AddError(new BuildMessage() { File = "some files", ErrorMessage = "some error messages" });
            results.AddWarning(new BuildMessage() { File = "some file", ErrorMessage = "some error message" });
            _runResultCache.Merge(results);
            _runResultCache.Merge(new TestRunResults("project", "assembly", false, TestRunner.NUnit, new TestResult[] { new TestResult(TestRunner.NUnit, TestRunStatus.Ignored, "Test name", "Message", new IStackLine[] { }) }));
            _runResultCache.Merge(new TestRunResults("project", "assembly", true, TestRunner.NUnit, new TestResult[] { new TestResult(TestRunner.NUnit, TestRunStatus.Failed, "Test name", "Message", new IStackLine[] { new StackLineMessage("method", "file", 10) }) }));

            _runResultCache.EnabledDeltas();
            _runResultCache.Clear();
            _runResultCache.Errors.Length.ShouldEqual(0);
            _runResultCache.Warnings.Length.ShouldEqual(0);
            _runResultCache.Failed.Length.ShouldEqual(0);
            _runResultCache.Ignored.Length.ShouldEqual(0);
        }
 private void updateBuildProject(ref BuildRunResults buildResults)
 {
     if (compare(buildResults.Project, _files.Solution.Tempfile))
         buildResults.UpdateProject(_files.Solution.Original);
     else
     {
         var buildProject = buildResults.Project;
         var project = _files.Files.FirstOrDefault(f => compare(f.Tempfile, buildProject));
         if (project != null)
             buildResults.UpdateProject(project.Original);
     }
 }