Chromium Code Reviews| Index: runtime/observatory/tests/service/service_test_common.dart |
| diff --git a/runtime/observatory/tests/service/service_test_common.dart b/runtime/observatory/tests/service/service_test_common.dart |
| index c623234c8165016393e895513e728fa59395f8e2..1bd7250004f9380d9795779425cc925f61eb2606 100644 |
| --- a/runtime/observatory/tests/service/service_test_common.dart |
| +++ b/runtime/observatory/tests/service/service_test_common.dart |
| @@ -5,7 +5,8 @@ |
| library service_test_common; |
| import 'dart:async'; |
| -import 'dart:io' show Platform; |
| +import 'dart:io' show File, Platform; |
| + |
| import 'package:observatory/models.dart' as M; |
| import 'package:observatory/service_common.dart'; |
| import 'package:unittest/unittest.dart'; |
| @@ -15,6 +16,29 @@ typedef Future VMTest(VM vm); |
| Map<String, StreamSubscription> streamSubscriptions = {}; |
| +class ScriptLineParser { |
|
rmacnak
2017/06/12 16:02:12
Awesome!
|
| + List<String> lines; |
| + |
| + ScriptLineParser(Uri scriptUri) { |
| + String content = new File(scriptUri.toFilePath()).readAsStringSync(); |
| + lines = content.split('\n'); |
| + } |
| + |
| + int lineFor(String commentContent) { |
| + String match1 = '// $commentContent'; |
| + String match2 = '/* $commentContent */'; |
| + |
| + for (int i = 0; i < lines.length; i++) { |
| + if (lines[i].contains(match1) || lines[i].contains(match2)) { |
| + // return the 1-based line number |
| + return i + 1; |
| + } |
| + } |
| + |
| + return -1; |
| + } |
| +} |
| + |
| Future subscribeToStream(VM vm, String streamName, onEvent) async { |
| assert(streamSubscriptions[streamName] == null); |