public int Execute(BoostTestRunnerCommandLineArgs args, BoostTestRunnerSettings settings, IProcessExecutionContext executionContext)
        {
            var fixedArgs = args;

            if (args != null)
            {
                // Adapt a copy of the command-line arguments to avoid changing the original
                fixedArgs = AdaptArguments(args.Clone());
            }

            using (var stderr = new TemporaryFile(IsStandardErrorFileDifferent(args, fixedArgs) ? fixedArgs.StandardErrorFile : null))
            {
                int resultCode = this.Runner.Execute(fixedArgs, settings, executionContext);

                // Extract the report output to its intended location
                string source      = (fixedArgs == null) ? null : fixedArgs.StandardErrorFile;
                string destination = (args == null) ? null : args.ReportFile;

                if ((source != null) && (destination != null))
                {
                    try
                    {
                        ExtractReport(source, destination, string.IsNullOrEmpty(stderr.Path));
                    }
                    catch (Exception ex)
                    {
                        Logger.Exception(ex, "Failed to extract test report from standard error [{0}] to report file [{1}] ({2})", source, destination, ex.Message);
                    }
                }

                return(resultCode);
            }
        }
        public void Execute(BoostTestRunnerCommandLineArgs args, BoostTestRunnerSettings settings, IProcessExecutionContext executionContext)
        {
            var fixedArgs = args;

            if (args != null)
            {
                // Adapt a copy of the command-line arguments to avoid changing the original
                fixedArgs = AdaptArguments(args.Clone());
            }

            using (var stderr = new TemporaryFile(IsStandardErrorFileDifferent(args, fixedArgs) ? fixedArgs.StandardErrorFile : null))
            {
                this.Runner.Execute(fixedArgs, settings, executionContext);

                // Extract the report output to its intended location
                string source = (fixedArgs == null) ? null : fixedArgs.StandardErrorFile;
                string destination = (args == null) ? null : args.ReportFile;

                if ((source != null) && (destination != null))
                {
                    try
                    {
                        ExtractReport(source, destination, string.IsNullOrEmpty(stderr.Path));
                    }
                    catch (Exception ex)
                    {
                        Logger.Exception(ex, "Failed to extract test report from standard error [{0}] to report file [{1}] ({2})", source, destination, ex.Message);
                    }
                }
            }
        }
        /// <summary>
        /// Provides a ProcessExecutionContextArgs structure containing the necessary information to launch the test process.
        /// Aggregates the BoostTestRunnerCommandLineArgs structure with the command-line arguments specified at configuration stage.
        /// </summary>
        /// <param name="args">The Boost Test Framework command line arguments</param>
        /// <param name="settings">The Boost Test Runner settings</param>
        /// <returns>A valid ProcessExecutionContextArgs structure to launch the test executable</returns>
        protected override ProcessExecutionContextArgs GetExecutionContextArgs(BoostTestRunnerCommandLineArgs args, BoostTestRunnerSettings settings)
        {
            Code.Require(args, "args");

            ProcessExecutionContextArgs info = base.GetExecutionContextArgs(args, settings);

            BoostTestRunnerCommandLineArgs tmpArgs = args.Clone();

            tmpArgs.StandardErrorFile = null;
            tmpArgs.StandardOutFile   = null;

            CommandEvaluator        evaluator = BuildEvaluator(this.Source, tmpArgs, settings);
            CommandEvaluationResult result    = evaluator.Evaluate(this.Settings.ExecutionCommandLine.Arguments);

            string cmdLineArgs = result.Result;

            if (!result.MappedVariables.Contains(BoostArgsPlaceholder))
            {
                cmdLineArgs = result.Result + (result.Result.EndsWith(" ", StringComparison.Ordinal) ? string.Empty : " ") + args.ToString();
            }

            BoostTestRunnerCommandLineArgs redirection = new BoostTestRunnerCommandLineArgs
            {
                StandardOutFile   = args.StandardOutFile,
                StandardErrorFile = args.StandardErrorFile
            };

            cmdLineArgs += redirection.ToString();

            info.FilePath  = evaluator.Evaluate(this.Settings.ExecutionCommandLine.FileName).Result;
            info.Arguments = cmdLineArgs;

            return(info);
        }
        /// <summary>
        /// Provides a ProcessExecutionContextArgs structure containing the necessary information to launch the test process.
        /// Aggregates the BoostTestRunnerCommandLineArgs structure with the command-line arguments specified at configuration stage.
        /// </summary>
        /// <param name="args">The Boost Test Framework command line arguments</param>
        /// <param name="settings">The Boost Test Runner settings</param>
        /// <returns>A valid ProcessExecutionContextArgs structure to launch the test executable</returns>
        protected override ProcessExecutionContextArgs GetExecutionContextArgs(BoostTestRunnerCommandLineArgs args, BoostTestRunnerSettings settings)
        {
            ProcessExecutionContextArgs info = base.GetExecutionContextArgs(args, settings);

            BoostTestRunnerCommandLineArgs tmpArgs = args.Clone();
            tmpArgs.StandardErrorFile = null;
            tmpArgs.StandardOutFile = null;

            CommandEvaluator evaluator = BuildEvaluator(this.Source, tmpArgs, settings);
            CommandEvaluationResult result = evaluator.Evaluate(this.Settings.ExecutionCommandLine.Arguments);

            string cmdLineArgs = result.Result;
            if (!result.MappedVariables.Contains(BoostArgsPlaceholder))
            {
                cmdLineArgs = result.Result + (result.Result.EndsWith(" ", StringComparison.Ordinal) ? string.Empty : " ") + args.ToString();
            }

            BoostTestRunnerCommandLineArgs redirection = new BoostTestRunnerCommandLineArgs
            {
                StandardOutFile = args.StandardOutFile,
                StandardErrorFile = args.StandardErrorFile
            };
            cmdLineArgs += redirection.ToString();

            info.FilePath = this.Settings.ExecutionCommandLine.FileName;
            info.Arguments = cmdLineArgs;

            return info;
        }