/// <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> /// Executes the discovery command as specified in the configuration for the requested test source. /// </summary> /// <param name="source">The test source module</param> /// <returns>The test framework describing all tests contained within the test source or null if one cannot be provided.</returns> private TestFramework ExecuteExternalDiscoveryCommand(string source) { // Use a temporary file to host the result of the external discovery process string path = Path.Combine(Path.GetDirectoryName(source), Path.GetFileName(source) + ListFileSuffix); // Perform cleanup to avoid inconsistent listing if (File.Exists(path)) { File.Delete(path); } CommandEvaluator evaluator = new CommandEvaluator(); evaluator.SetVariable("source", "\"" + source + "\""); evaluator.SetVariable("out", "\"" + path + "\""); // Evaluate the discovery command CommandLine commandLine = new CommandLine { FileName = evaluator.Evaluate(Settings.DiscoveryCommandLine.FileName).Result, Arguments = evaluator.Evaluate(Settings.DiscoveryCommandLine.Arguments).Result }; // Execute the discovery command via an external process if (ExecuteCommand(commandLine)) { // Parse the generate TestFramework from the temporary file return(ParseTestFramework(path)); } return(null); }
/// <summary> /// Provides a ProcessStartInfo 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 ProcessStartInfo structure to launch the test executable</returns> protected override ProcessStartInfo GetStartInfo(BoostTestRunnerCommandLineArgs args, BoostTestRunnerSettings settings) { ProcessStartInfo info = base.GetStartInfo(args, settings); CommandEvaluator evaluator = BuildEvaluator(this.Source, args, 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(); } info.FileName = this.Settings.ExecutionCommandLine.FileName; info.Arguments = cmdLineArgs; return(info); }