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

Side by Side Diff: runtime/observatory/HACKING.md

Issue 2079953002: Added HACKING.md to observatory (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated HACKING.md 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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][build_sdk] to have a
Cutch 2016/06/21 20:02:07 (here and elsewhere) reflow to 80 character limit.
Cutch 2016/06/21 20:02:07 Before you start to hack on Observatory, follow th
cbernaschina 2016/06/21 21:52:14 Done.
cbernaschina 2016/06/21 21:52:15 Done.
10 working environment in which you are able to build and test the Dart SDK.
11
12 ### Develop with Dartium ~ Suggested
13 If you want to avoid triggering a new compilation to JavaScript for each edit
14 you do, you can use a modified version of Chromium named Dartium that will
15 interpret you dart code directly.
16
17 You can obtain Dartium in two different ways:
18 1. [Download][download_dartium] the binaries
19 2. [Build][build_dartium] Dartium from the source code
20
21
22 ## Run existing tests
23 Before hacking Observatory let's run the existing Observatory tests.
24 We suggest to run all the test in __debug__ mode.
25
26 First build the sdk in debug mode
27 ```
28 $ ./tools/build.py --mode debug --arch x64 create_sdk
Cutch 2016/06/21 20:02:07 drop the --arch flag here or add it to test.py (th
cbernaschina 2016/06/21 21:52:15 Done.
29 ```
30
31 From the root of the sdk repository run:
32 ```
33 $ ./tools/test.py -mdebug service
34 ```
35
36 ## Serve Observatory
37 Observatory is built as part of building the sdk, but when working on
38 Observatory we recommend that you use __pub serve__ so you can avoid the
39 overhead of building the sdk for each change.
40
41 Use __pub__ to __serve__ Observatory:
42 ```
43 [...]/runtime/observatory$ pub serve
44 ```
45
46 ## Open Observatory
47 You can open the development version of Observatory from
48 Chrome/Chromium/__Dartium__ by navigating to [localhost:8080][open_observatory]
49
50 Every change you make to the Observatory source code will be visible by simply
51 __refreshing__ the page in the browser.
52
53 ## Connect to a VM
54 Start a Dart VM with the ``--observe`` flag (as explained in the
55 [get started guide][observatory_get_started]) and connect your Observatory insta nce to that VM.
56
57 Example script (file name ```clock.dart```):
58 ```
59 import 'dart:async' show Timer, Duration;
60
61 main() {
62 bool tick = true;
63 new Timer.periodic(const Duration(seconds: 1), (Timer t) {
64 print(tick ? 'tick' : 'tock');
65 tick = !tick;
66 });
67 }
68 ```
69 Start the script:
70 ```
71 $ dart --observe clock.dart
72 ```
73
74 ## Code Reviews
75 The development workflow of Dart (and Observatory) is based on code reviews.
76
77 Follow the code review [instructions][code_review] to be able to successfully su bmit your
78 code.
79
80 The main reviewers for Observatory related CLs are:
81 - turnidge
82 - johnmccutchan
83 - rmacnak
84
85 ## Write a new service test
86 All the service tests are located in the ```tests/service``` folder.
87 Test file names follow the convention ```<description>_test.dart```
88 (e.g. ```a_brief_description_test.dart```).
89
90 The test is generally structured in the following way.
91 ```dart
92 import 'package:test/test.dart';
93
94 main() {
95 // Some code that you need to test.
96 var a = 1 + 2;
97
98 // Some assertions to check the results.
99 expect(a, equal(3));
100 }
101 ```
102 See the official [test library][test_library] instructions;
103
104 The ```test_helper.dart``` file expose some functions that allow to run a part
105 of the code into another __VM__.
106
107 To test synchronous operations:
108 ```dart
109 import 'test_helper.dart';
110
111 code() {
112 // Write the code you want to be execute into another VM.
113 }
114
115 var tests = [
116 // A series of tests that you want to run against the above code.
117 (Isolate isolate) async {
118 await isolate.reload();
119 // Use the isolate to communicate to the VM.
120 }
121 ];
122
123 main(args) => runIsolateTestsSynchronous(args,
124 tests,
125 testeeConcurrent: code);
126 ```
127
128 In order to test asynchronous operations:
129 ```dart
130 import 'test_helper.dart';
131
132 code() async{
Cutch 2016/06/21 20:02:07 missing space after async
cbernaschina 2016/06/21 21:52:15 Done.
133 // Write the asynchronous code you want to be execute into another VM.
134 }
135
136 var tests = [
137 // A series of tests that you want to run against the above code.
138 (Isolate isolate) async {
139 await isolate.reload();
140 // Use the isolate to communicate to the VM.
141 }
142 ];
143
144 main(args) async => runIsolateTests(args,
145 tests,
146 testeeConcurrent: code);
147 ```
148
149 Both ```runIsolateTests``` and ```runIsolateTestsSynchronous``` have the
150 following named parameters:
151 - __testeeBefore__ (void()) a function that is going to be executed before
152 the test
153 - __testeeConcurrent__ (void()) test that is going to be executed
154 - __pause_on_start__ (bool, default: false) pause the Isolate before the first
155 instruction
156 - __pause_on_exit__ (bool, default: false) pause the Isolate after the last
157 instruction
158 - __pause_on_unhandled_exceptions__ (bool, default: false) pause the Isolate at
159 an unhandled exception
160 - __trace_service__ (bool, default: false) trace VM service requests
161 - __trace_compiler__ (bool, default: false) trace compiler operations
162 - __verbose_vm__ (bool, default: false) verbose logging
163
164
165 Some common and reusable test are available from ```service_test_common.dart```:
166 - hasPausedFor
167 - hasStoppedAtBreakpoint
168 - hasStoppedWithUnhandledException
169 - hasStoppedAtExit
170 - hasPausedAtStartcode_review
171 and utility functions:
172 - subscribeToStream
173 - cancelStreamSubscription
174 - asyncStepOver
175 - setBreakpointAtLine
176 - resumeIsolate
177 - resumeAndAwaitEvent
178 - resumeIsolateAndAwaitEvent
179 - stepOver
180 - getClassFromRootLib
181 - rootLibraryFieldValue
182
183 ## Run your tests
184 See: __Run existing tests__
185
186 [build_sdk]: https://github.com/dart-lang/sdk/wiki/Building "Building the Dart S DK"
187 [download_dartium]: https://www.dartlang.org/tools/dartium/ "Download Dartium"
188 [build_dartium]: https://github.com/dart-lang/sdk/wiki/Building-Dartium "Build D artium"
189 [open_observatory]: http://localhost:8080/ "Open Observatory"
190 [observatory_get_started]: https://dart-lang.github.io/observatory/get-started.h tml "Observatory get started"
191 [code_review]: https://github.com/dart-lang/sdk/wiki/Code-review-workflow-with-G itHub-and-reitveld "Code Review"
192 [test_library]: https://pub.dartlang.org/packages/test "Test Library"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698