예제 #1
0
        public void Should_serialize_run_finished_message()
        {
            var runreport = new RunReport();

            runreport.AddBuild("project 1", new TimeSpan(23), true);
            runreport.AddBuild("project 2", new TimeSpan(12), false);
            runreport.AddTestRun("project 2", "assembly", new TimeSpan(52), 12, 1, 2);
            runreport.WasAborted();
            var message = new RunFinishedMessage(runreport);
            var output  = serializeDeserialize <RunFinishedMessage>(message);

            output.Report.NumberOfBuildsSucceeded.ShouldEqual(1);
            output.Report.NumberOfBuildsFailed.ShouldEqual(1);
            output.Report.RunActions[0].Project.ShouldEqual("project 1");
            output.Report.RunActions[0].Type.ShouldEqual(InformationType.Build);
            output.Report.RunActions[0].Succeeded.ShouldEqual(true);
            output.Report.RunActions[0].TimeSpent.ShouldEqual(new TimeSpan(23));
            output.Report.RunActions[1].Project.ShouldEqual("project 2");
            output.Report.RunActions[1].Type.ShouldEqual(InformationType.Build);
            output.Report.RunActions[1].Succeeded.ShouldEqual(false);
            output.Report.RunActions[1].TimeSpent.ShouldEqual(new TimeSpan(12));
            output.Report.Aborted.ShouldBeTrue();

            output.Report.NumberOfTestsPassed.ShouldEqual(12);
            output.Report.NumberOfTestsFailed.ShouldEqual(2);
            output.Report.NumberOfTestsIgnored.ShouldEqual(1);
            output.Report.RunActions[2].Project.ShouldEqual("project 2");
            output.Report.RunActions[2].Assembly.ShouldEqual("assembly");
            output.Report.RunActions[2].Type.ShouldEqual(InformationType.TestRun);
            output.Report.RunActions[2].Succeeded.ShouldEqual(false);
            output.Report.RunActions[2].TimeSpent.ShouldEqual(new TimeSpan(52));
        }
예제 #2
0
 public void Should_add_succeeded_build_action()
 {
     _report.AddBuild("Project", new TimeSpan(0, 0, 25), true);
     _report.RunActions[0].Type.ShouldEqual(InformationType.Build);
     _report.RunActions[0].Project.ShouldEqual("Project");
     _report.RunActions[0].TimeSpent.ShouldEqual(new TimeSpan(0, 0, 25));
     _report.RunActions[0].Succeeded.ShouldBeTrue();
     _report.NumberOfBuildsSucceeded.ShouldEqual(1);
 }
        public void Should_build_tooltip_string()
        {
            var report = new RunReport();
            report.AddBuild(Path.GetFullPath("Project1.csproj"), new TimeSpan(0, 0, 0, 2, 234), true);
            report.AddBuild(Path.GetFullPath("Project2.csproj"), new TimeSpan(0, 0, 0, 3, 154), false);
            report.AddTestRun(Path.GetFullPath("Project3.csproj"), Path.GetFullPath("Assembly.dll"), new TimeSpan(0, 0, 0, 6, 211), 0, 0, 0);

            var builder = new SummaryBuilder(report);
            var output = builder.Build();

            output.ToString().ShouldEqual(getResult());
        }
예제 #4
0
        public void Should_build_tooltip_string()
        {
            var report = new RunReport();

            report.AddBuild(Path.GetFullPath("Project1.csproj"), new TimeSpan(0, 0, 0, 2, 234), true);
            report.AddBuild(Path.GetFullPath("Project2.csproj"), new TimeSpan(0, 0, 0, 3, 154), false);
            report.AddTestRun(Path.GetFullPath("Project3.csproj"), Path.GetFullPath("Assembly.dll"), new TimeSpan(0, 0, 0, 6, 211), 0, 0, 0);

            var builder = new SummaryBuilder(report);
            var output  = builder.Build();

            output.ToString().ShouldEqual(getResult());
        }
        private BuildRunResults buildProjects(RunInfo[] projectList, RunReport runReport)
        {
            var indirectlyBuilt = new List <string>();

            foreach (var file in projectList)
            {
                if (file.ShouldBeBuilt)
                {
                    Debug.WriteDebug("Set to build project {0}", file.Project.Key);
                    var report = build(file, runReport);
                    if (report != null)
                    {
                        return(report);
                    }
                }
                else
                {
                    Debug.WriteDebug("Not set to build project {0}", file.Project.Key);
                    indirectlyBuilt.Add(file.Project.Key);
                }
            }
            foreach (var project in indirectlyBuilt)
            {
                runReport.AddBuild(project, new TimeSpan(0), true);
            }
            return(null);
        }
        private bool buildProject(Project project, RunReport report)
        {
            var buildReport = _buildRunner.RunBuild(project, _configuration.BuildExecutable(project.Value), () => { return(_exit); });
            var succeeded   = buildReport.ErrorCount == 0;

            report.AddBuild(buildReport.Project, buildReport.TimeSpent, succeeded);
            _bus.Publish(new BuildRunMessage(buildReport));
            return(succeeded);
        }
        private bool buildSolution(RunInfo[] projectList, RunReport runReport)
        {
            var buildExecutable = _configuration.BuildExecutable(new ProjectDocument(ProjectType.None));

            if (File.Exists(buildExecutable))
            {
                _bus.Publish(new RunInformationMessage(InformationType.Build, _configuration.WatchToken, "", typeof(MSBuildRunner)));

                var buildReport = _buildRunner.RunBuild(_configuration.WatchToken, projectList.Where(p => p.Project.Value.RequiresRebuild).Count() > 0, buildExecutable, () => { return(_exit); });
                var succeeded   = buildReport.ErrorCount == 0;
                runReport.AddBuild(_configuration.WatchToken, buildReport.TimeSpent, succeeded);
                _bus.Publish(new BuildRunMessage(buildReport));
                return(succeeded);
            }
            return(false);
        }
        private BuildRunResults optimisticBuild(string[] changedProjects, RunInfo[] projectList, RunReport runReport)
        {
            var projectWithIssues = new List <string>();

            projectWithIssues.AddRange(_runCache
                                       .Errors
                                       .GroupBy(x => x.Key)
                                       .Select(x => x.Key));
            var builtProjects   = new List <RunInfo>();
            var indirectlyBuilt = new List <string>();

            foreach (var file in projectList)
            {
                if (changedProjects.Contains(file.Project.Key) || projectWithIssues.Contains(file.Project.Key))
                {
                    Debug.WriteDebug("Optimistic build for project {0}", file.Project.Key);
                    var original = file.Assembly + ".original" + Path.GetExtension(file.Assembly);
                    _fs.CopyFile(file.Assembly, original);
                    var report            = build(file, runReport);
                    var optimisticAdviced = _buildConfig.OptimisticBuildStrategy(file.Assembly, original);
                    _fs.DeleteFile(original);
                    if (!optimisticAdviced)
                    {
                        throw new Exception("Optimistic build is not adviced for this scenario");
                    }
                    if (report != null)
                    {
                        return(report);
                    }
                    builtProjects.Add(file);
                }
                else
                {
                    Debug.WriteDebug("Not set to optimisticly build project {0}", file.Project.Key);
                    indirectlyBuilt.Add(file.Project.Key);
                }
            }
            builtProjects.ForEach(x => copyAssembly(x.Project.Key, x.Assembly));
            foreach (var project in indirectlyBuilt)
            {
                runReport.AddBuild(project, new TimeSpan(0), true);
            }
            return(null);
        }
        private BuildRunResults buildProject(RunInfo info, RunReport report)
        {
            var project     = info.Project;
            var buildReport = _buildRunner.RunBuild(info, _configuration.BuildExecutable(project.Value), () => { return(_exit()); });

            buildReport = postProcessBuildReports(buildReport);
            var succeeded = buildReport.ErrorCount == 0;

            report.AddBuild(buildReport.Project, buildReport.TimeSpent, succeeded);
            _bus.Publish(new BuildRunMessage(buildReport));
            if (succeeded)
            {
                return(null);
            }
            else
            {
                return(buildReport);
            }
        }
 private BuildRunResults optimisticBuild(string[] changedProjects, RunInfo[] projectList, RunReport runReport)
 {
     var projectWithIssues = new List<string>();
     projectWithIssues.AddRange(_runCache
         .Errors
         .GroupBy(x => x.Key)
         .Select(x => x.Key));
     var builtProjects = new List<RunInfo>();
     var indirectlyBuilt = new List<string>();
     foreach (var file in projectList)
     {
         if (changedProjects.Contains(file.Project.Key) || projectWithIssues.Contains(file.Project.Key))
         {
             Debug.WriteDebug("Optimistic build for project {0}", file.Project.Key);
             var original = file.Assembly + ".original" + Path.GetExtension(file.Assembly);
             _fs.CopyFile(file.Assembly, original);
             var report = build(file, runReport);
             var optimisticAdviced = _buildConfig.OptimisticBuildStrategy(file.Assembly, original);
             _fs.DeleteFile(original);
             if (!optimisticAdviced)
                 throw new Exception("Optimistic build is not adviced for this scenario");
             if (report != null)
                 return report;
             builtProjects.Add(file);
         }
         else
         {
             Debug.WriteDebug("Not set to optimisticly build project {0}", file.Project.Key);
             indirectlyBuilt.Add(file.Project.Key);
         }
     }
     builtProjects.ForEach(x => copyAssembly(x.Project.Key, x.Assembly));
     foreach (var project in indirectlyBuilt)
         runReport.AddBuild(project, new TimeSpan(0), true);
     return null;
 }
 private BuildRunResults buildProject(RunInfo info, RunReport report)
 {
     var project = info.Project;
     var buildReport = _buildRunner.RunBuild(info, _configuration.BuildExecutable(project.Value), () => { return _exit(); });
     buildReport = postProcessBuildReports(buildReport);
     var succeeded = buildReport.ErrorCount == 0;
     report.AddBuild(buildReport.Project, buildReport.TimeSpent, succeeded);
     _bus.Publish(new BuildRunMessage(buildReport));
     if (succeeded)
         return null;
     else
         return buildReport;
 }
        private BuildRunResults buildSolution(RunInfo[] projectList, RunReport runReport)
        {
            var buildExecutable = _configuration.BuildExecutable(new ProjectDocument(ProjectType.None));
            if (File.Exists(buildExecutable))
            {
                _bus.Publish(new RunInformationMessage(InformationType.Build, _configuration.SolutionToBuild, "", typeof(MSBuildRunner)));

                var buildReport = _buildRunner.RunBuild(_configuration.SolutionToBuild, projectList.Where(p => p.Project.Value.RequiresRebuild).Count() > 0, buildExecutable, () => { return _exit(); });
                buildReport = postProcessBuildReports(buildReport);
                var succeeded = buildReport.ErrorCount == 0;
                runReport.AddBuild(_configuration.WatchToken, buildReport.TimeSpent, succeeded);
                _bus.Publish(new BuildRunMessage(buildReport));
                if (succeeded)
                    return null;
                else
                    return buildReport;
            }
            return null;
        }
 private BuildRunResults buildProjects(RunInfo[] projectList, RunReport runReport)
 {
     var indirectlyBuilt = new List<string>();
     foreach (var file in projectList)
     {
         if (file.ShouldBeBuilt)
         {
             Debug.WriteDebug("Set to build project {0}", file.Project.Key);
             var report = build(file, runReport);
             if (report != null)
                 return report;
         }
         else
         {
             Debug.WriteDebug("Not set to build project {0}", file.Project.Key);
             indirectlyBuilt.Add(file.Project.Key);
         }
     }
     foreach (var project in indirectlyBuilt)
         runReport.AddBuild(project, new TimeSpan(0), true);
     return null;
 }