示例#1
0
        private ProcessArgumentBuilder GetArguments(
            DotCoverContext context,
            DotCoverCoverSettings settings,
            FilePath outputPath)
        {
            var builder = new ProcessArgumentBuilder();

            builder.Append("Cover");

            // The target application to call.
            builder.AppendSwitch("/TargetExecutable", "=", context.FilePath.FullPath.Quote());

            // The arguments to the target application.
            var arguments = context.Settings?.Arguments?.Render();

            if (!string.IsNullOrWhiteSpace(arguments))
            {
                arguments = arguments.Replace("\"", "\\\"");
                builder.AppendSwitch("/TargetArguments", "=", arguments.Quote());
            }

            // Set the output file.
            outputPath = outputPath.MakeAbsolute(_environment);
            builder.AppendSwitch("/Output", "=", outputPath.FullPath.Quote());

            // Set common Coverage settings
            settings.ToArguments(_environment).CopyTo(builder);

            return(builder);
        }
示例#2
0
        private ProcessArgumentBuilder GetArguments(
            DotCoverContext context,
            DotCoverCoverSettings settings,
            FilePath outputPath)
        {
            var builder = new ProcessArgumentBuilder();

            builder.Append("Cover");

            // The target application to call.
            builder.AppendSwitch("/TargetExecutable", "=", context.FilePath.FullPath.Quote());

            // The arguments to the target application.
            var arguments = context.Settings?.Arguments?.Render();

            if (!string.IsNullOrWhiteSpace(arguments))
            {
                arguments = arguments.Replace("\"", "\\\"");
                builder.AppendSwitch("/TargetArguments", "=", arguments.Quote());
            }

            // Set the output file.
            outputPath = outputPath.MakeAbsolute(_environment);
            builder.AppendSwitch("/Output", "=", outputPath.FullPath.Quote());

            // TargetWorkingDir
            if (settings.TargetWorkingDir != null)
            {
                builder.AppendSwitch("/TargetWorkingDir", "=", settings.TargetWorkingDir.MakeAbsolute(_environment).FullPath.Quote());
            }

            // Scope
            if (settings.Scope.Count > 0)
            {
                var scope = string.Join(";", settings.Scope);
                builder.AppendSwitch("/Scope", "=", scope.Quote());
            }

            // Filters
            if (settings.Filters.Count > 0)
            {
                var filters = string.Join(";", settings.Filters);
                builder.AppendSwitch("/Filters", "=", filters.Quote());
            }

            // Filters
            if (settings.AttributeFilters.Count > 0)
            {
                var attributeFilters = string.Join(";", settings.AttributeFilters);
                builder.AppendSwitch("/AttributeFilters", "=", attributeFilters.Quote());
            }

            // DisableDefaultFilters
            if (settings.DisableDefaultFilters)
            {
                builder.Append("/DisableDefaultFilters");
            }

            return(builder);
        }
示例#3
0
        private static DotCoverContext InterceptAction(
            ICakeContext context,
            Action <ICakeContext> action)
        {
            var interceptor = new DotCoverContext(context);

            action(interceptor);

            // Validate arguments.
            if (interceptor.FilePath == null)
            {
                throw new CakeException("No tool was started.");
            }

            return(interceptor);
        }