Ejemplo n.º 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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        private static BuildRunResults runBuild(string buildExecutable, string arguments, string target, Func <bool> abortIfTrue)
        {
            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())
                {
                    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 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);
        }
Ejemplo n.º 6
0
 public void Should_not_add_duplicate_warnings()
 {
     var result = new BuildRunResults("");
     var line =
         "Session.cs(32,46): warning CS0109: The member `Desktopcouch.Session.GType' does not hide an inherited member. The new keyword is not required";
     var parser = new MSBuildOutputParser(result, line);
     parser.Parse();
     parser.Parse();
     result.WarningCount.ShouldEqual(1);
 }
Ejemplo n.º 7
0
 public void Should_not_add_duplicate_errors()
 {
     var result = new BuildRunResults("");
     var line =
         "Class1.cs(5,7): error CS0246: The type or namespace name 'Nunit' could not be found (are you missing a using directive or an assembly reference?)";
     var parser = new MSBuildOutputParser(result, line);
     parser.Parse();
     parser.Parse();
     result.ErrorCount.ShouldEqual(1);
 }
Ejemplo n.º 8
0
 public void Should_parse_warning()
 {
     var result = new BuildRunResults("");
     var line =
         "Session.cs(32,46): warning CS0109: The member `Desktopcouch.Session.GType' does not hide an inherited member. The new keyword is not required";
     var parser = new MSBuildOutputParser(result, line);
     parser.Parse();
     result.WarningCount.ShouldEqual(1);
     result.Warnings[0].File.ShouldEqual("Session.cs");
     result.Warnings[0].LineNumber.ShouldEqual(32);
     result.Warnings[0].LinePosition.ShouldEqual(46);
     result.Warnings[0].ErrorMessage.ShouldEqual("CS0109: The member `Desktopcouch.Session.GType' does not hide an inherited member. The new keyword is not required");
 }
Ejemplo n.º 9
0
 public void Should_parse_error()
 {
     var result = new BuildRunResults("");
     var line =
         "Class1.cs(5,7): error CS0246: The type or namespace name 'Nunit' could not be found (are you missing a using directive or an assembly reference?)";
     var parser = new MSBuildOutputParser(result, line);
     parser.Parse();
     result.ErrorCount.ShouldEqual(1);
     result.Errors[0].File.ShouldEqual("Class1.cs");
     result.Errors[0].LineNumber.ShouldEqual(5);
     result.Errors[0].LinePosition.ShouldEqual(7);
     result.Errors[0].ErrorMessage.ShouldEqual("CS0246: The type or namespace name 'Nunit' could not be found (are you missing a using directive or an assembly reference?)");
 }
Ejemplo n.º 10
0
        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");
        }
Ejemplo n.º 11
0
        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");
        }
Ejemplo n.º 12
0
        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");
        }
Ejemplo n.º 13
0
        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?");
        }
Ejemplo n.º 14
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 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.");
        }