| Index: tests/compiler/dart2js/memory_compiler.dart
|
| diff --git a/tests/compiler/dart2js/memory_compiler.dart b/tests/compiler/dart2js/memory_compiler.dart
|
| index b4091f3fe5ea7688646c4f1eb4300a7a691379e1..392f51b6bf3a36251bc7e48f634c42bc6fd82ef4 100644
|
| --- a/tests/compiler/dart2js/memory_compiler.dart
|
| +++ b/tests/compiler/dart2js/memory_compiler.dart
|
| @@ -10,7 +10,7 @@ import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
|
| show NullSink;
|
|
|
| import '../../../sdk/lib/_internal/compiler/compiler.dart'
|
| - show Diagnostic, DiagnosticHandler;
|
| + show Diagnostic, DiagnosticHandler, CompilerOutputProvider;
|
|
|
| import 'dart:async';
|
|
|
| @@ -59,6 +59,41 @@ class DiagnosticCollector {
|
| }
|
| }
|
|
|
| +class BufferedEventSink implements EventSink<String> {
|
| + StringBuffer sb = new StringBuffer();
|
| + String text;
|
| +
|
| + void add(String event) {
|
| + sb.write(event);
|
| + }
|
| +
|
| + void addError(errorEvent, [StackTrace stackTrace]) {
|
| + // Do not support this.
|
| + }
|
| +
|
| + void close() {
|
| + text = sb.toString();
|
| + sb = null;
|
| + }
|
| +}
|
| +
|
| +class OutputCollector {
|
| + Map<String, Map<String, BufferedEventSink>> outputMap = {};
|
| +
|
| + EventSink<String> call(String name, String extension) {
|
| + Map<String, BufferedEventSink> sinkMap =
|
| + outputMap.putIfAbsent(extension, () => {});
|
| + return sinkMap.putIfAbsent(name, () => new BufferedEventSink());
|
| + }
|
| +
|
| + String getOutput(String name, String extension) {
|
| + Map<String, BufferedEventSink> sinkMap = outputMap[extension];
|
| + if (sinkMap == null) return null;
|
| + BufferedEventSink sink = sinkMap[name];
|
| + return sink != null ? sink.text : null;
|
| + }
|
| +}
|
| +
|
| DiagnosticHandler createDiagnosticHandler(DiagnosticHandler diagnosticHandler,
|
| SourceFileProvider provider,
|
| bool showDiagnostics) {
|
| @@ -84,6 +119,7 @@ Expando<MemorySourceFileProvider> expando =
|
|
|
| Compiler compilerFor(Map<String,String> memorySourceFiles,
|
| {DiagnosticHandler diagnosticHandler,
|
| + CompilerOutputProvider outputProvider,
|
| List<String> options: const [],
|
| Compiler cachedCompiler,
|
| bool showDiagnostics: true,
|
| @@ -112,10 +148,13 @@ Compiler compilerFor(Map<String,String> memorySourceFiles,
|
| var handler =
|
| createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics);
|
|
|
| - EventSink<String> outputProvider(String name, String extension) {
|
| + EventSink<String> noOutputProvider(String name, String extension) {
|
| if (name != '') throw 'Attempt to output file "$name.$extension"';
|
| return new NullSink('$name.$extension');
|
| }
|
| + if (outputProvider == null) {
|
| + outputProvider = noOutputProvider;
|
| + }
|
|
|
| Compiler compiler = new Compiler(readStringFromUri,
|
| outputProvider,
|
|
|