Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(870)

Unified Diff: lib/src/run_single.dart

Issue 2078453002: Speed up testing. (Closed) Base URL: git@github.com:dart-lang/rasta.git@visit_for_effect
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/run_batch.dart ('k') | test/kernel/kernel_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/run_single.dart
diff --git a/lib/src/run_single.dart b/lib/src/run_single.dart
index 34979960d465bf49044377e538b99b62bb7e31e7..ba7a60d69e746fa99f7dd0225be122b431916e92 100644
--- a/lib/src/run_single.dart
+++ b/lib/src/run_single.dart
@@ -7,100 +7,23 @@ library rasta.run_single;
import 'dart:async' show
Future;
-import 'dart:io' show
- IOSink;
-
-import 'package:compiler/src/elements/elements.dart' show
- CompilationUnitElement,
- LibraryElement;
-
import 'package:kernel/ast.dart' as ir;
-import 'package:kernel/binary/ast_to_binary.dart' show
- BinaryPrinter;
-
-import 'package:kernel/text/ast_to_text.dart' show
- Printer;
-
-import 'package:rasta/custom_compiler.dart' show
+import '../custom_compiler.dart' show
CustomCompiler;
-import 'package:rasta/kernel.dart' show
- Kernel;
-
import 'options.dart' show
Options;
import 'rastask.dart' show
- Rastask,
- openWrite;
+ Rastask;
class RunSingle extends Rastask {
RunSingle(CustomCompiler compiler, Stopwatch wallClock, Options options)
: super(compiler, wallClock, options);
Future<ir.TreeNode> run() async {
- Duration setupDuration = wallClock.elapsed;
-
- await compiler.setupSdk();
-
- await compiler.setupPackages(options.input);
-
- Kernel kernel = new Kernel(compiler);
- ir.Library library = await kernel.loadLibrary(options.input);
-
- bool generateLibrary = options.generateLibrary;
- if (generateLibrary == null) {
- generateLibrary = !kernel.hasMainMethod(options.input);
- }
- if (generateLibrary) {
- kernel.processWorkQueue(targetLibrary: options.input);
- } else {
- if (!kernel.hasMainMethod(options.input)) {
- throw "No main method in ${options.input}.";
- }
- kernel.processWorkQueue();
- }
-
- ir.Program program;
- if (!generateLibrary) {
- Iterable<ir.Procedure> mainMethods = library.procedures.where(
- (ir.Procedure function) => function.name.name == "main");
- program =
- new ir.Program(new List<ir.Library>.from(kernel.libraries.values))
- ..mainMethod = mainMethods.single;
- }
- compiler.printVerboseTimings(setupDuration);
- if (options.output != null) {
- await openWrite(options.output, (IOSink sink) {
- BinaryPrinter printer = new BinaryPrinter(sink);
- if (generateLibrary) {
- printer.writeLibraryFile(library);
- } else {
- printer.writeProgramFile(program);
- }
- });
- } else {
- StringBuffer buffer = new StringBuffer();
- Printer printer = new Printer(buffer);
- if (generateLibrary) {
- printer.writeLibraryFile(library);
- } else {
- printer.writeProgramFile(program);
- }
- print("$buffer");
- }
-
- if (options.dependenciesFile != null) {
- await openWrite(options.dependenciesFile, (IOSink sink) {
- void writeCompilationUnit(CompilationUnitElement unit) {
- sink.write("${unit.script.resourceUri}\n");
- }
- kernel.forEachLibraryElement((LibraryElement library) {
- library.compilationUnits.forEach(writeCompilationUnit);
- });
- });
- }
- return generateLibrary ? library : program;
+ await setup(globalOptions.input);
+ return runOne(globalOptions);
kasperl 2016/06/16 11:14:49 Very nice.
}
}
« no previous file with comments | « lib/src/run_batch.dart ('k') | test/kernel/kernel_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698