Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Hacking Observatory | |
| 2 | |
| 3 These instructions will guide you through the Observatory development and | |
| 4 testing workflow. | |
| 5 | |
| 6 ## SDK Setup & Build | |
| 7 Getting ready to start. | |
| 8 | |
| 9 Before starting hacking observatory follow [the instructions][1] to have a | |
|
Cutch
2016/06/20 14:47:01
how about [instructions](http://....) for this and
cbernaschina
2016/06/20 16:10:11
The [...][...] version allows to reuse links and t
| |
| 10 working environment in which you are able to build and test the Dart SDK. | |
| 11 | |
| 12 ## Run existing tests | |
| 13 Before hacking Observatory let's run the existing Observatory tests. | |
| 14 | |
| 15 From the root of the sdk repository run: | |
| 16 ``` | |
| 17 $ ./tools/test.py -mrelease service | |
|
Cutch
2016/06/20 14:47:01
We recommend people use the debug mode for running
cbernaschina
2016/06/20 16:10:11
Done.
| |
| 18 ``` | |
| 19 | |
| 20 ## Develop with Dartium ~ Suggested | |
| 21 If you want to avoid to trigger a new compilation to JavaScript for each edit | |
|
Cutch
2016/06/20 14:47:01
If you want to avoid triggering a ...
cbernaschina
2016/06/20 16:10:11
Done.
| |
| 22 you do, you can use a modified version of Chromium named Dartium that will | |
| 23 interpret you dart code directly. | |
| 24 | |
| 25 You can obtain Dartium in two different ways: | |
|
Cutch
2016/06/20 14:47:01
Move the dartium download up to the top in the set
cbernaschina
2016/06/20 16:10:11
Done.
| |
| 26 1. [Download the binaries][2] | |
| 27 2. [Build Dartium from the source code][3] | |
| 28 | |
| 29 ## Serve Observatory | |
| 30 In order to avoid a complete build of the sdk for each change you do to | |
|
Cutch
2016/06/20 14:47:01
How about:
"Observatory is built as part of build
cbernaschina
2016/06/20 16:10:11
Done.
| |
| 31 Observatory, we are going to __serve__ it directly. | |
| 32 | |
| 33 Use __pub__ to __serve__ Observatory: | |
| 34 ``` | |
| 35 [...]/runtime/observatory$ pub serve | |
| 36 ``` | |
| 37 | |
| 38 ## Open Observatory | |
| 39 You can open the development version of Observatory from | |
| 40 Chrome/Chromium/__Dartium__ by navigating to [localhost:8080][4] | |
| 41 | |
| 42 Every change you make to the Observatory source code will be visible by simply | |
| 43 __refreshing__ the page in the browser. | |
| 44 | |
| 45 ## Connect to a VM | |
| 46 Start a Dart VM with the ``--observe`` flag (as explained in the | |
| 47 [get started guide][5]) and connect your Observatory instance to that VM. | |
|
Cutch
2016/06/20 14:47:01
Let's provide a sample script here:
```dart
impo
cbernaschina
2016/06/20 16:10:11
Done.
| |
| 48 | |
| 49 ## Code Reviews | |
| 50 The development workflow of Dart (and Observatory) is based on code reviews. | |
| 51 | |
| 52 Follow the [code review instructions][6] to be able to successfully submit your | |
| 53 code. | |
| 54 | |
| 55 The main reviewers for Observatory related CLs are: | |
| 56 - turnidge | |
| 57 - johnmccutchan | |
| 58 - rmacnak | |
| 59 | |
| 60 ## Write a new service test | |
| 61 All the service tests are located in the ```tests/service``` folder. | |
| 62 Test file names follow the convention ```<description>_test.dart``` | |
| 63 (e.g. ```a_brief_description_test.dart```). | |
| 64 | |
| 65 The test is generally structured in the following way. | |
| 66 ```dart | |
| 67 import 'package:test/test.dart'; | |
| 68 | |
| 69 main() { | |
| 70 // Some code that you need to test. | |
| 71 var a = 1 + 2; | |
| 72 | |
| 73 // Some assertions to check the results. | |
| 74 expect(a, equal(3)); | |
| 75 } | |
| 76 ``` | |
| 77 See the official [test library][7] instructions; | |
| 78 | |
| 79 The ```test_helper.dart``` file expose some functions that allow to run a part | |
| 80 of the code into another __VM__. | |
| 81 | |
| 82 To test synchronous operations: | |
| 83 ```dart | |
| 84 import 'test_helper.dart'; | |
| 85 | |
| 86 code() { | |
| 87 // Write the code you want to be execute into another VM. | |
| 88 } | |
| 89 | |
| 90 var tests = [ | |
| 91 // A series of tests that you want to run against the above code. | |
| 92 (Isolate isolate) async { | |
| 93 await isolate.reload(); | |
| 94 // Use the isolate to communicate to the VM. | |
| 95 } | |
| 96 ]; | |
| 97 | |
| 98 main(args) => runIsolateTestsSynchronous(args, | |
| 99 tests, | |
| 100 testeeConcurrent: code); | |
| 101 ``` | |
| 102 | |
| 103 In order to test asynchronous operations: | |
| 104 ```dart | |
| 105 import 'test_helper.dart'; | |
| 106 | |
| 107 code() async{ | |
| 108 // Write the asynchronous code you want to be execute into another VM. | |
| 109 } | |
| 110 | |
| 111 var tests = [ | |
| 112 // A series of tests that you want to run against the above code. | |
| 113 (Isolate isolate) async { | |
| 114 await isolate.reload(); | |
| 115 // Use the isolate to communicate to the VM. | |
| 116 } | |
| 117 ]; | |
| 118 | |
| 119 main(args) async => runIsolateTests(args, | |
| 120 tests, | |
| 121 testeeConcurrent: code); | |
| 122 ``` | |
| 123 | |
| 124 Both ```runIsolateTests``` and ```runIsolateTestsSynchronous``` have the | |
| 125 following named parameters: | |
| 126 - __testeeBefore__ (void()) a function that is going to be executed before | |
| 127 the test | |
| 128 - __testeeConcurrent__ (void()) test that is going to be executed | |
| 129 - __pause_on_start__ (bool, default: false) pause the Isolate before the first | |
| 130 instruction | |
| 131 - __pause_on_exit__ (bool, default: false) pause the Isolate after the last | |
| 132 instruction | |
| 133 - __pause_on_unhandled_exceptions__ (bool, default: false) pause the Isolate at | |
| 134 an unhandled exception | |
| 135 - __trace_service__ (bool, default: false) trace VM service requests | |
| 136 - __trace_compiler__ (bool, default: false) trace compiler operations | |
| 137 - __verbose_vm__ (bool, default: false) verbose logging | |
| 138 | |
| 139 | |
| 140 Some common and reusable test are available from ```service_test_common.dart```: | |
| 141 - hasPausedFor | |
| 142 - hasStoppedAtBreakpoint | |
| 143 - hasStoppedWithUnhandledException | |
| 144 - hasStoppedAtExit | |
| 145 - hasPausedAtStart | |
| 146 - stoppedAtLine | |
| 147 | |
| 148 and utility functions: | |
| 149 - subscribeToStream | |
| 150 - cancelStreamSubscription | |
| 151 - asyncStepOver | |
| 152 - setBreakpointAtLine | |
| 153 - resumeIsolate | |
| 154 - resumeAndAwaitEvent | |
| 155 - resumeIsolateAndAwaitEvent | |
| 156 - stepOver | |
| 157 - getClassFromRootLib | |
| 158 - rootLibraryFieldValue | |
| 159 | |
| 160 ## Run your tests | |
| 161 See: __Run existing tests__ | |
| 162 | |
| 163 [1]: https://github.com/dart-lang/sdk/wiki/Building "Building the Dart SDK" | |
| 164 [2]: https://www.dartlang.org/tools/dartium/ "Download Dartium" | |
| 165 [3]: https://github.com/dart-lang/sdk/wiki/Building-Dartium "Build Dartium" | |
| 166 [4]: http://localhost:8080/ "Open Observatory" | |
| 167 [5]: https://dart-lang.github.io/observatory/get-started.html "Observatory get s tarted" | |
| 168 [6]: https://github.com/dart-lang/sdk/wiki/Code-review-workflow-with-GitHub-and- reitveld "Code Review" | |
| 169 [7]: https://pub.dartlang.org/packages/test "Test Library" | |
| OLD | NEW |