internal RunScriptLoader(TokenList tokens, string script) : base(tokens) { info = new InfoOrganizer(tokens, script); string skip = tokens.GetValue("goto"); skipToVariation = (skip == null) ? -1 : StringConverter.ToInt(skip); if (skipToVariation == 0 || skipToVariation > Variation.TotalVariations) { throw new ArgumentOutOfRangeException("goto", "The specified parameter must be in the range 1-" + Variation.TotalVariations); } }
internal static void SetGlobalParameters(TokenList tokens) { globalParameters = tokens; string fresh = tokens.GetValue("NewWindowPerVariation"); newWindowPerVariation = (fresh == null) ? false : StringConverter.ToBool(fresh); if (newWindowPerVariation) { // Global variation will not be used. Do not create it. totalVariations = 0; globalVariation = null; } else { // Create a special variation "0" with all the global values. totalVariations = -1; globalVariation = new Variation(tokens, true); } }
/// <summary> /// Set the TestAssembly, launch tests in the test assembly based on args, and /// revert the TestAssembly value to original value. /// </summary> /// <param name="args"></param> /// <param name="testAssembly"></param> public static void Launch(string[] args, Assembly testAssembly) { //Set TestAssembly. Assembly originalTestAssembly = TestAssembly; TestAssembly = testAssembly; TokenList tokens = new TokenList(args); foreach (Object o in tokens) { LogHeader(o.ToString()); } string runAll = tokens.GetValue("RunAll"); string runAllScripts = tokens.GetValue("RunAllScripts"); string dontCatch = tokens.GetValue("DontCatch"); string logTime = tokens.GetValue("LogTime"); string script = tokens.GetValue("script"); string className = tokens.GetValue("Class"); if (tokens.ContainsKey("?") || tokens.ContainsKey("help") || tokens.ContainsKey("Help")) { PrintHelp(); return; } //Catch Exceptions on dispatcher, and rethrow on main thread if (dontCatch == null) { RenderingTest.catchExceptionsOnDispatcherThread = true; } else { RenderingTest.catchExceptionsOnDispatcherThread = !StringConverter.ToBool(dontCatch); } if (logTime != null) { LogTime = StringConverter.ToBool(logTime); } GraphicsTestLoader tester = null; if (runAll != null && StringConverter.ToBool(runAll)) { tester = new RunAllLoader(tokens); } else if (runAllScripts != null && StringConverter.ToBool(runAllScripts)) { tester = new RunAllLoader(tokens, false); } else if (script == null && className == null) { PrintHelp(); return; } else { tester = new RunScriptLoader(tokens, script); } //Intercept and log any uncaught exceptions try { tester.RunMyTests(); } catch (Exception e) { TestLog.Current.Result = TestResult.Fail; TestLog.Current.LogStatus("Test Failure - Unhandled Exception Caught"); TestLog.Current.LogEvidence(e.ToString()); Logger.LogFinalResults(1, 1); } if (RenderingTest.application != null) { RenderingTest.application.Dispatcher.BeginInvoke( DispatcherPriority.Normal, new DispatcherOperationCallback(Shutdown), null ); } //revert TestAssembly. TestAssembly = originalTestAssembly; }