Esempio n. 1
0
        /// <summary>
        /// Prepare upload files and return as documents
        /// </summary>
        /// <param name="inputType"></param>
        protected InputFiles UploadFiles(HttpRequestBase Request, string sourceFolder)
        {
            try
            {
                var        pathProcessor = new PathProcessor(sourceFolder);
                InputFiles documents     = new InputFiles();

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFileBase postedFile = Request.Files[i];

                    if (postedFile != null)
                    {
                        // Check if File is available.
                        if (postedFile != null && postedFile.ContentLength > 0)
                        {
                            string _fileName = postedFile.FileName;
                            string _savepath = pathProcessor.SourceFolder + "\\" + System.IO.Path.GetFileName(_fileName);
                            postedFile.SaveAs(_savepath);
                            documents.Add(new InputFile(_fileName, sourceFolder, _savepath));
                        }
                    }
                }
                return(documents);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
Esempio n. 2
0
        protected InputFiles UploadFiles(HttpRequestBase Request, string _folderName)
        {
            try
            {
                //string _folderName = Guid.NewGuid().ToString();
                var        pathProcessor = new PathProcessor(_folderName);
                InputFiles _inputFiles   = new InputFiles();
                //foreach (string fileName in Request.Files)
                for (int i = 0; i < Request.Files.Count; i++)

                {
                    HttpPostedFileBase postedFile = Request.Files[i];

                    if (postedFile != null)
                    {
                        // Check if File is available.
                        if (postedFile != null && postedFile.ContentLength > 0)
                        {
                            string fn        = System.IO.Path.GetFileName(postedFile.FileName);
                            string _savepath = pathProcessor.SourceFolder + "\\" + fn;
                            postedFile.SaveAs(_savepath);
                            _inputFiles.Add(new InputFile(fn, _folderName, _savepath));
                        }
                    }
                }
                return(_inputFiles);
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
Esempio n. 3
0
        private void PopulateInputData()
        {
            string[] filePaths = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Input\\");
            foreach (var epsFileName in filePaths.Where(n => n.Contains("EPS")))
            {
                string[] words = epsFileName.Split('_');

                if (words != null && words.Length > 0)
                {
                    string hotelBedFileName = filePaths.FirstOrDefault(n => n.Contains(words[0]) && n.Contains("HB"));
                    InputFiles.Add(new InputFile(Path.GetFileName(words[0]), epsFileName, hotelBedFileName));
                }
            }
        }
Esempio n. 4
0
        private CommandLineOptions(Context context)
        {
            context.put(CONTEX_KEY, this);

            optionSet = new OptionSet {
                { "v|verbose", s => Verbose = true },
                { "dump-tree", s => DumpTree = true },
                { "pretty-print-tree", s => PrettyPrintTree = true },
                { "h|help", s => ShowHelp = true },
                { "<>", "Input files", s => InputFiles.Add(s), true },
                { "o|output=", "Output file path", s => OutPath = s },
                { "dump-ir", "Dump LLVM IR", s => DumpIR = true },
                { "exec", "Execute inside the compiler", s => Execute = true }
            };
        }
        public void AddFile(UserFile clickedItem)
        {
            bool isExist = false;

            foreach (UserFile inputFile in InputFiles)
            {
                if (inputFile.Name == clickedItem.Name)
                {
                    isExist = true;
                }
            }
            if (!isExist)
            {
                InputFiles.Add(clickedItem);
            }
            if (InputFiles.Count > 0)
            {
                ShowFileInfoPanel();
            }
        }
        public static int Parse(string[] args)
        {
            for (int i = 0; i < args.Length; i++)
            {
                bool   hasColonArgument = false;
                string beforeColon;
                string afterColon = null;
                int    colonIndex = args[i].IndexOf(':');
                if (colonIndex >= 0 && (args[i].StartsWith("-") || args[i].StartsWith("/")))
                {
                    hasColonArgument = true;
                    beforeColon      = args[i].Substring(0, colonIndex);
                    afterColon       = args[i].Substring(colonIndex + 1);
                }
                else
                {
                    beforeColon = args[i];
                }

                switch (beforeColon)
                {
                case "-kernelArgs":
                case "/kernelArgs":
                    if (!hasColonArgument)
                    {
                        Console.WriteLine("Error: parameter list expected after " + beforeColon + " argument");
                        Environment.Exit(1);
                    }

                    afterColon = afterColon.Trim();
                    if (afterColon.StartsWith("[") && afterColon.EndsWith("]"))
                    {
                        afterColon = afterColon.Substring(1, afterColon.Length - 2);
                    }
                    else if (afterColon.StartsWith("[") || afterColon.EndsWith("]"))
                    {
                        Console.WriteLine("Error: parameter list must be enclosed in square brackets or not at all.");
                        Environment.Exit(1);
                    }

                    List <string> kernelArgs = new List <string>(afterColon.Split(','));
                    if (kernelArgs.Count == 0 || kernelArgs.Any(x => x.Length == 0))
                    {
                        Console.WriteLine("Error: Cannot have empty parameters");
                        Environment.Exit(1);
                    }

                    KernelInterceptorParams.Add(kernelArgs);
                    break;

                case "-help":
                case "/help":
                case "-?":
                case "/?":
                    return(-1);

                case "-print":
                case "/print":
                    if (!hasColonArgument)
                    {
                        Console.WriteLine("Error: filename expected after " + beforeColon + " argument");
                        Environment.Exit(1);
                    }

                    Debug.Assert(afterColon != null);
                    OutputFile = afterColon;
                    break;

                case "-debugGPUVerify":
                case "/debugGPUVerify":
                    DebugGPUVerify = true;
                    break;

                case "-onlyDivergence":
                case "/onlyDivergence":
                    OnlyDivergence = true;
                    break;

                case "-adversarialAbstraction":
                case "/adversarialAbstraction":
                    AdversarialAbstraction = true;
                    break;

                case "-equalityAbstraction":
                case "/equalityAbstraction":
                    EqualityAbstraction = true;
                    break;

                case "-showStages":
                case "/showStages":
                    ShowStages = true;
                    break;

                case "-noInfer":
                case "/noInfer":
                    Inference = false;
                    break;

                case "-showUniformityAnalysis":
                case "/showUniformityAnalysis":
                    ShowUniformityAnalysis = true;
                    break;

                case "-noUniformityAnalysis":
                case "/noUniformityAnalysis":
                    DoUniformityAnalysis = false;
                    break;

                case "-showAccessBreaking":
                case "/showAccessBreaking":
                    ShowAccessBreaking = true;
                    break;

                case "-showMayBePowerOfTwoAnalysis":
                case "/showMayBePowerOfTwoAnalysis":
                    ShowMayBePowerOfTwoAnalysis = true;
                    break;

                case "-showArrayControlFlowAnalysis":
                case "/showArrayControlFlowAnalysis":
                    ShowArrayControlFlowAnalysis = true;
                    break;

                case "-onlyIntraGroupRaceChecking":
                case "/onlyIntraGroupRaceChecking":
                    OnlyIntraGroupRaceChecking = true;
                    break;

                case "-noBenign":
                case "/noBenign":
                    NoBenign = true;
                    break;

                case "-noBarrierAccessChecks":
                case "/noBarrierAccessChecks":
                    BarrierAccessChecks = false;
                    break;

                case "-asymmetricAsserts":
                case "/asymmetricAsserts":
                    AsymmetricAsserts = true;
                    break;

                case "-onlyLog":
                case "/onlyLog":
                    OnlyLog = true;
                    break;

                case "-mathInt":
                case "/mathInt":
                    MathInt = true;
                    break;

                case "-abstractHoudini":
                case "/abstractHoudini":
                    AbstractHoudini = true;
                    break;

                case "-doWarpSync":
                case "/doWarpSync":
                    WarpSync = true;
                    if (hasColonArgument)
                    {
                        WarpSize = int.Parse(afterColon);
                    }
                    break;

                case "-atomics":
                case "/atomics":
                    if (hasColonArgument)
                    {
                        switch (afterColon)
                        {
                        case "r":
                            AtomicVsRead  = true;
                            AtomicVsWrite = false;
                            break;

                        case "w":
                            AtomicVsRead  = false;
                            AtomicVsWrite = true;
                            break;

                        case "rw":
                            AtomicVsRead  = true;
                            AtomicVsWrite = true;
                            break;

                        case "none":
                            AtomicVsRead  = false;
                            AtomicVsWrite = false;
                            break;

                        default:
                            AtomicVsRead  = true;
                            AtomicVsWrite = true;
                            break;
                        }
                    }

                    break;

                case "-noRefinedAtomics":
                case "/noRefinedAtomics":
                    RefinedAtomics = false;
                    break;

                case "-noRemovePrivateArrayAccesses":
                case "/noRemovePrivateArrayAccesses":
                    RemovePrivateArrayAccesses = false;
                    break;

                case "-noEliminateRedundantReadInstrumentation":
                case "/noEliminateRedundantReadInstrumentation":
                    EliminateRedundantReadInstrumentation = false;
                    break;

                case "-noOptimiseBarrierIntervals":
                case "/noOptimiseBarrierIntervals":
                    OptimiseBarrierIntervals = false;
                    break;

                case "-checkSingleNonInlinedImpl":
                case "/checkSingleNonInlinedImpl":
                    CheckSingleNonInlinedImpl = true;
                    break;

                case "-noCandidate":
                case "/noCandidate":
                    DoNotGenerateCandidates.Add(afterColon);
                    break;

                case "-noPruneInfeasibleEdges":
                case "/noPruneInfeasibleEdges":
                    PruneInfeasibleEdges = false;
                    break;

                case "-noSafeBarrierIdentification":
                case "/noSafeBarrierIdentification":
                    IdentifySafeBarriers = false;
                    break;

                case "-nondeterminiseUninterpretedFunctions":
                case "/nondeterminiseUninterpretedFunctions":
                    NonDeterminiseUninterpretedFunctions = true;
                    break;

                case "-raceChecking":
                case "/raceChecking":
                    if (!hasColonArgument || (afterColon != "ORIGINAL" && afterColon != "SINGLE" && afterColon != "MULTIPLE"))
                    {
                        Console.WriteLine("Error: one of 'ORIGINAL', 'SINGLE' or 'MULTIPLE' expected after " + beforeColon + " argument");
                        Environment.Exit(1);
                    }

                    if (afterColon == "ORIGINAL")
                    {
                        RaceInstrumentationUtil.RaceCheckingMethod = RaceCheckingMethod.ORIGINAL;
                    }
                    else if (afterColon == "SINGLE")
                    {
                        RaceInstrumentationUtil.RaceCheckingMethod = RaceCheckingMethod.WATCHDOG_SINGLE;
                    }
                    else
                    {
                        RaceInstrumentationUtil.RaceCheckingMethod = RaceCheckingMethod.WATCHDOG_MULTIPLE;
                    }

                    break;

                case "-printLoopStatistics":
                case "/printLoopStatistics":
                    PrintLoopStatistics = true;
                    break;

                case "-disableInessentialLoopDetection":
                case "/disableInessentialLoopDetection":
                    DisableInessentialLoopDetection = true;
                    break;

                case "-checkArrayBounds":
                case "/checkArrayBounds":
                    ArrayBoundsChecking = true;
                    break;

                case "-checkArrays":
                case "/checkArrays":
                    if (!hasColonArgument)
                    {
                        Console.WriteLine("Error: a comma-separated list of array names must be provided after " + beforeColon + " argument");
                        Environment.Exit(1);
                    }

                    if (ArraysToCheck == null)
                    {
                        ArraysToCheck = new HashSet <string>();
                    }

                    foreach (var arrayName in afterColon.Split(','))
                    {
                        ArraysToCheck.Add(arrayName);
                    }

                    break;

                default:
                    InputFiles.Add(args[i]);
                    break;
                }
            }

            return(0);
        }
Esempio n. 7
0
        protected virtual void ConfigureOptions()
        {
            // NOTE: The order in which patterns are added
            // determines the display order for the help.

            // Select Tests
            this.Add("test=", "Comma-separated list of {NAMES} of tests to run or explore. This option may be repeated.",
                     v => ((List <string>)TestList).AddRange(TestNameParser.Parse(RequiredValue(v, "--test"))));
#if !PORTABLE
            this.Add("testlist=", "File {PATH} containing a list of tests to run, one per line. This option may be repeated.",
                     v =>
            {
                string testListFile = RequiredValue(v, "--testlist");

                var fullTestListPath = ExpandToFullPath(testListFile);

                if (!File.Exists(fullTestListPath))
                {
                    ErrorMessages.Add("Unable to locate file: " + testListFile);
                }
                else
                {
                    try
                    {
                        using (var rdr = new StreamReader(fullTestListPath))
                        {
                            while (!rdr.EndOfStream)
                            {
                                var line = rdr.ReadLine().Trim();

                                if (line[0] != '#')
                                {
                                    ((List <string>)TestList).Add(line);
                                }
                            }
                        }
                    }
                    catch (IOException)
                    {
                        ErrorMessages.Add("Unable to read file: " + testListFile);
                    }
                }
            });
#endif
            this.Add("where=", "Test selection {EXPRESSION} indicating what tests will be run. See description below.",
                     v => WhereClause = RequiredValue(v, "--where"));

            this.Add("timeout=", "Set timeout for each test case in {MILLISECONDS}.",
                     v => defaultTimeout = RequiredInt(v, "--timeout"));

            this.Add("seed=", "Set the random {SEED} used to generate test cases.",
                     v => randomSeed = RequiredInt(v, "--seed"));
#if !PORTABLE
            this.Add("workers=", "Specify the {NUMBER} of worker threads to be used in running tests. If not specified, defaults to 2 or the number of processors, whichever is greater.",
                     v => numWorkers = RequiredInt(v, "--workers"));
#endif
            this.Add("stoponerror", "Stop run immediately upon any test failure or error.",
                     v => StopOnError = v != null);

            this.Add("wait", "Wait for input before closing console window.",
                     v => WaitBeforeExit = v != null);
#if !PORTABLE
            // Output Control
            this.Add("work=", "{PATH} of the directory to use for output files. If not specified, defaults to the current directory.",
                     v => workDirectory = RequiredValue(v, "--work"));

            this.Add("output|out=", "File {PATH} to contain text output from the tests.",
                     v => OutFile = RequiredValue(v, "--output"));

            this.Add("err=", "File {PATH} to contain error output from the tests.",
                     v => ErrFile = RequiredValue(v, "--err"));

            this.Add("full", "Prints full report of all test results.",
                     v => Full = v != null);

            this.Add("result=", "An output {SPEC} for saving the test results.\nThis option may be repeated.",
                     v => resultOutputSpecifications.Add(new OutputSpecification(RequiredValue(v, "--resultxml"))));

            this.Add("explore:", "Display or save test info rather than running tests. Optionally provide an output {SPEC} for saving the test info. This option may be repeated.", v =>
            {
                Explore = true;
                if (v != null)
                {
                    ExploreOutputSpecifications.Add(new OutputSpecification(v));
                }
            });

            this.Add("noresult", "Don't save any test results.",
                     v => noresult = v != null);
#endif
            this.Add("labels=", "Specify whether to write test case names to the output. Values: Off, On, All",
                     v => DisplayTestLabels = RequiredValue(v, "--labels", "Off", "On", "All"));
#if !PORTABLE
            this.Add("trace=", "Set internal trace {LEVEL}.\nValues: Off, Error, Warning, Info, Verbose (Debug)",
                     v => InternalTraceLevel = RequiredValue(v, "--trace", "Off", "Error", "Warning", "Info", "Verbose", "Debug"));

#if !NETCF
            this.Add("teamcity", "Turns on use of TeamCity service messages.",
                     v => TeamCity = v != null);
#endif

            this.Add("noheader|noh", "Suppress display of program information at start of run.",
                     v => NoHeader = v != null);

            this.Add("nocolor|noc", "Displays console output without color.",
                     v => NoColor = v != null);
#endif
            this.Add("verbose|v", "Display additional information as the test runs.",
                     v => Verbose = v != null);

            this.Add("help|h", "Display this message and exit.",
                     v => ShowHelp = v != null);

            this.Add("version|V", "Display the header and exit.",
                     v => ShowVersion = v != null);

            // Default
            this.Add("<>", v =>
            {
#if PORTABLE
                if (v.StartsWith("-") || v.StartsWith("/") && Environment.NewLine == "\r\n")
#else
                if (v.StartsWith("-") || v.StartsWith("/") && Path.DirectorySeparatorChar != '/')
#endif
                { ErrorMessages.Add("Invalid argument: " + v); }
                else
                {
                    InputFiles.Add(v);
                }
            });
        }
Esempio n. 8
0
 private void ProcessParameter(string param)
 {
     InputFiles.Add(param);
 }
Esempio n. 9
0
        private void ConfigureOptions()
        {
            var parser = new OptionParser(s => ErrorMessages.Add(s));

            // NOTE: The order in which patterns are added
            // determines the display order for the help.

            this.Add("test=", "Comma-separated list of {NAMES} of tests to run or explore. This option may be repeated.",
                     v => ((List <string>)TestList).AddRange(TestNameParser.Parse(parser.RequiredValue(v, "--test"))));

            this.Add("testlist=", "File {PATH} containing a list of tests to run, one per line. This option may be repeated.",
                     v =>
            {
                string testListFile = parser.RequiredValue(v, "--testlist");

                var fullTestListPath = ExpandToFullPath(testListFile);

                if (!File.Exists(fullTestListPath))
                {
                    ErrorMessages.Add("Unable to locate file: " + testListFile);
                }
                else
                {
                    try
                    {
                        using (var rdr = new StreamReader(fullTestListPath))
                        {
                            while (!rdr.EndOfStream)
                            {
                                var line = rdr.ReadLine().Trim();

                                if (!string.IsNullOrEmpty(line) && line[0] != '#')
                                {
                                    ((List <string>)TestList).Add(line);
                                }
                            }
                        }
                    }
                    catch (IOException)
                    {
                        ErrorMessages.Add("Unable to read file: " + testListFile);
                    }
                }
            });

            this.Add("where=", "Test selection {EXPRESSION} indicating what tests will be run. See description below.",
                     v => WhereClause = parser.RequiredValue(v, "--where"));

            this.Add("params|p=", "Deprecated and will be removed in a future release. Please use --testparam instead.",
                     v =>
            {
                const string deprecationWarning = "--params is deprecated and will be removed in a future release. Please use --testparam instead.";

                if (!WarningMessages.Contains(deprecationWarning))
                {
                    WarningMessages.Add(deprecationWarning);
                }

                string parameters = parser.RequiredValue(v, "--params");

                foreach (string param in parameters.Split(new[] { ';' }))
                {
                    var valuePair = parser.RequiredKeyValue(param);
                    if (valuePair.HasValue)
                    {
                        TestParameters[valuePair.Value.Key] = valuePair.Value.Value;
                    }
                }
            });

            this.Add("testparam|tp=", "Followed by a key-value pair separated by an equals sign. Test code can access the value by name.",
                     v =>
            {
                var valuePair = parser.RequiredKeyValue(parser.RequiredValue(v, "--testparam"));
                if (valuePair.HasValue)
                {
                    TestParameters[valuePair.Value.Key] = valuePair.Value.Value;
                }
            });

            this.Add("timeout=", "Set timeout for each test case in {MILLISECONDS}.",
                     v => DefaultTimeout = parser.RequiredInt(v, "--timeout"));

            this.Add("seed=", "Set the random {SEED} used to generate test cases.",
                     v => RandomSeed = parser.RequiredInt(v, "--seed"));

            this.Add("workers=", "Specify the {NUMBER} of worker threads to be used in running tests. If not specified, defaults to 2 or the number of processors, whichever is greater.",
                     v => NumberOfTestWorkers = parser.RequiredInt(v, "--workers"));

            this.Add("stoponerror", "Stop run immediately upon any test failure or error.",
                     v => StopOnError = v != null);

            this.Add("wait", "Wait for input before closing console window.",
                     v => WaitBeforeExit = v != null);

            // Output Control
            this.Add("work=", "{PATH} of the directory to use for output files. If not specified, defaults to the current directory.",
                     v => workDirectory = parser.RequiredValue(v, "--work"));

            this.Add("output|out=", "File {PATH} to contain text output from the tests.",
                     v => OutFile = parser.RequiredValue(v, "--output"));

            this.Add("result=", "An output {SPEC} for saving the test results.\nThis option may be repeated.",
                     v =>
            {
                var spec = parser.ResolveOutputSpecification(parser.RequiredValue(v, "--resultxml"), resultOutputSpecifications, _fileSystem, CURRENT_DIRECTORY_ON_ENTRY);
                if (spec != null)
                {
                    resultOutputSpecifications.Add(spec);
                }
            });

            this.Add("explore:", "Display or save test info rather than running tests. Optionally provide an output {SPEC} for saving the test info. This option may be repeated.", v =>
            {
                Explore  = true;
                var spec = parser.ResolveOutputSpecification(v, ExploreOutputSpecifications, _fileSystem, CURRENT_DIRECTORY_ON_ENTRY);
                if (spec != null)
                {
                    ExploreOutputSpecifications.Add(spec);
                }
            });

            this.Add("noresult", "Don't save any test results.",
                     v => noresult = v != null);

            this.Add("labels=", "Specify whether to write test case names to the output. Values: Off, On, Before, After, BeforeAndAfter, All",
                     v => DisplayTestLabels = parser.RequiredValue(v, "--labels", "Off", "On", "Before", "After", "BeforeAndAfter", "All"));

            this.Add("test-name-format=", "Non-standard naming pattern to use in generating test names.",
                     v => DefaultTestNamePattern = parser.RequiredValue(v, "--test-name-format"));

            this.Add("trace=", "Set internal trace {LEVEL}.\nValues: Off, Error, Warning, Info, Verbose (Debug)",
                     v => InternalTraceLevel = parser.RequiredValue(v, "--trace", "Off", "Error", "Warning", "Info", "Verbose", "Debug"));

            this.Add("teamcity", "Turns on use of TeamCity service messages. TeamCity engine extension is required.",
                     v => TeamCity = v != null);

            this.Add("noheader|noh", "Suppress display of program information at start of run.",
                     v => NoHeader = v != null);

            this.Add("nocolor|noc", "Displays console output without color.",
                     v => NoColor = v != null);

            this.Add("help|h", "Display this message and exit.",
                     v => ShowHelp = v != null);

            this.Add("version|V", "Display the header and exit.",
                     v => ShowVersion = v != null);

            this.Add("encoding=", "Specifies the encoding to use for Console standard output, for example utf-8, ascii, unicode.",
                     v => ConsoleEncoding = parser.RequiredValue(v, "--encoding"));

            // Default
            this.Add("<>", v =>
            {
                if (v.StartsWith("-") || v.StartsWith("/") && Path.DirectorySeparatorChar != '/')
                {
                    ErrorMessages.Add("Invalid argument: " + v);
                }
                else
                {
                    InputFiles.Add(v);
                }
            });

            this.Add("config=", "{NAME} of a project configuration to load (e.g.: Debug).",
                     v => ActiveConfig = parser.RequiredValue(v, "--config"));

            this.AddNetFxOnlyOption("configfile=", "{NAME} of configuration file to use for this run.",
                                    NetFxOnlyOption("configfile=", v => ConfigurationFile = parser.RequiredValue(v, "--configfile")));

            // Where to Run Tests
            this.AddNetFxOnlyOption("process=", "{PROCESS} isolation for test assemblies.\nValues: InProcess, Separate, Multiple. If not specified, defaults to Separate for a single assembly or Multiple for more than one.",
                                    NetFxOnlyOption("process=", v =>
            {
                ProcessModel = parser.RequiredValue(v, "--process", "Single", "InProcess", "Separate", "Multiple");
                // Change so it displays correctly even though it isn't absolutely needed
                if (ProcessModel.ToLower() == "single")
                {
                    ProcessModel = "InProcess";
                }
            }));

            this.AddNetFxOnlyOption("inprocess", "Synonym for --process:InProcess",
                                    NetFxOnlyOption("inprocess", v => ProcessModel = "InProcess"));

            this.AddNetFxOnlyOption("domain=", "{DOMAIN} isolation for test assemblies.\nValues: None, Single, Multiple. If not specified, defaults to Single for a single assembly or Multiple for more than one.",
                                    NetFxOnlyOption("domain=", v => DomainUsage = parser.RequiredValue(v, "--domain", "None", "Single", "Multiple")));

            // How to Run Tests
            this.AddNetFxOnlyOption("framework=", "{FRAMEWORK} type/version to use for tests.\nExamples: mono, net-3.5, v4.0, 2.0, mono-4.0. If not specified, tests will run under the framework they are compiled with.",
                                    NetFxOnlyOption("framework=", v => Framework = parser.RequiredValue(v, "--framework")));

            this.AddNetFxOnlyOption("x86", "Run tests in an x86 process on 64 bit systems",
                                    NetFxOnlyOption("x86", v => RunAsX86 = v != null));

            this.Add("dispose-runners", "Dispose each test runner after it has finished running its tests.",
                     v => DisposeRunners = v != null);

            this.AddNetFxOnlyOption("shadowcopy", "Shadow copy test files",
                                    NetFxOnlyOption("shadowcopy", v => ShadowCopyFiles = v != null));

            this.AddNetFxOnlyOption("loaduserprofile", "Load user profile in test runner processes",
                                    NetFxOnlyOption("loaduserprofile", v => LoadUserProfile = v != null));

            this.Add("skipnontestassemblies", "Skip any non-test assemblies specified, without error.",
                     v => SkipNonTestAssemblies = v != null);

            this.AddNetFxOnlyOption("agents=", "Specify the maximum {NUMBER} of test assembly agents to run at one time. If not specified, there is no limit.",
                                    NetFxOnlyOption("agents=", v => _maxAgents = parser.RequiredInt(v, "--agents")));

            this.AddNetFxOnlyOption("debug", "Launch debugger to debug tests.",
                                    NetFxOnlyOption("debug", v => DebugTests = v != null));

            this.AddNetFxOnlyOption("pause", "Pause before running to allow attaching a debugger.",
                                    NetFxOnlyOption("pause", v => PauseBeforeRun = v != null));

            this.Add("list-extensions", "List all extension points and the extensions for each.",
                     v => ListExtensions = v != null);

            this.AddNetFxOnlyOption("set-principal-policy=", "Set PrincipalPolicy for the test domain.",
                                    NetFxOnlyOption("set-principal-policy=", v => PrincipalPolicy = parser.RequiredValue(v, "--set-principal-policy", "UnauthenticatedPrincipal", "NoPrincipal", "WindowsPrincipal")));

#if DEBUG
            this.AddNetFxOnlyOption("debug-agent", "Launch debugger in nunit-agent when it starts.",
                                    NetFxOnlyOption("debug-agent", v => DebugAgent = v != null));
#endif
        }
Esempio n. 10
0
        public ConsoleOptions(params string[] args)
        {
            // NOTE: The order in which patterns are added
            // determines the display order for the help.

            // Old Options no longer supported:
            //   fixture
            //   xmlConsole
            //   noshadow
            //   nothread
            //   nodots

            // Options to be added:
            //   teamcity
            //   workers

            // Select Tests
            this.Add("test=", "Comma-separated list of {NAMES} of tests to run or explore. This option may be repeated.",
                     v => ((List <string>)TestList).AddRange(TestNameParser.Parse(RequiredValue(v, "--test"))));

            this.Add("include=", "Test {CATEGORIES} to be included. May be a single category, a comma-separated list of categories or a category expression.",
                     v => Include = RequiredValue(v, "--include"));

            this.Add("exclude=", "Test {CATEGORIES} to be excluded. May be a single category, a comma-separated list of categories or a category expression.",
                     v => Exclude = RequiredValue(v, "--exclude"));

            this.Add("config=", "{NAME} of a project configuration to load (e.g.: Debug).",
                     v => ActiveConfig = RequiredValue(v, "--config"));

            // Where to Run Tests
            this.Add("process=", "{PROCESS} isolation for test assemblies.\nValues: Single, Separate, Multiple",
                     v => ProcessModel = RequiredValue(v, "--process", "Single", "Separate", "Multiple"));

            this.Add("domain=", "{DOMAIN} isolation for test assemblies.\nValues: None, Single, Multiple",
                     v => DomainUsage = RequiredValue(v, "--domain", "None", "Single", "Multiple"));

            // How to Run Tests
            this.Add("framework=", "{FRAMEWORK} type/version to use for tests.\nExamples: mono, net-3.5, v4.0, 2.0, mono-4.0",
                     v => Framework = RequiredValue(v, "--framework"));

            this.Add("x86", "Run tests in an x86 process on 64 bit systems",
                     v => RunAsX86 = v != null);

            this.Add("dispose-runners", "Dispose each test runner after it has finished running its tests.",
                     v => DisposeRunners = v != null);

            this.Add("timeout=", "Set timeout for each test case in {MILLISECONDS}.",
                     v => defaultTimeout = RequiredInt(v, "--timeout"));

            this.Add("seed=", "Set the random {SEED} used to generate test cases.",
                     v => randomSeed = RequiredInt(v, "--seed"));

            this.Add("workers=", "Specify the {NUMBER} of worker threads to be used in running tests.",
                     v => numWorkers = RequiredInt(v, "--workers"));

            this.Add("stoponerror", "Stop run immediately upon any test failure or error.",
                     v => StopOnError = v != null);

            this.Add("wait", "Wait for input before closing console window.",
                     v => WaitBeforeExit = v != null);

            this.Add("pause", "Pause before run to allow debugging.",
                     v => PauseBeforeRun = v != null);

            // Output Control
            this.Add("work=", "{PATH} of the directory to use for output files.",
                     v => WorkDirectory = RequiredValue(v, "--work"));

            this.Add("output|out=", "File {PATH} to contain text output from the tests.",
                     v => OutFile = RequiredValue(v, "--output"));

            this.Add("err=", "File {PATH} to contain error output from the tests.",
                     v => ErrFile = RequiredValue(v, "--err"));

            this.Add("result=", "An output {SPEC} for saving the test results.\nThis option may be repeated.",
                     v => resultOutputSpecifications.Add(new OutputSpecification(RequiredValue(v, "--resultxml"))));

            this.Add("explore:", "Display or save test info rather than running tests. Optionally provide an output {SPEC} for saving the test info. This option may be repeated.", v =>
            {
                Explore = true;
                if (v != null)
                {
                    ExploreOutputSpecifications.Add(new OutputSpecification(v));
                }
            });

            this.Add("noresult", "Don't save any test results.",
                     v => noresult = v != null);

            this.Add("labels=", "Specify whether to write test case names to the output. Values: Off, On, All",
                     v => DisplayTestLabels = RequiredValue(v, "--labels", "Off", "On", "All"));

            this.Add("trace=", "Set internal trace {LEVEL}.\nValues: Off, Error, Warning, Info, Verbose (Debug)",
                     v => InternalTraceLevel = RequiredValue(v, "--trace", "Off", "Error", "Warning", "Info", "Verbose", "Debug"));

            this.Add("teamcity", "Turns on use of TeamCity service messages.",
                     v => TeamCity = v != null);

            this.Add("noheader|noh", "Suppress display of program information at start of run.",
                     v => NoHeader = v != null);

            this.Add("nocolor|noc", "Displays console output without color.",
                     v => NoColor = v != null);

            this.Add("verbose|v", "Display additional information as the test runs.",
                     v => Verbose = v != null);

            this.Add("help|h", "Display this message and exit.",
                     v => ShowHelp = v != null);

            // Default
            this.Add("<>", v =>
            {
                if (v.StartsWith("-") || v.StartsWith("/") && Path.DirectorySeparatorChar != '/')
                {
                    ErrorMessages.Add("Invalid argument: " + v);
                }
                else
                {
                    InputFiles.Add(v);
                }
            });

            if (args != null)
            {
                this.Parse(args);
            }
        }
Esempio n. 11
0
        protected virtual void ConfigureOptions()
        {
            // NOTE: The order in which patterns are added
            // determines the display order for the help.

            // Select Tests
            this.Add("test=", "Comma-separated list of {NAMES} of tests to run or explore. This option may be repeated.",
                     v => ((List <string>)TestList).AddRange(TestNameParser.Parse(RequiredValue(v, "--test"))));

            this.Add("testlist=", "File {PATH} containing a list of tests to run, one per line. This option may be repeated.",
                     v =>
            {
                string testListFile = RequiredValue(v, "--testlist");

                var fullTestListPath = ExpandToFullPath(testListFile);

                if (!File.Exists(fullTestListPath))
                {
                    ErrorMessages.Add("Unable to locate file: " + testListFile);
                }
                else
                {
                    try
                    {
                        using (var rdr = new StreamReader(fullTestListPath))
                        {
                            while (!rdr.EndOfStream)
                            {
                                var line = rdr.ReadLine().Trim();

                                if (!string.IsNullOrEmpty(line) && line[0] != '#')
                                {
                                    ((List <string>)TestList).Add(line);
                                }
                            }
                        }
                    }
                    catch (IOException)
                    {
                        ErrorMessages.Add("Unable to read file: " + testListFile);
                    }
                }
            });

            this.Add("where=", "Test selection {EXPRESSION} indicating what tests will be run. See description below.",
                     v => WhereClause = RequiredValue(v, "--where"));

            this.Add("params|p=", "Define a test parameter.",
                     v =>
            {
                string parameters = RequiredValue(v, "--params");

                // This can be changed without breaking backwards compatibility with frameworks.
                foreach (string param in parameters.Split(new[] { ';' }))
                {
                    int eq = param.IndexOf("=");
                    if (eq == -1 || eq == param.Length - 1)
                    {
                        ErrorMessages.Add("Invalid format for test parameter. Use NAME=VALUE.");
                    }
                    else
                    {
                        string name = param.Substring(0, eq);
                        string val  = param.Substring(eq + 1);

                        TestParameters[name] = val;
                    }
                }
            });

            this.Add("timeout=", "Set timeout for each test case in {MILLISECONDS}.",
                     v => defaultTimeout = RequiredInt(v, "--timeout"));

            this.Add("seed=", "Set the random {SEED} used to generate test cases.",
                     v => randomSeed = RequiredInt(v, "--seed"));

            this.Add("workers=", "Specify the {NUMBER} of worker threads to be used in running tests. If not specified, defaults to 2 or the number of processors, whichever is greater.",
                     v => numWorkers = RequiredInt(v, "--workers"));

            this.Add("stoponerror", "Stop run immediately upon any test failure or error.",
                     v => StopOnError = v != null);

            this.Add("wait", "Wait for input before closing console window.",
                     v => WaitBeforeExit = v != null);

            // Output Control
            this.Add("work=", "{PATH} of the directory to use for output files. If not specified, defaults to the current directory.",
                     v => workDirectory = RequiredValue(v, "--work"));

            this.Add("output|out=", "File {PATH} to contain text output from the tests.",
                     v => OutFile = RequiredValue(v, "--output"));

            this.Add("result=", "An output {SPEC} for saving the test results.\nThis option may be repeated.",
                     v => ResolveOutputSpecification(RequiredValue(v, "--resultxml"), resultOutputSpecifications));

            this.Add("explore:", "Display or save test info rather than running tests. Optionally provide an output {SPEC} for saving the test info. This option may be repeated.", v =>
            {
                Explore = true;
                ResolveOutputSpecification(v, ExploreOutputSpecifications);
            });

            this.Add("noresult", "Don't save any test results.",
                     v => noresult = v != null);

            this.Add("labels=", "Specify whether to write test case names to the output. Values: Off, On, Before, After, All",
                     v => DisplayTestLabels = RequiredValue(v, "--labels", "Off", "On", "Before", "After", "All"));

            this.Add("test-name-format=", "Non-standard naming pattern to use in generating test names.",
                     v => DefaultTestNamePattern = RequiredValue(v, "--test-name-format"));

            this.Add("trace=", "Set internal trace {LEVEL}.\nValues: Off, Error, Warning, Info, Verbose (Debug)",
                     v => InternalTraceLevel = RequiredValue(v, "--trace", "Off", "Error", "Warning", "Info", "Verbose", "Debug"));

            this.Add("teamcity", "Turns on use of TeamCity service messages. TeamCity engine extension is required.",
                     v => TeamCity = v != null);

            this.Add("noheader|noh", "Suppress display of program information at start of run.",
                     v => NoHeader = v != null);

            this.Add("nocolor|noc", "Displays console output without color.",
                     v => NoColor = v != null);

            this.Add("help|h", "Display this message and exit.",
                     v => ShowHelp = v != null);

            this.Add("version|V", "Display the header and exit.",
                     v => ShowVersion = v != null);

            this.Add("encoding=", "Specifies the encoding to use for Console standard output, for example utf-8, ascii, unicode.",
                     v => ConsoleEncoding = RequiredValue(v, "--encoding"));

            // Default
            this.Add("<>", v =>
            {
                if (v.StartsWith("-") || v.StartsWith("/") && Path.DirectorySeparatorChar != '/')
                {
                    ErrorMessages.Add("Invalid argument: " + v);
                }
                else
                {
                    InputFiles.Add(v);
                }
            });
        }
Esempio n. 12
0
        public CommandLineOptions(params string[] args)
        {
            // NOTE: The order in which patterns are added
            // determines the display order for the help.

            // Old Options no longer supported:
            //   test
            //   console
            //   include
            //   exclude

            // Old Options to continue supporting:
            //   lang
            //   cleanup
            //   help

            // Options to be added:
            //   test
            //   trace

            // Select Tests
            //this.Insert("test=", "Comma-separated list of {NAMES} of tests to run or explore. This option may be repeated.",
            //    v => ((List<string>)TestList).AddRange(TestNameParser.Parse(RequiredValue(v, "--test"))));

            this.Add("config=", "Project {CONFIG} to load (e.g.: Debug).",
                     v => ActiveConfig = RequiredValue(v, "--config"));

            this.Add("noload", "Suppress loading of most recent project.",
                     v => NoLoad = v != null);

            this.Add("run", "Automatically run the loaded project.",
                     v => RunAllTests = v != null);

            //this.Add("runselected", "Automatically run last selected tests.",
            //    v => RunSelectedTests = v != null);

            // Output GuiELement
            this.Add("trace=", "Set internal trace {LEVEL}.",
                     v => InternalTraceLevel = RequiredValue(v, "--trace", "Off", "Error", "Warning", "Info", "Verbose", "Debug"));

            this.Add("help|h", "Display this message and exit.",
                     v => ShowHelp = v != null);

            // Default
            this.Add("<>", v =>
            {
                if (v.StartsWith("-") || v.StartsWith("/") && Path.DirectorySeparatorChar != '/')
                {
                    ErrorMessages.Add("Invalid argument: " + v);
                }
                else
                {
                    InputFiles.Add(v);
                }
            });

            if (args != null)
            {
                this.Parse(args);
            }
        }
        void ConfigureOptions()
        {
            // NOTE: The order in which patterns are added
            // determines the display order for the help.

            // Select Tests
            this.Add("test=", "Comma-separated list of {NAMES} of tests to run or explore. This option may be repeated.",
                     v => ((List <string>)TestList).AddRange(TestNameParser.Parse(RequiredValue(v, "--test"))));

            this.Add("where=", "Test selection {EXPRESSION} indicating what tests will be run. See description below.",
                     v => WhereClause = RequiredValue(v, "--where"));

            this.Add("timeout=", "Set timeout for each test case in {MILLISECONDS}.",
                     v => DefaultTimeout = RequiredInt(v, "--timeout"));

            this.Add("seed=", "Set the random {SEED} used to generate test cases.",
                     v => RandomSeed = RequiredInt(v, "--seed"));
#if false
            this.Add("workers=", "Specify the {NUMBER} of worker threads to be used in running tests. If not specified, defaults to 2 or the number of processors, whichever is greater.",
                     v => numWorkers = RequiredInt(v, "--workers"));
#endif
            this.Add("stoponerror", "Stop run immediately upon any test failure or error.",
                     v => StopOnError = v != null);

            this.Add("wait", "Wait for input before closing console window.",
                     v => WaitBeforeExit = v != null);

            // Output Control
            this.Add("work=", "{PATH} of the directory to use for output files. If not specified, defaults to the current directory.",
                     v => workDirectory = RequiredValue(v, "--work"));

            this.Add("output|out=", "File {PATH} to contain text output from the tests.",
                     v => OutFile = RequiredValue(v, "--output"));

            this.Add("err=", "File {PATH} to contain error output from the tests.",
                     v => ErrFile = RequiredValue(v, "--err"));

            this.Add("full", "Prints full report of all test results.",
                     v => Full = v != null);

            this.Add("result=", "An output {SPEC} for saving the test results.\nThis option may be repeated.",
                     v => resultOutputSpecifications.Add(new OutputSpecification(RequiredValue(v, "--resultxml"))));

            this.Add("explore:", "Display or save test info rather than running tests. Optionally provide an output {SPEC} for saving the test info. This option may be repeated.", v =>
            {
                Explore = true;
                if (v != null)
                {
                    ExploreOutputSpecifications.Add(new OutputSpecification(v));
                }
            });

            this.Add("noresult", "Don't save any test results.",
                     v => noresult = v != null);

            this.Add("labels=", "Specify whether to write test case names to the output. Values: Off, On, All",
                     v => DisplayTestLabels = RequiredValue(v, "--labels", "Off", "On", "All"));

            this.Add("trace=", "Set internal trace {LEVEL}.\nValues: Off, Error, Warning, Info, Verbose (Debug)",
                     v => InternalTraceLevel = RequiredValue(v, "--trace", "Off", "Error", "Warning", "Info", "Verbose", "Debug"));

            this.Add("noheader|noh", "Suppress display of program information at start of run.",
                     v => NoHeader = v != null);

            this.Add("nocolor|noc", "Displays console output without color.",
                     v => NoColor = v != null);

            this.Add("verbose|v", "Display additional information as the test runs.",
                     v => Verbose = v != null);

            this.Add("help|h", "Display this message and exit.",
                     v => ShowHelp = v != null);

            this.Add("version|V", "Display the header and exit.",
                     v => ShowVersion = v != null);

#if NET451
            this.Add("debug", "Attaches the debugger on launch",
                     v => Debug = v != null);
#endif

            // .NET Core runner options
            this.Add("designtime", "Used to indicate that the runner is being launched by an IDE",
                     v => DesignTime = v != null);

            this.Add("port=", "Used by IDEs to specify a port number to listen for a connection",
                     v => Port = RequiredInt(v, "--port"));

            this.Add("wait-command", "Used by IDEs to indicate that the runner should connect to the port and wait for commands, instead of going ahead and executing the tests",
                     v => WaitCommand = v != null);

            this.Add("list", "Used by IDEs to request a list of tests that can be run",
                     v => List = v != null);

            this.Add("parentProcessId", "Used by IDEs to indicate the Parent PID",
                     v => ParentProcessId = RequiredInt(v, "--parentProcessId"));

            // Default
            this.Add("<>", v =>
            {
                if (v.StartsWith("-", StringComparison.Ordinal) || v.StartsWith("/", StringComparison.Ordinal) && Path.DirectorySeparatorChar != '/')
                {
                    ErrorMessages.Add("Invalid argument: " + v);
                }
                else
                {
                    InputFiles.Add(v);
                }
            });
        }
Esempio n. 14
0
        private bool ProcessArgs(bool ignoreCommandFile = false)
        {
            if (!string.IsNullOrEmpty(PocoyoDataFilePath))
            {
                if (!File.Exists(PocoyoDataFilePath))
                {
                    LogError($"Missing file: {PocoyoDataFilePath}");
                    return(false);
                }

                PocoyoData.LoadFromData(PocoyoDataFilePath);
            }

            if (!ignoreCommandFile)
            {
                if (!string.IsNullOrEmpty(CommandFile))
                {
                    if (!File.Exists(CommandFile))
                    {
                        LogError($"Missing --commands file: {CommandFile}");
                        return(false);
                    }

                    return(false);
                }
            }

            if (Files.Count == 0)
            {
                LogError($"Missing input files / folders");
                return(false);
            }

            foreach (var filePath in Files)
            {
                var inputFile = Path.GetFullPath(filePath);
                if (Directory.Exists(inputFile))
                {
                    foreach (var csharpFilePath in Directory.EnumerateFiles(inputFile, "*.cs", SearchOption.AllDirectories))
                    {
                        var found = InputFiles.FirstOrDefault(item => string.Equals(item, csharpFilePath));
                        if (found == null)
                        {
                            InputFiles.Add(csharpFilePath);
                        }
                    }
                }
                else if (File.Exists(inputFile))
                {
                    var found = InputFiles.FirstOrDefault(item => string.Equals(item, inputFile));
                    if (found == null)
                    {
                        InputFiles.Add(inputFile);
                    }
                }
                else
                {
                    LogError($"Invalid file: {inputFile}");
                    return(false);
                }
            }

            if (string.IsNullOrEmpty(OutputFile))
            {
                LogError($"Missing --outputFile");
                return(false);
            }

            var outputFilePath = Path.GetFullPath(OutputFile);
            var outputFolder   = Path.GetDirectoryName(outputFilePath);

            Directory.CreateDirectory(outputFolder);

            if (Directory.Exists(outputFilePath))
            {
                OutputFolder = outputFilePath;
            }
            else
            {
                if (File.Exists(outputFilePath))
                {
                    File.Delete(outputFilePath);
                }
                OutputFile = outputFilePath;
            }

            if (InputFiles.Count == 0)
            {
                LogError($"Missing input files / folders");
                return(false);
            }

            if (string.IsNullOrEmpty(CommandFile) || !CommandFile.ToLower().EndsWith(".json"))
            {
                SerializeToJson();
            }

            return(true);
        }
Esempio n. 15
0
 public void AddInputFile(string path, DateTime timestamp)
 {
     InputFiles.Add(path);
     myFileSystem.AddFile(path, timestamp);
 }
Esempio n. 16
0
        public CommandLineOptions(params string[] args)
        {
            //this.Add("config=", "Project {CONFIG} to load (e.g.: Debug).",
            //    v => ActiveConfig = v);

            this.Add("noload", "Suppress loading of the most recent test file.",
                     v => NoLoad = v != null);

            this.Add("run", "Automatically run the loaded tests.",
                     v => RunAllTests = v != null);

            this.Add("process=", "{PROCESS} isolation for test assemblies. Values: InProcess, Separate, Multiple. If not specified, defaults to Separate for a single assembly or Multiple for more than one.",
                     v =>
            {
                if (CheckRequiredValue(v, "--process", "InProcess", "Separate", "Multiple"))
                {
                    ProcessModel = v;
                }
            });

            this.Add("x86", "Run tests in an X86 process on 64-bit systems.",
                     v => RunAsX86 = v != null);

            this.Add("agents=", "Specify maximum {NUMBER} of test assembly agents to run at one time. If not specified, there is no limit.",
                     v =>
            {
                if (CheckRequiredInt(v, "--agents", out int val))
                {
                    MaxAgents = val;
                }
            });

            this.Add("inprocess", "Synonym for --process.InProcess.",
                     v => ProcessModel = "Single");

            this.Add("domain=", "{DOMAIN} isolation for test assemblies. Values: None, Single, Multiple. If not specified, defaults to Single for a single assembly or Multiple for more than one.",
                     v =>
            {
                if (CheckRequiredValue(v, "--domain", "None", "Single", "Multiple"))
                {
                    DomainUsage = v;
                }
            });

            //this.Add("runselected", "Automatically run last selected tests.",
            //    v => RunSelectedTests = v != null);

            this.Add("trace=", "Set internal trace {LEVEL}. Valid values are Off, Error, Warning, Info or Debug. Verbose is a synonym for Debug.",
                     v =>
            {
                if (CheckRequiredValue(v, "--trace", "Off", "Error", "Warning", "Info", "Verbose", "Debug"))
                {
                    InternalTraceLevel = v;
                }
            });

            this.Add("help|h", "Display the help message and exit.",
                     v => ShowHelp = v != null);

            // Default
            this.Add("<>", v =>
            {
                if (v.StartsWith("-") || v.StartsWith("/") && Path.DirectorySeparatorChar != '/')
                {
                    ErrorMessages.Add("Invalid argument: " + v);
                }
                else
                {
                    InputFiles.Add(v);
                }
            });

            if (args != null)
            {
                this.Parse(args);
            }
        }
Esempio n. 17
0
        public CommandLineOptions(params string[] args)
        {
            Add("config=", "Project {CONFIG} to load (e.g.: Debug).",
                v => ActiveConfig = v);

            Add("noload", "Suppress loading of the most recent test file.",
                v => NoLoad = v != null);

            Add("run", "Automatically run the loaded tests.",
                v => RunAllTests = v != null);

            Add("unattended", "Unattended execution: perform requested actions, then exit.",
                v => Unattended = v != null);

            Add("x86", "Run tests in an X86 process on 64-bit systems.",
                v => RunAsX86 = v != null);

            Add("agents=", "Specify maximum {NUMBER} of test assembly agents to run at one time. If not specified, there is no limit.",
                v =>
            {
                if (CheckRequiredInt(v, "--agents", out int val))
                {
                    MaxAgents = val;
                }
            });

            Add("work=", "{PATH} of the directory to use for output files. If not specified, defaults to the current directory.",
                v =>
            {
                if (CheckRequiredValue(v, "--work"))
                {
                    WorkDirectory = v;
                }
            });

            //Add("runselected", "Automatically run last selected tests.",
            //    v => RunSelectedTests = v != null);

            Add("trace=", "Set internal trace {LEVEL}. Valid values are Off, Error, Warning, Info or Debug. Verbose is a synonym for Debug.",
                v =>
            {
                if (CheckRequiredValue(v, "--trace", "Off", "Error", "Warning", "Info", "Verbose", "Debug"))
                {
                    InternalTraceLevel = v;
                }
            });

#if DEBUG
            Add("debug-agent", "Launch debugger in testcentric-agent when it starts.",
                v => DebugAgent = v != null);

            Add("simulate-unload-error", "Throw CannotUnloadAppDomainException when unloading AppDomain.",
                v => SimulateUnloadError = v != null);

            Add("simulate-unload-timeout", "Inject infinite loop when unloading AppDomain.",
                v => SimulateUnloadTimeout = v != null);
#endif

            Add("help|h", "Display the help message and exit.",
                v => ShowHelp = v != null);

            // Default
            Add("<>", v =>
            {
                if (v.StartsWith("-") || v.StartsWith("/") && Path.DirectorySeparatorChar != '/')
                {
                    ErrorMessages.Add("Invalid argument: " + v);
                }
                else
                {
                    InputFiles.Add(v);
                }
            });

            if (args != null)
            {
                Parse(args);
            }
        }
Esempio n. 18
0
 /// <summary>
 ///     Add a MetalsharpFile to the input files
 /// </summary>
 ///
 /// <example>
 ///     ```c#
 ///         new MetalsharpProject()
 ///         .AddInput(new MetalsharpFile("# File Text", "path\\to\\file.md");
 ///     ```
 /// </example>
 ///
 /// <param name="file">
 ///     The file to add.
 /// </param>
 ///
 /// <returns>
 ///     The current `MetalsharpProject`, allowing it to be fluent.
 /// </returns>
 public MetalsharpProject AddInput(MetalsharpFile file)
 {
     InputFiles.Add(file);
     return(this);
 }
Esempio n. 19
0
 public void ProcessPositionalParameter(string parameter)
 {
     InputFiles.Add(Path.GetFullPath(parameter));
 }