GetFiles() public static method

Retrieve file names from the command line
public static GetFiles ( string args ) : List
args string
return List
Example #1
0
        /// <summary>
        /// NBench Runner takes the following <see cref="args"/>
        ///
        /// C:\> NBench.Runner.exe [assembly name] [output-directory={dir-path}] [configuration={file-path}] [include=MyTest*.Perf*,Other*Spec] [exclude=*Long*] [concurrent={true|false}] [trace={true|false}] [teamcity={true|false}]
        ///
        /// </summary>
        /// <param name="args">The commandline arguments</param>
        static int Main(string[] args)
        {
            string[] include    = null;
            string[] exclude    = null;
            bool     concurrent = false;
            bool     trace      = false;
            bool     teamcity   = false;

            if (CommandLine.HasProperty("include"))
            {
                include = CommandLine.GetProperty("include").Split(',');
            }
            if (CommandLine.HasProperty("exclude"))
            {
                exclude = CommandLine.GetProperty("exclude").Split(',');
            }
            if (CommandLine.HasProperty("concurrent"))
            {
                concurrent = CommandLine.GetBool("concurrent");
            }
            if (CommandLine.HasProperty("trace"))
            {
                trace = CommandLine.GetBool("trace");
            }
            if (CommandLine.HasProperty("teamcity"))
            {
                teamcity = CommandLine.GetBool("teamcity");
            }
            else
            {
                // try to auto-detect if not explicitly set
                teamcity = !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME"));
            }


            TestPackage package = new TestPackage(CommandLine.GetFiles(args), include, exclude, concurrent)
            {
                Tracing = trace
            };

            if (CommandLine.HasProperty("output-directory"))
            {
                package.OutputDirectory = CommandLine.GetProperty("output-directory");
            }

            if (CommandLine.HasProperty("configuration"))
            {
                package.ConfigurationFile = CommandLine.GetProperty("configuration");
            }

            package.TeamCity = teamcity;

            package.Validate();
            var result = TestRunner.Run(package);

            return(result.AllTestsPassed ? 0 : -1);
        }
Example #2
0
        /// <summary>
        /// NBench Runner takes the following <see cref="args"/>
        ///
        /// C:\> NBench.Runner.exe [assembly name] [output-directory={dir-path}] [configuration={file-path}] [include=MyTest*.Perf*,Other*Spec] [exclude=*Long*] [concurrent={true|false}] [trace={true|false}]
        ///
        /// </summary>
        /// <param name="args">The commandline arguments</param>
        static int Main(string[] args)
        {
            string[] include    = null;
            string[] exclude    = null;
            bool     concurrent = false;
            bool     trace      = false;

            if (CommandLine.HasProperty("include"))
            {
                include = CommandLine.GetProperty("include").Split(',');
            }
            if (CommandLine.HasProperty("exclude"))
            {
                exclude = CommandLine.GetProperty("exclude").Split(',');
            }
            if (CommandLine.HasProperty("concurrent"))
            {
                concurrent = CommandLine.GetBool("concurrent");
            }
            if (CommandLine.HasProperty("trace"))
            {
                trace = CommandLine.GetBool("trace");
            }


            TestPackage package = new TestPackage(CommandLine.GetFiles(args), include, exclude, concurrent)
            {
                Tracing = trace
            };

            if (CommandLine.HasProperty("output-directory"))
            {
                package.OutputDirectory = CommandLine.GetProperty("output-directory");
            }

            if (CommandLine.HasProperty("configuration"))
            {
                package.ConfigurationFile = CommandLine.GetProperty("configuration");
            }

            package.Validate();
            var result = TestRunner.Run(package);

            return(result.AllTestsPassed ? 0 : -1);
        }
Example #3
0
        /// <summary>
        /// NBench Runner takes the following <see cref="args"/>
        ///
        /// C:\> NBench.Runner.exe [assembly name] [output-directory={dir-path}] [configuration={file-path}] [include=MyTest*.Perf*,Other*Spec] [exclude=*Long*] [concurrent={true|false}] [trace={true|false}] [teamcity={true|false}]
        ///
        /// </summary>
        /// <param name="args">The commandline arguments</param>
        static int Main(string[] args)
        {
            string[] include    = null;
            string[] exclude    = null;
            bool     concurrent = false;
            bool     trace      = false;
            bool     teamcity   = false;

            if (args.Length == 1 && args[0] == "--help")
            {
                CommandLine.ShowHelp();
                return(0);
            }

            if (CommandLine.HasProperty(CommandLine.DiagnosticsKey))
            {
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine("DIAG: Executing with parameters [{0}]", CommandLine.FormatCapturedArguments());
                Console.WriteLine("DIAG: Unparsed arguments [{0}]", string.Join(",", Environment.GetCommandLineArgs()));
                Console.WriteLine($"DIAG: Captured, but unrecognized arguments: {string.Join(",", CommandLine.Values.Value.Select(x => $"{x.Key}:[{string.Join(",", x.Value)}]"))}");
                Console.ResetColor();
            }

            if (CommandLine.HasProperty(CommandLine.IncludeKey))
            {
                include = CommandLine.GetProperty(CommandLine.IncludeKey)?.ToArray();
            }
            if (CommandLine.HasProperty(CommandLine.ExcludeKey))
            {
                exclude = CommandLine.GetProperty(CommandLine.ExcludeKey)?.ToArray();
            }
            if (CommandLine.HasProperty(CommandLine.ConcurrentKey))
            {
                concurrent = CommandLine.GetBool(CommandLine.ConcurrentKey);
            }
            if (CommandLine.HasProperty(CommandLine.TracingKey))
            {
                trace = CommandLine.GetBool(CommandLine.TracingKey);
            }
            if (CommandLine.HasProperty(CommandLine.TeamCityKey))
            {
                teamcity = true;
            }
            else
            {
                // try to auto-detect if not explicitly set
                teamcity = !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME"));
            }

            var files = CommandLine.GetFiles(args);

            if (files.Count == 0)
            {
                Console.WriteLine("Please provide assemblies for which to run NBench tests\n");
                CommandLine.ShowHelp();
                return(1);
            }

            TestPackage package =
                new TestPackage(files, include, exclude, concurrent)
            {
                Tracing = trace
            };

            if (CommandLine.HasProperty(CommandLine.OutputKey))
            {
                package.OutputDirectory = CommandLine.GetSingle(CommandLine.OutputKey);
            }

            if (CommandLine.HasProperty(CommandLine.ConfigurationKey))
            {
                package.ConfigurationFile = CommandLine.GetSingle(CommandLine.ConfigurationKey);
            }

            package.TeamCity = teamcity;

            package.Validate();
            var result = TestRunner.Run(package);

            return(result.AllTestsPassed ? 0 : -1);
        }
Example #4
0
        /// <summary>
        /// NBench Runner takes the following <see cref="args"/>
        ///
        /// C:\> NBench.Runner.exe [assembly name] [output-directory={dir-path}] [configuration={file-path}] [include=MyTest*.Perf*,Other*Spec] [exclude=*Long*] [concurrent={true|false}] [trace={true|false}] [teamcity={true|false}]
        ///
        /// </summary>
        /// <param name="args">The commandline arguments</param>
        static int Main(string[] args)
        {
            string[] include    = null;
            string[] exclude    = null;
            bool     concurrent = false;
            bool     trace      = false;
            bool     teamcity   = false;

            if (args.Length == 1 && args[0] == "--help")
            {
                CommandLine.ShowHelp();
                return(0);
            }

            if (CommandLine.HasProperty("include"))
            {
                include = CommandLine.GetProperty("include").Split(',');
            }
            if (CommandLine.HasProperty("exclude"))
            {
                exclude = CommandLine.GetProperty("exclude").Split(',');
            }
            if (CommandLine.HasProperty("concurrent"))
            {
                concurrent = CommandLine.GetBool("concurrent");
            }
            if (CommandLine.HasProperty("trace"))
            {
                trace = CommandLine.GetBool("trace");
            }
            if (CommandLine.HasProperty("teamcity"))
            {
                teamcity = CommandLine.GetBool("teamcity");
            }
            else
            {
                // try to auto-detect if not explicitly set
                teamcity = !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME"));
            }

            var files = CommandLine.GetFiles(args);

            if (files.Count == 0)
            {
                Console.WriteLine("Please provide assemblies for which to run NBench tests\n");
                CommandLine.ShowHelp();
                return(1);
            }

            TestPackage package =
                new TestPackage(files, include, exclude, concurrent)
            {
                Tracing = trace
            };

            if (CommandLine.HasProperty("output-directory"))
            {
                package.OutputDirectory = CommandLine.GetProperty("output-directory");
            }

            if (CommandLine.HasProperty("configuration"))
            {
                package.ConfigurationFile = CommandLine.GetProperty("configuration");
            }

            package.TeamCity = teamcity;

            package.Validate();
            var result = TestRunner.Run(package);

            return(result.AllTestsPassed ? 0 : -1);
        }