Exemplo n.º 1
0
        /// <summary>
        /// analyzes and runs the tests given in the param file.
        /// </summary>
        public void Run()
        {
            _ciRun = true;
            if (_runtype == TestStorageType.Unknown)
            {
                Enum.TryParse <TestStorageType>(_ciParams["runType"], true, out _runtype);
            }
            if (_runtype == TestStorageType.Unknown)
            {
                WriteToConsole(Resources.LauncherNoRuntype);
                return;
            }

            if (!_ciParams.ContainsKey("resultsFilename"))
            {
                WriteToConsole(Resources.LauncherNoResFilenameFound);
                return;
            }
            string resultsFilename = _ciParams["resultsFilename"];

            if (_ciParams.ContainsKey("uniqueTimeStamp"))
            {
                UniqueTimeStamp = _ciParams["uniqueTimeStamp"];
            }
            else
            {
                UniqueTimeStamp = resultsFilename.ToLower().Replace("results", "").Replace(".xml", "");
            }

            //create the runner according to type
            IAssetRunner runner = CreateRunner(_runtype, _ciParams);

            //runner instantiation failed (no tests to run or other problem)
            if (runner == null)
            {
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
            }

            //run the tests!
            RunTests(runner, resultsFilename);

            //Console.WriteLine("Press any key to exit...");
            //Console.ReadKey();
            ConsoleQuickEdit.Enable();
            if (Launcher.ExitCode != ExitCodeEnum.Passed)
            {
                Environment.Exit((int)Launcher.ExitCode);
            }
        }
Exemplo n.º 2
0
        //[MTAThread]
        static void Main(string[] args)
        {
            ConsoleQuickEdit.Disable();
            if (args.Count() == 0 || args.Contains("/?"))
            {
                ShowHelp();
                return;
            }
            // show version?
            if (args[0] == "-v" || args[0] == "-version" || args[0] == "/v")
            {
                Console.WriteLine(Assembly.GetEntryAssembly().GetName().Version.ToString());
                Environment.Exit(0);
                return;
            }

            for (int i = 0; i < args.Count(); i = i + 2)
            {
                string key = args[i].StartsWith("-") ? args[i].Substring(1) : args[i];
                string val = i + 1 < args.Count() ? args[i + 1].Trim() : String.Empty;
                argsDictionary[key] = val;
            }
            string paramFileName, runtype;
            string failOnTestFailed = "N";

            argsDictionary.TryGetValue("runtype", out runtype);
            argsDictionary.TryGetValue("paramfile", out paramFileName);
            TestStorageType enmRuntype = TestStorageType.Unknown;

            if (!Enum.TryParse <TestStorageType>(runtype, true, out enmRuntype))
            {
                enmRuntype = TestStorageType.Unknown;
            }

            if (string.IsNullOrEmpty(paramFileName))
            {
                ShowHelp();
                return;
            }

            ShowTitle();
            ConsoleWriter.WriteLine(Resources.GeneralStarted);

            var apiRunner = new Launcher(failOnTestFailed, paramFileName, enmRuntype);

            apiRunner.Run();
        }
Exemplo n.º 3
0
        //[MTAThread]
        static void Main(string[] args)
        {
            ConsoleWriter.WriteLine(Resources.GeneralStarted);
            ConsoleQuickEdit.Disable();
            Console.OutputEncoding = System.Text.Encoding.GetEncoding("utf-8");
            if (args.Count() == 0 || args.Contains("/?"))
            {
                ShowHelp();
                return;
            }
            for (int i = 0; i < args.Count(); i = i + 2)
            {
                string key = args[i].StartsWith("-") ? args[i].Substring(1) : args[i];
                string val = i + 1 < args.Count() ? args[i + 1].Trim() : String.Empty;
                argsDictionary[key] = val;
            }
            string paramFileName, runtype;
            string failOnTestFailed = "N";

            argsDictionary.TryGetValue("runtype", out runtype);
            argsDictionary.TryGetValue("paramfile", out paramFileName);
            TestStorageType enmRuntype = TestStorageType.Unknown;

            if (!Enum.TryParse <TestStorageType>(runtype, true, out enmRuntype))
            {
                enmRuntype = TestStorageType.Unknown;
            }

            if (string.IsNullOrEmpty(paramFileName))
            {
                ShowHelp();
                return;
            }
            var apiRunner = new Launcher(failOnTestFailed, paramFileName, enmRuntype);

            apiRunner.Run();
        }
        /// <summary>
        /// analyzes and runs the tests given in the param file.
        /// </summary>
        public void Run()
        {
            _ciRun = true;
            if (_runType == TestStorageType.Unknown)
            {
                Enum.TryParse <TestStorageType>(_ciParams["runType"], true, out _runType);
            }
            if (_runType == TestStorageType.Unknown)
            {
                WriteToConsole(Resources.LauncherNoRuntype);
                return;
            }

            if (!_ciParams.ContainsKey("resultsFilename"))
            {
                WriteToConsole(Resources.LauncherNoResFilenameFound);
                return;
            }
            string resultsFilename = _ciParams["resultsFilename"];

            UniqueTimeStamp = _ciParams.ContainsKey("uniqueTimeStamp") ? _ciParams["uniqueTimeStamp"] : resultsFilename.ToLower().Replace("results", "").Replace(".xml", "");

            //run the entire set of test once
            //create the runner according to type
            IAssetRunner runner = CreateRunner(_runType, _ciParams, true);

            //runner instantiation failed (no tests to run or other problem)
            if (runner == null)
            {
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
            }

            TestSuiteRunResults results = runner.Run();

            RunTests(runner, resultsFilename, results);


            if (_runType.Equals(TestStorageType.FileSystem))
            {
                string onCheckFailedTests = (_ciParams.ContainsKey("onCheckFailedTest") ? _ciParams["onCheckFailedTest"] : "");

                _rerunFailedTests = !string.IsNullOrEmpty(onCheckFailedTests) && Convert.ToBoolean(onCheckFailedTests.ToLower());


                //the "On failure" option is selected and the run build contains failed tests
                if (_rerunFailedTests.Equals(true) && Launcher.ExitCode != ExitCodeEnum.Passed)
                {
                    ConsoleWriter.WriteLine("There are failed tests. Rerun the selected tests.");

                    //rerun the selected tests (either the entire set or just the selected ones)
                    //create the runner according to type
                    runner = CreateRunner(_runType, _ciParams, false);

                    //runner instantiation failed (no tests to run or other problem)
                    if (runner == null)
                    {
                        Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
                    }

                    TestSuiteRunResults rerunResults = runner.Run();
                    results.AppendResults(rerunResults);
                    RunTests(runner, resultsFilename, results);
                }
            }

            ConsoleQuickEdit.Enable();
            if (Launcher.ExitCode != ExitCodeEnum.Passed)
            {
                Environment.Exit((int)Launcher.ExitCode);
            }
        }
Exemplo n.º 5
0
        //[MTAThread]
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.ProcessExit += (s, e) =>
            {
                int code = Environment.ExitCode;
                if (code == 0)
                {
                    Console.Out.WriteLine("The launcher tool exited with code: 0");
                }
                else
                {
                    Console.Error.WriteLine("The launcher tool exited with error code: {0}", code);
                }
            };

            ConsoleQuickEdit.Disable();
            ConsoleWriter.Initialize();
            if (!args.Any() || args.Contains("/?"))
            {
                ShowHelp();
                return;
            }
            // show version?
            if (args[0] == "-v" || args[0] == "-version" || args[0] == "/v")
            {
                Console.WriteLine(Assembly.GetEntryAssembly().GetName().Version.ToString());
                Environment.Exit(0);
                return;
            }

            for (int i = 0; i < args.Length; i += 2)
            {
                string arg = args[i].Trim();
                if (arg.StartsWith("--"))
                {
                    // --<flag> means it is a flag without value
                    string key = arg.Substring(2);
                    argsDictionary[key] = string.Empty;
                    i -= 1;
                }
                else
                {
                    string key = arg.StartsWith("-") ? arg.Substring(1) : arg;
                    string val = i + 1 < args.Length ? args[i + 1].Trim() : string.Empty;
                    argsDictionary[key] = val;
                }
            }

            // verbose output mode?
            if (argsDictionary.ContainsKey("verbose"))
            {
                ConsoleWriter.EnableVerboseOutput = true;
            }

            // redirect output if required
            string redirectOutPipeName;

            if (argsDictionary.TryGetValue("redirect-out-pipe", out redirectOutPipeName))
            {
                // need to redirect stdout to the specified pipe
                var outPipe = new NamedPipeClientStream(".", redirectOutPipeName, PipeDirection.Out);
                outPipe.Connect();
                // create stream write for stdout
                var sw = new StreamWriter(outPipe)
                {
                    AutoFlush = true
                };
                Console.SetOut(sw);

                ConsoleWriter.WriteVerboseLine("The stdout is redirected via the named pipe: " + redirectOutPipeName);
            }

            // redirect error if required
            string redirectErrPipeName;

            if (argsDictionary.TryGetValue("redirect-err-pipe", out redirectErrPipeName))
            {
                // need to redirect stderr to the specified pipe
                var errPipe = new NamedPipeClientStream(".", redirectErrPipeName, PipeDirection.Out);
                errPipe.Connect();
                // create stream write for stderr
                var sw = new StreamWriter(errPipe)
                {
                    AutoFlush = true
                };
                Console.SetError(sw);

                ConsoleWriter.WriteVerboseLine("The stderr is redirected via the named pipe: " + redirectErrPipeName);
            }

            string paramFileName, runtype;
            string failOnTestFailed = "N";

            argsDictionary.TryGetValue("runtype", out runtype);
            argsDictionary.TryGetValue("paramfile", out paramFileName);
            TestStorageType enmRuntype = TestStorageType.Unknown;

            if (!Enum.TryParse <TestStorageType>(runtype, true, out enmRuntype))
            {
                enmRuntype = TestStorageType.Unknown;
            }

            if (string.IsNullOrEmpty(paramFileName))
            {
                ShowHelp();
                return;
            }

            ShowTitle();
            ConsoleWriter.WriteLine(Resources.GeneralStarted);

            try
            {
                if (StartNewLauncherProcess(args))
                {
                    // the new launcher process is launched and everthing shall already be handled in the StartNewLauncherProcess
                    // so here returns, that is, this process shall exit
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Warning: Error occurred when creating the new process in the user session:");
                Console.Error.WriteLine("-------------------------------");
                Console.Error.WriteLine(ex.Message);
                ConsoleWriter.WriteVerboseLine(ex.ToString());
                Console.Error.WriteLine("-------------------------------");
                Console.Error.WriteLine("Warning: Test(s) will be run in non-user session, however, the test(s) might fail.");
            }

            var launcher = new Launcher(failOnTestFailed, paramFileName, enmRuntype);

            if (launcher.IsParamFileEncodingNotSupported)
            {
                Console.WriteLine(Properties.Resources.JavaPropertyFileBOMNotSupported);
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
                return;
            }

            launcher.Run();
        }
Exemplo n.º 6
0
        /// <summary>
        /// analyzes and runs the tests given in the param file.
        /// </summary>
        public void Run()
        {
            _ciRun = true;
            if (_runtype == TestStorageType.Unknown)
            {
                Enum.TryParse <TestStorageType>(_ciParams["runType"], true, out _runtype);
            }
            if (_runtype == TestStorageType.Unknown)
            {
                WriteToConsole(Resources.LauncherNoRuntype);
                return;
            }

            if (!_ciParams.ContainsKey("resultsFilename"))
            {
                WriteToConsole(Resources.LauncherNoResFilenameFound);
                return;
            }
            string resultsFilename = _ciParams["resultsFilename"];

            if (_ciParams.ContainsKey("uniqueTimeStamp"))
            {
                UniqueTimeStamp = _ciParams["uniqueTimeStamp"];
            }
            else
            {
                UniqueTimeStamp = resultsFilename.ToLower().Replace("results", "").Replace(".xml", "");
            }

            bool initialTestRun = true;

            //run the entire set of test once
            //create the runner according to type
            IAssetRunner runner = CreateRunner(_runtype, _ciParams, initialTestRun);

            //runner instantiation failed (no tests to run or other problem)
            if (runner == null)
            {
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
            }

            RunTests(runner, resultsFilename);


            if (_runtype.Equals(TestStorageType.Alm))
            {
                bool   filterSelected;
                string filter = (_ciParams.ContainsKey("FilterTests") ? _ciParams["FilterTests"] : "");

                if (string.IsNullOrEmpty(filter))
                {
                    filterSelected = false;
                }
                else
                {
                    filterSelected = Convert.ToBoolean(filter.ToLower());
                }

                if (filterSelected.Equals(true) && Launcher.ExitCode != ExitCodeEnum.Passed)
                {
                    //rerun selected tests
                    initialTestRun = false;

                    runner = CreateRunner(_runtype, _ciParams, initialTestRun);

                    //runner instantiation failed (no tests to run or other problem)
                    if (runner == null)
                    {
                        Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
                    }

                    RunTests(runner, resultsFilename);
                }
            }

            if (_runtype.Equals(TestStorageType.FileSystem))
            {
                string onCheckFailedTests = (_ciParams.ContainsKey("onCheckFailedTest") ? _ciParams["onCheckFailedTest"] : "");

                if (string.IsNullOrEmpty(onCheckFailedTests))
                {
                    rerunFailedTests = false;
                }
                else
                {
                    rerunFailedTests = Convert.ToBoolean(onCheckFailedTests.ToLower());
                }


                //the "On failure" option is selected and the run build contains failed tests
                if (rerunFailedTests.Equals(true) && Launcher.ExitCode != ExitCodeEnum.Passed)
                {
                    ConsoleWriter.WriteLine("There are failed tests. Rerun the selected tests.");

                    initialTestRun = false;

                    //rerun the selected tests (either the entire set or just the selected ones)
                    //create the runner according to type
                    runner = CreateRunner(_runtype, _ciParams, initialTestRun);

                    //runner instantiation failed (no tests to run or other problem)
                    if (runner == null)
                    {
                        Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
                    }

                    RunTests(runner, resultsFilename);
                }
            }

            //Console.WriteLine("Press any key to exit...");
            //Console.ReadKey();
            ConsoleQuickEdit.Enable();
            if (Launcher.ExitCode != ExitCodeEnum.Passed)
            {
                Environment.Exit((int)Launcher.ExitCode);
            }
        }