示例#1
0
        /// <summary>
        /// Creates the coverage report from the xml coverage files spécified.
        /// </summary>
        /// <param name="sources">The sources XML files.</param>
        /// <param name="destination">The destination directory.</param>
        /// <param name="logger">The logger.</param>
        public static void CreateReport(IList <string> sources, string destination, ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            if (sources == null || sources.Count == 0)
            {
                return;
            }

            if (String.IsNullOrEmpty(destination))
            {
                throw new ArgumentException("Destination must be a valid path.", "destination");
            }

            if (Directory.Exists(destination))
            {
                Directory.Delete(destination, true);
            }

            ProcessTask mergeTask = CreateMergeTask(sources, destination);

            logger.Log(LogSeverity.Info, string.Format("Genrating {0} coverage report to '{1}': \"{2}\" {3}", Name, destination, mergeTask.ExecutablePath, mergeTask.Arguments));

            mergeTask.CaptureConsoleOutput       = true;
            mergeTask.ConsoleOutputDataReceived += (sender, e) =>
            {
                if (e.Data != null)
                {
                    logger.Log(LogSeverity.Info, e.Data);
                }
            };

            mergeTask.CaptureConsoleError       = true;
            mergeTask.ConsoleErrorDataReceived += (sender, e) =>
            {
                if (e.Data != null)
                {
                    logger.Log(LogSeverity.Error, e.Data);
                }
            };

            if (!mergeTask.Run(null))
            {
                throw new PartCoverToolException(string.Format("Failed to generate {0} coverage report.  The report command failed with exit code {1}.", Name, mergeTask.ExitCode));
            }

            int i = 0;

            foreach (string source in sources)
            {
                if (!string.IsNullOrEmpty(source) && File.Exists(source))
                {
                    i++;
                    File.Move(source, Path.Combine(destination, String.Format("coverage_{0:D4}.xml", i)));
                }
            }
        }
        private static ProcessTask RunMSTest(string options)
        {
            string value = (string)RegistryUtils.GetValueWithBitness(
                ProcessorArchitecture.X86, RegistryHive.LocalMachine,
                @"Software\Microsoft\VisualStudio\9.0",
                "InstallDir", null);

            if (value == null)
            {
                Assert.Inconclusive("Visual Studio 2008 does not appear to be installed.");
            }

            string executablePath = Path.Combine(value, "MSTest.exe");

            if (!File.Exists(executablePath))
            {
                Assert.Inconclusive("Visual Studio 2008 appears to be installed but MSTest.exe was not found.");
            }

            string testAssemblyPath = AssemblyUtils.GetAssemblyLocalPath(typeof(SimpleTest).Assembly);
            string workingDirectory = Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(typeof(GallioTipIntegrationTest).Assembly));

            ProcessTask task = Tasks.StartProcessTask(executablePath,
                                                      "\"/testcontainer:" + testAssemblyPath + "\" " + options,
                                                      workingDirectory);

            Assert.IsTrue(task.Run(TimeSpan.FromSeconds(60)), "A timeout occurred.");
            return(task);
        }
        private ProcessTask RunNAnt(string target)
        {
            ProcessTask task = Tasks.StartProcessTask(executablePath,
                                                      String.Concat("-debug /f:Integration.build ", target,
                                                                    " /D:GallioPath=\"", RuntimeAccessor.RuntimePath, "\""),
                                                      workingDirectory);

            Assert.IsTrue(task.Run(TimeSpan.FromSeconds(60)), "A timeout occurred.");
            return(task);
        }
        private ProcessTask RunMSBuild(string target)
        {
            ProcessTask task = Tasks.StartProcessTask(executablePath,
                                                      String.Concat("Integration.proj /v:detailed /t:", target,
                                                                    " /p:GallioPath=\"", RuntimeAccessor.RuntimePath, "\""),
                                                      workingDirectory);

            Assert.IsTrue(task.Run(TimeSpan.FromSeconds(60)), "A timeout occurred.");
            return(task);
        }
示例#5
0
        public void Merge(IList <string> sources, string destination, ILogger logger)
        {
            if (File.Exists(destination))
            {
                File.Delete(destination);
            }

            if (sources.Count == 0)
            {
                return;
            }

            if (sources.Count == 1)
            {
                File.Move(sources[0], destination);
                return;
            }

            ProcessTask mergeTask = CreateMergeTask(sources, destination);

            logger.Log(LogSeverity.Info, string.Format("Merging {0} coverage files to '{1}': \"{2}\" {3}", Name, destination, mergeTask.ExecutablePath, mergeTask.Arguments));

            mergeTask.CaptureConsoleOutput       = true;
            mergeTask.ConsoleOutputDataReceived += (sender, e) =>
            {
                if (e.Data != null)
                {
                    logger.Log(LogSeverity.Info, e.Data);
                }
            };

            mergeTask.CaptureConsoleError       = true;
            mergeTask.ConsoleErrorDataReceived += (sender, e) =>
            {
                if (e.Data != null)
                {
                    logger.Log(LogSeverity.Error, e.Data);
                }
            };

            if (!mergeTask.Run(null))
            {
                throw new NCoverToolException(string.Format("Failed to merge {0} coverage files.  The merge command failed with exit code {1}.", Name, mergeTask.ExitCode));
            }

            if (!File.Exists(destination))
            {
                throw new NCoverToolException(string.Format("Failed to merge {0} coverage files.  The merge command did not produce the merged file as expected.", Name));
            }

            foreach (string source in sources)
            {
                File.Delete(source);
            }
        }
        private ProcessTask RunPowerShell(string options)
        {
            string executablePath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.System),
                @"windowspowershell\v1.0\powershell.exe");

            string workingDirectory = Path.GetDirectoryName((AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)));

            ProcessTask task = Tasks.StartProcessTask(executablePath,
                                                      "\"& Add-PSSnapIn Gallio; $DebugPreference = 'Continue'; Run-Gallio 'MbUnit.TestResources.dll' -pd '" +
                                                      RuntimeAccessor.RuntimePath + "' " + options + "\"",
                                                      workingDirectory);

            Assert.IsTrue(task.Run(TimeSpan.FromSeconds(60)), "A timeout occurred.");
            return(task);
        }
        private ProcessTask RunEcho(string options)
        {
            string testAssemblyPath = AssemblyUtils.GetAssemblyLocalPath(typeof(SimpleTest).Assembly);
            string workingDirectory = Path.GetDirectoryName((AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)));
#if DEBUG
            string executablePath = Path.Combine(workingDirectory, "Gallio.Echo.exe");
#else
            string executablePath = Path.Combine(RuntimeAccessor.Instance.GetRuntimeSetup().RuntimePath, "Gallio.Echo.exe");
#endif

            ProcessTask task = Tasks.StartProcessTask(executablePath,
                "\"" + testAssemblyPath + "\" /pd:\"" + RuntimeAccessor.RuntimePath + "\" " + options,
                workingDirectory);

            Assert.IsTrue(task.Run(TimeSpan.FromSeconds(60)), "A timeout occurred.");
            return task;
        }