Example #1
0
        public static XunitPerformanceHarnessOptions Parse(string[] args)
        {
            using (var parser = new Parser((settings) =>
            {
                settings.CaseInsensitiveEnumValues = true;
                settings.CaseSensitive = false;
                settings.HelpWriter = new StringWriter();
                settings.IgnoreUnknownArguments = true;
            }))
            {
                XunitPerformanceHarnessOptions options = null;
                var parserResult = parser.ParseArguments <XunitPerformanceHarnessOptions>(args)
                                   .WithParsed(parsed => options = parsed)
                                   .WithNotParsed(errors =>
                {
                    foreach (var error in errors)
                    {
                        switch (error.Tag)
                        {
                        case ErrorType.MissingValueOptionError:
                            throw new ArgumentException(
                                $"Missing value option for {(error as MissingValueOptionError).NameInfo.NameText}");

                        case ErrorType.HelpRequestedError:
                            Console.WriteLine(Usage());
                            Environment.Exit(0);
                            break;

                        case ErrorType.VersionRequestedError:
                            Console.WriteLine(new AssemblyName(typeof(XunitPerformanceHarnessOptions).GetTypeInfo().Assembly.FullName).Version);
                            Environment.Exit(0);
                            break;

                        case ErrorType.BadFormatTokenError:
                        case ErrorType.UnknownOptionError:
                        case ErrorType.MissingRequiredOptionError:
                        case ErrorType.MutuallyExclusiveSetError:
                        case ErrorType.BadFormatConversionError:
                        case ErrorType.SequenceOutOfRangeError:
                        case ErrorType.RepeatedOptionError:
                        case ErrorType.NoVerbSelectedError:
                        case ErrorType.BadVerbSelectedError:
                        case ErrorType.HelpVerbRequestedError:
                            break;
                        }
                    }
                });
                return(options);
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitPerformanceHarness"/> class.
        /// </summary>
        /// <param name="args">String array that contains any command-line arguments passed in.</param>
        public XunitPerformanceHarness(string[] args)
        {
            _args = new string[args.Length];
            args.CopyTo(_args, 0);

            _disposed = false;

            var options = XunitPerformanceHarnessOptions.Parse(_args);

            OutputDirectory             = options.OutputDirectory;
            _collectDefaultXUnitMetrics = options.MetricNames.Contains("default", StringComparer.OrdinalIgnoreCase);
            _metricCollectionFactory    = GetPerformanceMetricFactory(options.MetricNames);
            _requireEtw = RequireEtw(options.MetricNames);
            _typeNames  = new List <string>(options.TypeNames);

            Configuration.RunId       = options.RunId;
            Configuration.FileLogPath = $"{Configuration.RunId}.csv"; // TODO: Conditionally set this based on whether we want a csv file written.
        }
Example #3
0
        public XunitPerformanceHarness(string[] args)
        {
            _args        = args;
            _disposed    = false;
            _outputFiles = new List <string>();

            var options = XunitPerformanceHarnessOptions.Parse(args);

            // Set the run id.
            _outputDirectory = options.OutputDirectory;
            _typeNames       = new List <string>(options.TypeNames);
            _runner          = (assemblyPath) =>
            {
                XunitRunner.Run(assemblyPath, _typeNames);
            };

            Configuration.RunId = options.RunId;
            // Set the file log path.
            // TODO: Conditionally set this based on whether we want a csv file written.
            Configuration.FileLogPath = Configuration.RunId + ".csv";
        }
Example #4
0
 public static string Usage()
 {
     return(XunitPerformanceHarnessOptions.Usage());
 }
 public static string Usage() => XunitPerformanceHarnessOptions.Usage();