Exemplo n.º 1
0
        protected virtual void CollectCoverageData(Project testProject, PrepareArgs prepareParams)
        {
            try
            {
                var options    = MakeCollectParams();
                var logging    = coverageLogging;
                var statusCode = CSApi.Collect(options, logging);

                if (statusCode != 0)
                {
                    throw new CodeCoverageException(testProject, $"Failed while collecting coverage data. Status code: {statusCode}.");
                }
            }
            catch (Exception e)
            {
                throw new CodeCoverageException(testProject, $"Failed while collection coverage data.", e);
            }

            CollectArgs MakeCollectParams()
            {
                return(new CollectArgs
                {
                    RecorderDirectory = prepareParams.InputDirectory
                });
            }
        }
Exemplo n.º 2
0
 private static ProcessArgumentBuilder ProcessArguments(
     ICakeContext cakeContext,
     ProcessArgumentBuilder builder,
     FilePath project,
     AltCoverSettings altcover)
 {
     Array.ForEach(
         CSApi.ToTestArgumentList(
             altcover.PreparationPhase,
             altcover.CollectionPhase,
             altcover.Force),
         t => builder.Append(t));
     return(builder);
 }
Exemplo n.º 3
0
        protected virtual PrepareArgs PrepareProjectForCoverage(Project testProject, ConfigurationSelector configuration)
        {
            try
            {
                var options = MakePrepareParamsForTestProject();
                DeleteCoverageDirectoryIfAlreadyExists(options);
                var statusCode = CSApi.Prepare(options, coverageLogging);

                if (statusCode != 0)
                {
                    throw new CodeCoverageException(testProject, $"Failed while preparing project for coverage. Status code: {statusCode}.");
                }

                return(options);
            }
            catch (Exception e)
            {
                throw new CodeCoverageException(testProject, $"Failed while preparing project for coverage.", e);
            }

            void DeleteCoverageDirectoryIfAlreadyExists(PrepareArgs options)
            {
                if (Directory.Exists(options.OutputDirectory))
                {
                    Directory.Delete(options.OutputDirectory, true);
                }
            }

            PrepareArgs MakePrepareParamsForTestProject()
            {
                var projectOutputDirectory  = testProject.GetOutputFileName(configuration).ParentDirectory;
                var coverageOutputDirectory = CoverageOutputPathForProject(testProject, configuration);
                var xmlReportPath           = CoverageFilePathForProject(testProject, configuration);

                return(new PrepareArgs
                {
                    InputDirectory = projectOutputDirectory,
                    OutputDirectory = coverageOutputDirectory,
                    XmlReport = xmlReportPath,
                    OpenCover = true,
                    InPlace = true,
                    Save = false
                });
            }
        }
Exemplo n.º 4
0
 public static string Version(this ICakeContext context)
 {
     return(CSApi.Version());
 }
Exemplo n.º 5
0
 public static string Ipmo(this ICakeContext context)
 {
     return(CSApi.Ipmo());
 }
Exemplo n.º 6
0
 public static int Collect(this ICakeContext context, ICollectArgs c, ILogArgs l = null)
 {
     return(CSApi.Collect(c, MakeLog(context, l)));
 }
Exemplo n.º 7
0
 public static int Prepare(this ICakeContext context, IPrepareArgs p, ILogArgs l = null)
 {
     return(CSApi.Prepare(p, MakeLog(context, l)));
 }