mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 20:11:19 +00:00
remove TestRunner and revector callers to DartRunner
It only had a few methods in it that all ended up delegating to DartRunner. Review URL: http://codereview.chromium.org//8223005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@306 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
95ab992168
commit
0294b62be1
|
@ -42,7 +42,7 @@ public class CommandLineOptions {
|
||||||
usage = "Treat some type checks as warnings\n instead of fatal errors")
|
usage = "Treat some type checks as warnings\n instead of fatal errors")
|
||||||
private boolean shouldWarnOnNoSuchType = false;
|
private boolean shouldWarnOnNoSuchType = false;
|
||||||
|
|
||||||
@Option(name = "--enable_type_checks",
|
@Option(name = "--enable_type_checks",
|
||||||
usage = "Generate runtime type checks")
|
usage = "Generate runtime type checks")
|
||||||
private boolean developerModeChecks = false;
|
private boolean developerModeChecks = false;
|
||||||
|
|
||||||
|
@ -349,13 +349,6 @@ public class CommandLineOptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Command line options accepted by the {@link com.google.dart.runner.TestRunner} entry point.
|
|
||||||
*/
|
|
||||||
public static class TestRunnerOptions extends DartRunnerOptions {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses command line options, handling the feature to ignore unrecognized
|
* Parses command line options, handling the feature to ignore unrecognized
|
||||||
* flags.
|
* flags.
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package com.google.dart.runner;
|
package com.google.dart.runner;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.io.CharStreams;
|
import com.google.common.io.CharStreams;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.google.dart.compiler.Backend;
|
import com.google.dart.compiler.Backend;
|
||||||
|
@ -21,6 +22,8 @@ import com.google.dart.compiler.DefaultDartCompilerListener;
|
||||||
import com.google.dart.compiler.DefaultErrorFormatter;
|
import com.google.dart.compiler.DefaultErrorFormatter;
|
||||||
import com.google.dart.compiler.LibrarySource;
|
import com.google.dart.compiler.LibrarySource;
|
||||||
import com.google.dart.compiler.Source;
|
import com.google.dart.compiler.Source;
|
||||||
|
import com.google.dart.compiler.UnitTestBatchRunner;
|
||||||
|
import com.google.dart.compiler.UnitTestBatchRunner.Invocation;
|
||||||
import com.google.dart.compiler.UrlLibrarySource;
|
import com.google.dart.compiler.UrlLibrarySource;
|
||||||
import com.google.dart.compiler.backend.js.ClosureJsBackend;
|
import com.google.dart.compiler.backend.js.ClosureJsBackend;
|
||||||
import com.google.dart.compiler.backend.js.JavascriptBackend;
|
import com.google.dart.compiler.backend.js.JavascriptBackend;
|
||||||
|
@ -72,10 +75,34 @@ public class DartRunner {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
|
boolean runBatch = false;
|
||||||
|
final List<LibrarySource> imports = Collections.emptyList();
|
||||||
DartRunnerOptions options = processCommandLineOptions(args);
|
DartRunnerOptions options = processCommandLineOptions(args);
|
||||||
throwingMain(options, args, Collections.<LibrarySource>emptyList(), System.out, System.err);
|
if (options.shouldBatch()) {
|
||||||
} catch (RunnerError error) {
|
runBatch = true;
|
||||||
System.err.println(error.getLocalizedMessage());
|
if (args.length > 1) {
|
||||||
|
System.err
|
||||||
|
.println("(Extra arguments specified with -batch ignored.)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (runBatch) {
|
||||||
|
UnitTestBatchRunner.runAsBatch(args, new Invocation() {
|
||||||
|
@Override
|
||||||
|
public boolean invoke(String[] args) throws Throwable {
|
||||||
|
try {
|
||||||
|
throwingMain(args, System.out, System.err);
|
||||||
|
} catch (RunnerError e) {
|
||||||
|
System.out.println(e.getLocalizedMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throwingMain(args, System.out, System.err);
|
||||||
|
}
|
||||||
|
} catch (RunnerError e) {
|
||||||
|
System.err.println(e.getLocalizedMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -83,13 +110,12 @@ public class DartRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void throwingMain(DartRunnerOptions options,
|
public static void throwingMain(String[] args,
|
||||||
String[] args,
|
|
||||||
List<LibrarySource> imports,
|
|
||||||
PrintStream stdout,
|
PrintStream stdout,
|
||||||
final PrintStream stderr)
|
final PrintStream stderr)
|
||||||
throws RunnerError {
|
throws RunnerError {
|
||||||
|
DartRunnerOptions options = processCommandLineOptions(args);
|
||||||
|
List<LibrarySource> imports = Lists.newArrayList();
|
||||||
if (options.getSourceFiles().isEmpty()) {
|
if (options.getSourceFiles().isEmpty()) {
|
||||||
throw new RunnerError("No script files specified on the command line: " + Joiner.on(" ").join(args));
|
throw new RunnerError("No script files specified on the command line: " + Joiner.on(" ").join(args));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
|
||||||
// BSD-style license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package com.google.dart.runner;
|
|
||||||
|
|
||||||
import com.google.dart.compiler.CommandLineOptions;
|
|
||||||
import com.google.dart.compiler.CommandLineOptions.TestRunnerOptions;
|
|
||||||
import com.google.dart.compiler.DartCompiler;
|
|
||||||
import com.google.dart.compiler.LibrarySource;
|
|
||||||
import com.google.dart.compiler.UnitTestBatchRunner;
|
|
||||||
import com.google.dart.compiler.UnitTestBatchRunner.Invocation;
|
|
||||||
|
|
||||||
import org.kohsuke.args4j.CmdLineException;
|
|
||||||
import org.kohsuke.args4j.CmdLineParser;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs dart programs.<br/>
|
|
||||||
* The command-line interface is similar to the VM's command line interface.
|
|
||||||
* </br>
|
|
||||||
*/
|
|
||||||
public class TestRunner {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
boolean runBatch = false;
|
|
||||||
TestRunnerOptions options = processCommandLineOptions(args);
|
|
||||||
if (options.shouldBatch()) {
|
|
||||||
runBatch = true;
|
|
||||||
if (args.length > 1) {
|
|
||||||
System.err.println("(Extra arguments specified with -batch ignored.)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (runBatch) {
|
|
||||||
UnitTestBatchRunner.runAsBatch(args, new Invocation() {
|
|
||||||
@Override
|
|
||||||
public boolean invoke(String[] args) throws Throwable {
|
|
||||||
try {
|
|
||||||
throwingMain(args, System.out, System.err);
|
|
||||||
} catch (RunnerError e) {
|
|
||||||
System.out.println(e.getLocalizedMessage());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throwingMain(args, System.out, System.err);
|
|
||||||
}
|
|
||||||
} catch (RunnerError e) {
|
|
||||||
System.err.println(e.getLocalizedMessage());
|
|
||||||
System.exit(1);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
DartCompiler.crash();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void printUsageAndThrow(CmdLineParser cmdLineParser, String reason) throws RunnerError {
|
|
||||||
StringBuilder usage = new StringBuilder();
|
|
||||||
usage.append(reason);
|
|
||||||
usage.append("\n");
|
|
||||||
usage.append("Usage: ");
|
|
||||||
usage.append(System.getProperty("com.google.dart.runner.progname",
|
|
||||||
TestRunner.class.getSimpleName()));
|
|
||||||
usage.append(" [<options>] <dart-script-file> [<script-arguments>]\n");
|
|
||||||
usage.append("\n");
|
|
||||||
|
|
||||||
OutputStream s = new ByteArrayOutputStream();
|
|
||||||
if (cmdLineParser == null) {
|
|
||||||
cmdLineParser = new CmdLineParser(new TestRunnerOptions());
|
|
||||||
}
|
|
||||||
cmdLineParser.printUsage(s);
|
|
||||||
usage.append(s);
|
|
||||||
throw new RunnerError(usage.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static TestRunnerOptions processCommandLineOptions(String[] args) throws RunnerError {
|
|
||||||
CmdLineParser cmdLineParser = null;
|
|
||||||
TestRunnerOptions parsedOptions = null;
|
|
||||||
try {
|
|
||||||
parsedOptions = new TestRunnerOptions();
|
|
||||||
cmdLineParser = CommandLineOptions.parse(args, parsedOptions);
|
|
||||||
if (args.length == 0 || parsedOptions.showHelp()) {
|
|
||||||
printUsageAndThrow(cmdLineParser, "");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
} catch (CmdLineException e) {
|
|
||||||
printUsageAndThrow(cmdLineParser, e.getLocalizedMessage());
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert parsedOptions != null;
|
|
||||||
return parsedOptions;
|
|
||||||
}
|
|
||||||
public static void throwingMain(String[] args, PrintStream stdout, PrintStream stderr)
|
|
||||||
throws RunnerError {
|
|
||||||
TestRunnerOptions options = processCommandLineOptions(args);
|
|
||||||
List<LibrarySource> imports = new ArrayList<LibrarySource>();
|
|
||||||
DartRunner.throwingMain(options, args, imports, stdout, stderr);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -89,13 +89,8 @@ public abstract class End2EndTestCase extends CompilerTestCase {
|
||||||
DartRunnerOptions verboseOptions = new CommandLineOptions.DartRunnerOptions();
|
DartRunnerOptions verboseOptions = new CommandLineOptions.DartRunnerOptions();
|
||||||
verboseOptions.setVerbose(true);
|
verboseOptions.setVerbose(true);
|
||||||
try {
|
try {
|
||||||
DartRunner.compileAndRunApp(app,
|
DartRunner.compileAndRunApp(app, verboseOptions, config, listener, args,
|
||||||
verboseOptions,
|
System.out, System.err);
|
||||||
config,
|
|
||||||
listener,
|
|
||||||
args,
|
|
||||||
System.out,
|
|
||||||
System.err);
|
|
||||||
} catch (RhinoException e) {
|
} catch (RhinoException e) {
|
||||||
// TODO(jgw): This is a hack to dump the translated source when something goes wrong. It can
|
// TODO(jgw): This is a hack to dump the translated source when something goes wrong. It can
|
||||||
// be removed as soon as we have a source map we can use to provide source-level errors.
|
// be removed as soon as we have a source map we can use to provide source-level errors.
|
||||||
|
|
|
@ -73,8 +73,8 @@ public class NonStrictResolutionTest extends End2EndTestCase {
|
||||||
StringStream outStream = new StringStream(System.out);
|
StringStream outStream = new StringStream(System.out);
|
||||||
StringStream errStream = new StringStream(System.err);
|
StringStream errStream = new StringStream(System.err);
|
||||||
try {
|
try {
|
||||||
DartRunner
|
DartRunner.compileAndRunApp(app, verboseOptions, config, listener, args,
|
||||||
.compileAndRunApp(app, verboseOptions, config, listener, args, outStream, errStream);
|
outStream, errStream);
|
||||||
} catch (RhinoException e) {
|
} catch (RhinoException e) {
|
||||||
super.fail(e.getLocalizedMessage());
|
super.fail(e.getLocalizedMessage());
|
||||||
} catch (RunnerError e) {
|
} catch (RunnerError e) {
|
||||||
|
|
|
@ -16,8 +16,8 @@ import com.google.dart.compiler.DefaultLibrarySource;
|
||||||
import com.google.dart.compiler.LibrarySource;
|
import com.google.dart.compiler.LibrarySource;
|
||||||
import com.google.dart.compiler.Source;
|
import com.google.dart.compiler.Source;
|
||||||
import com.google.dart.compiler.UrlLibrarySource;
|
import com.google.dart.compiler.UrlLibrarySource;
|
||||||
|
import com.google.dart.runner.DartRunner;
|
||||||
import com.google.dart.runner.RunnerError;
|
import com.google.dart.runner.RunnerError;
|
||||||
import com.google.dart.runner.TestRunner;
|
|
||||||
import com.google.dart.runner.V8Launcher;
|
import com.google.dart.runner.V8Launcher;
|
||||||
|
|
||||||
import junit.framework.AssertionFailedError;
|
import junit.framework.AssertionFailedError;
|
||||||
|
@ -138,7 +138,7 @@ public class SharedTestCase extends TestCase {
|
||||||
if (regularCompile) {
|
if (regularCompile) {
|
||||||
invokeCompiler();
|
invokeCompiler();
|
||||||
} else {
|
} else {
|
||||||
TestRunner.throwingMain(arguments, outputStream, outputStream);
|
DartRunner.throwingMain(arguments, outputStream, outputStream);
|
||||||
}
|
}
|
||||||
} catch (RunnerError e) {
|
} catch (RunnerError e) {
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class AllTests {
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite("Dartc test runner tests");
|
TestSuite suite = new TestSuite("Dartc test runner tests");
|
||||||
|
|
||||||
suite.addTestSuite(TestRunnerTest.class);
|
suite.addTestSuite(DartRunnerTest.class);
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,11 @@ import junit.framework.TestCase;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
public class TestRunnerTest extends TestCase {
|
public class DartRunnerTest extends TestCase {
|
||||||
public void testMain() throws Throwable {
|
public void testMain() throws Throwable {
|
||||||
try {
|
try {
|
||||||
PrintStream stream = new PrintStream(new ByteArrayOutputStream());
|
PrintStream stream = new PrintStream(new ByteArrayOutputStream());
|
||||||
TestRunner.throwingMain("NoSuchFile.dart".split(" "), stream, stream);
|
DartRunner.throwingMain("NoSuchFile.dart".split(" "), stream, stream);
|
||||||
fail("Expected a compilation failure.");
|
fail("Expected a compilation failure.");
|
||||||
} catch (RunnerError e) {
|
} catch (RunnerError e) {
|
||||||
// Expected this exception.
|
// Expected this exception.
|
|
@ -55,7 +55,7 @@ exec $JAVABIN -ea -classpath @CLASSPATH@ \
|
||||||
${JVM_DEBUG_FLAGS} \
|
${JVM_DEBUG_FLAGS} \
|
||||||
${JVM_FLAGS} \
|
${JVM_FLAGS} \
|
||||||
${JVM_FLAGS_CMDLINE} \
|
${JVM_FLAGS_CMDLINE} \
|
||||||
com.google.dart.runner.TestRunner \
|
com.google.dart.runner.DartRunner \
|
||||||
$DARTC_FLAGS \
|
$DARTC_FLAGS \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
|
|
@ -28,4 +28,4 @@ fi
|
||||||
exec java -ea -Dcom.google.dart.runner.d8="$D8_EXEC" \
|
exec java -ea -Dcom.google.dart.runner.d8="$D8_EXEC" \
|
||||||
-Dcom.google.dart.runner.progname="$DART_SCRIPT_NAME" \
|
-Dcom.google.dart.runner.progname="$DART_SCRIPT_NAME" \
|
||||||
-classpath "@CLASSPATH@" \
|
-classpath "@CLASSPATH@" \
|
||||||
com.google.dart.runner.TestRunner $@
|
com.google.dart.runner.DartRunner $@
|
||||||
|
|
Loading…
Reference in a new issue