From 89bda83e0570ab87c6e449f5955613d5385e90b3 Mon Sep 17 00:00:00 2001 From: "alexanders@b2ef00c0-3703-41da-baef-cfe82387ac0c" Date: Wed, 3 Feb 2010 00:50:41 +0000 Subject: removed obsolete svn folder from hg tree --HG-- extra : convert_revision : svn%3Ab2ef00c0-3703-41da-baef-cfe82387ac0c/trunk%408 --- .../org/mozilla/javascript/drivers/ShellTest.java | 346 +++++++++++++++++++++ 1 file changed, 346 insertions(+) create mode 100644 infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/ShellTest.java (limited to 'infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/ShellTest.java') diff --git a/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/ShellTest.java b/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/ShellTest.java new file mode 100644 index 0000000..9acf64e --- /dev/null +++ b/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/ShellTest.java @@ -0,0 +1,346 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Java port of jsDriver.pl. + * + * The Initial Developer of the Original Code is + * David P. Caldwell. + * Portions created by David P. Caldwell are Copyright (C) + * 2007 David P. Caldwell. All Rights Reserved. + * + * + * Contributor(s): + * David P. Caldwell + * + * Alternatively, the contents of this file may be used under the terms of + * the GNU General Public License Version 2 or later (the "GPL"), in which + * case the provisions of the GPL are applicable instead of those above. If + * you wish to allow use of your version of this file only under the terms of + * the GPL and not to allow others to use your version of this file under the + * MPL, indicate your decision by deleting the provisions above and replacing + * them with the notice and other provisions required by the GPL. If you do + * not delete the provisions above, a recipient may use your version of this + * file under either the MPL or the GPL. + * + * ***** END LICENSE BLOCK ***** */ + +package org.mozilla.javascript.drivers; + +import org.mozilla.javascript.*; +import java.io.*; +import java.util.*; + +import org.mozilla.javascript.tools.shell.*; + +/** + * @version $Id: ShellTest.java,v 1.5 2007/10/11 19:44:10 szegedia%freemail.hu Exp $ + */ +class ShellTest { + static final FileFilter DIRECTORY_FILTER = new FileFilter() { + public boolean accept(File pathname) + { + return pathname.isDirectory() && !pathname.getName().equals("CVS"); + } + }; + + static final FileFilter TEST_FILTER = new FileFilter() { + public boolean accept(File pathname) + { + return pathname.getName().endsWith(".js") && !pathname.getName().equals("shell.js") && !pathname.getName().equals("browser.js") && !pathname.getName().equals("template.js"); + } + }; + + static String getStackTrace(Throwable t) { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + t.printStackTrace(new PrintStream(bytes)); + return new String(bytes.toByteArray()); + } + + private static void runFileIfExists(Context cx, Scriptable global, File f) + { + if(f.isFile()) + { + Main.processFile(cx, global, f.getPath()); + } + } + + private static class TestState + { + boolean finished; + ErrorReporterWrapper errors; + int exitCode = 0; + } + + static abstract class Status { + private boolean negative; + + final void setNegative() { + this.negative = true; + } + + final boolean isNegative() { + return this.negative; + } + + final void hadErrors(JsError[] errors) { + if (!negative && errors.length > 0) { + failed("JavaScript errors:\n" + JsError.toString(errors)); + } else if (negative && errors.length == 0) { + failed("Should have produced runtime error."); + } + } + + abstract void running(File jsFile); + + abstract void failed(String s); + abstract void threw(Throwable t); + abstract void timedOut(); + abstract void exitCodesWere(int expected, int actual); + abstract void outputWas(String s); + + static Status compose(final Status[] array) { + return new Status() { + void running(File file) { + for (int i=0; i