anchor.diff:        expect(await portLineCompleter.future, equals('foo'));
         print("Compiler terminated with ${await vm.exitCode} exit code");
       });
  +
  +    test('collect coverage', () async {
  +      collectStuff(int port) async {
  +        RemoteVm remoteVm = new RemoteVm(port);
  +
  +        // Wait for the script to have finished.
  +        while (true) {
  +          Map isolate = await remoteVm.getIsolate();
  +          Map pauseEvent = isolate["pauseEvent"];
  +          if (pauseEvent["kind"] == "PauseExit") break;
  +        }
  +
  +        // Collect coverage for the two user scripts.
  +        Map sourceReport = await remoteVm.getSourceReport();
  +        List scripts = sourceReport["scripts"];
  +        Map<String, int> scriptIdToIndex = new Map<String, int>();
  +        int i = 0;
  +        for (Map script in scripts) {
  +          if (script["uri"].toString().endsWith("main.dart") ||
  +              script["uri"].toString().endsWith("lib.dart")) {
  +            scriptIdToIndex[script["id"]] = i;
  +          }
  +          i++;
  +        }
  +        expect(scriptIdToIndex.length >= 2, isTrue);
  +
  +        List<String> errorMessages = new List<String>();
  +
  +        // Ensure the scripts all have a non-null 'tokenPosTable' entry.
  +        Map<int, Map> scriptIndexToScript = new Map<int, Map>();
  +        for (String scriptId in scriptIdToIndex.keys) {
  +          Map script = await remoteVm.getObject(scriptId);
  +          int scriptIdx = scriptIdToIndex[scriptId];
  +          scriptIndexToScript[scriptIdx] = script;
  +          List tokenPosTable = script["tokenPosTable"];
  +          if (tokenPosTable == null) {
  +            errorMessages.add("Script with uri ${script['uri']} "
  +                "and id ${script['id']} "
  +                "has null tokenPosTable.");
  +          } else if (tokenPosTable.isEmpty) {
  +            errorMessages.add("Script with uri ${script['uri']} "
  +                "and id ${script['id']} "
  +                "has empty tokenPosTable.");
  +          }
  +        }
  +
  +        // Ensure that we can get a line and column number for all reported
  +        // positions in the scripts we care about.
  +        List ranges = sourceReport["ranges"];
  +        Set<int> scriptIndexesSet = new Set<int>.from(scriptIndexToScript.keys);
  +        for (Map range in ranges) {
  +          if (scriptIndexesSet.contains(range["scriptIndex"])) {
  +            Set<int> positions = new Set<int>();
  +            positions.add(range["startPos"]);
  +            positions.add(range["endPos"]);
  +            Map coverage = range["coverage"];
  +            for (int pos in coverage["hits"]) positions.add(pos);
  +            for (int pos in coverage["misses"]) positions.add(pos);
  +            for (int pos in range["possibleBreakpoints"]) positions.add(pos);
  +            Map script = scriptIndexToScript[range["scriptIndex"]];
  +            Set<int> knownPositions = new Set<int>();
  +            if (script["tokenPosTable"] != null) {
  +              for (List tokenPosTableLine in script["tokenPosTable"]) {
  +                for (int i = 1; i < tokenPosTableLine.length; i += 2) {
  +                  knownPositions.add(tokenPosTableLine[i]);
  +                }
  +              }
  +            }
  +            for (int pos in positions) {
  +              if (!knownPositions.contains(pos)) {
  +                errorMessages.add("Script with uri ${script['uri']} "
  +                    "and id ${script['id']} "
  +                    "references position $pos which cannot be translated to "
  +                    "line and column.");
  +              }
  +            }
  +          }
  +        }
  +        expect(errorMessages, isEmpty);
  +        remoteVm.resume();
  +      }
  +
  +      Directory dir = mytest.createTempSync();
  +      File mainDill = File(p.join(dir.path, p.basename(main.path + ".dill")));
  +      File libDill = File(p.join(dir.path, p.basename(lib.path + ".dill")));
  +      IncrementalCompiler compiler = new IncrementalCompiler(options, main.uri);
  +      await compileAndSerialize(mainDill, libDill, compiler);
  +
  +      var list = new File(p.join(dir.path, 'myMain.dilllist'))..createSync();
  +      list.writeAsStringSync("#@dill\n${mainDill.path}\n${libDill.path}\n");
  +      vm = await Process.start(Platform.resolvedExecutable, <String>[
  +        "--pause-isolates-on-exit",
  +        "--enable-vm-service:0",
  +        list.path
  +      ]);
  +
  +      const kObservatoryListening = 'Observatory listening on ';
  +      final RegExp observatoryPortRegExp =
  +          new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)/");
  +      int port;
  +      final splitter = new LineSplitter();
  +      Completer<String> portLineCompleter = new Completer<String>();
  +      vm.stdout
  +          .transform(utf8.decoder)
  +          .transform(splitter)
  +          .listen((String s) async {
  +        if (s.startsWith(kObservatoryListening)) {
  +          expect(observatoryPortRegExp.hasMatch(s), isTrue);
  +          final match = observatoryPortRegExp.firstMatch(s);
  +          port = int.parse(match.group(1));
  +          await collectStuff(port);
  +          if (!portLineCompleter.isCompleted) {
  +            portLineCompleter.complete("done");
  +          }
  +        }
  +        print("vm stdout: $s");
  +      });
  +      vm.stderr.transform(utf8.decoder).transform(splitter).listen((String s) {
  +        print("vm stderr: $s");
  +      });
  +      await portLineCompleter.future;
  +      print("Compiler terminated with ${await vm.exitCode} exit code");
  +    }, skip: "Currently fails");
     });
   
     group('reload', () {
  
positive.code: 
        var list = new File(p.join(dir.path, 'myMain.dilllist'))..createSync();
        list.writeAsStringSync("#@dill\n${mainDill.path}\n${libDill.path}\n");
        var vm =
            await Process.start(Platform.resolvedExecutable, <String>[list.path]);
  
        final splitter = new LineSplitter();
  
negative.code: 
        var list = new File(p.join(dir.path, 'myMain.dilllist'))..createSync();
        list.writeAsStringSync("#@dill\n${libDill.path}\n${mainDill.path}\n");
        vm =
            await Process.start(Platform.resolvedExecutable, <String>[list.path]);
  
        final splitter = new LineSplitter();
  