Inheritance: ContextFactory
示例#1
0
		/// <exception cref="System.Exception"></exception>
		internal virtual void Run(JsDriver.Arguments arguments)
		{
			if (arguments.Help())
			{
				System.Console.Out.WriteLine("See mozilla/js/tests/README-jsDriver.html; note that some options are not supported.");
				System.Console.Out.WriteLine("Consult the Java source code at testsrc/org/mozilla/javascript/JsDriver.java for details.");
				System.Environment.Exit(0);
			}
			ShellContextFactory factory = new ShellContextFactory();
			factory.SetOptimizationLevel(arguments.GetOptimizationLevel());
			factory.SetStrictMode(arguments.IsStrict());
			FilePath path = arguments.GetTestsPath();
			if (path == null)
			{
				path = new FilePath("../tests");
			}
			if (!path.Exists())
			{
				throw new Exception("JavaScript tests not found at " + path.GetCanonicalPath());
			}
			JsDriver.Tests tests = new JsDriver.Tests(path, arguments.GetTestList(), arguments.GetSkipList());
			JsDriver.Tests.Script[] all = tests.GetFiles();
			arguments.GetConsole().Println("Running " + all.Length + " tests.");
			JsDriver.Results results = new JsDriver.Results(factory, arguments, arguments.Trace());
			results.Start();
			for (int i = 0; i < all.Length; i++)
			{
				results.Run(all[i], new JsDriver.ShellTestParameters(arguments.GetTimeout()));
			}
			results.Finish();
		}
示例#2
0
			internal Results(ShellContextFactory factory, JsDriver.Arguments arguments, bool trace)
			{
				this.factory = factory;
				this.arguments = arguments;
				FilePath output = arguments.GetOutputFile();
				if (output == null)
				{
					output = new FilePath("rhino-test-results." + new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").Format(new DateTime()) + ".html");
				}
				this.output = output;
				this.trace = trace;
			}
示例#3
0
		public virtual void RunMozillaTest()
		{
			//System.out.println("Test \"" + jsFile + "\" running under optimization level " + optimizationLevel);
			ShellContextFactory shellContextFactory = new ShellContextFactory();
			shellContextFactory.SetOptimizationLevel(optimizationLevel);
			MozillaSuiteTest.ShellTestParameters @params = new MozillaSuiteTest.ShellTestParameters();
			MozillaSuiteTest.JunitStatus status = new MozillaSuiteTest.JunitStatus();
			ShellTest.Run(shellContextFactory, jsFile, @params, status);
		}
示例#4
0
			public _Runnable_274(ShellContextFactory shellContextFactory, Exception[] thrown, ShellTest.TestState testState, ShellTest.Status status, FilePath jsFile, Global global)
			{
				this.shellContextFactory = shellContextFactory;
				this.thrown = thrown;
				this.testState = testState;
				this.status = status;
				this.jsFile = jsFile;
				this.global = global;
			}
示例#5
0
		/// <exception cref="System.Exception"></exception>
		public static void Run(ShellContextFactory shellContextFactory, FilePath jsFile, ShellTest.Parameters parameters, ShellTest.Status status)
		{
			Global global = new Global();
			MemoryStream @out = new MemoryStream();
			TextWriter p = new TextWriter(@out);
			global.SetOut(p);
			global.SetErr(p);
			global.DefineFunctionProperties(new string[] { "options" }, typeof(ShellTest), ScriptableObject.DONTENUM | ScriptableObject.PERMANENT | ScriptableObject.READONLY);
			// test suite expects keywords to be disallowed as identifiers
			shellContextFactory.SetAllowReservedKeywords(false);
			ShellTest.TestState testState = new ShellTest.TestState();
			if (jsFile.GetName().EndsWith("-n.js"))
			{
				status.SetNegative();
			}
			Exception[] thrown = new Exception[] { null };
			Sharpen.Thread t = new Sharpen.Thread(new _Runnable_274(shellContextFactory, thrown, testState, status, jsFile, global), jsFile.GetPath());
			t.SetDaemon(true);
			t.Start();
			t.Join(parameters.GetTimeoutMilliseconds());
			lock (testState)
			{
				if (!testState.finished)
				{
					CallStop(t);
					status.TimedOut();
				}
			}
			int expectedExitCode = 0;
			p.Flush();
			status.OutputWas(Sharpen.Runtime.GetStringForBytes(@out.ToArray()));
			BufferedReader r = new BufferedReader(new StreamReader(new MemoryStream(@out.ToArray())));
			string failures = string.Empty;
			for (; ; )
			{
				string s = r.ReadLine();
				if (s == null)
				{
					break;
				}
				if (s.IndexOf("FAILED!") != -1)
				{
					failures += s + '\n';
				}
				int expex = s.IndexOf("EXPECT EXIT CODE ");
				if (expex != -1)
				{
					expectedExitCode = s[expex + "EXPECT EXIT CODE ".Length] - '0';
				}
			}
			if (thrown[0] != null)
			{
				status.Threw(thrown[0]);
			}
			status.ExitCodesWere(expectedExitCode, testState.exitCode);
			if (failures != string.Empty)
			{
				status.Failed(failures);
			}
		}
示例#6
0
			/// <exception cref="System.Exception"></exception>
			public override void RunBare()
			{
				ShellContextFactory shellContextFactory = new ShellContextFactory();
				shellContextFactory.SetOptimizationLevel(optimizationLevel);
				StandardTests.JsTestCase.ShellTestParameters @params = new StandardTests.JsTestCase.ShellTestParameters();
				ShellTest.Run(shellContextFactory, jsFile, @params, new StandardTests.JunitStatus());
			}