OLD | NEW |
1 # Building and Testing AngularDart | 1 # Building and Testing AngularDart |
2 | 2 |
3 This document describes how to set up your development environment to build and
test AngularDart, and | 3 This document describes how to set up your development environment to build and |
4 explains the basic mechanics of using `git`, `node`, and `npm`. | 4 test AngularDart, and explains the basic mechanics of using `git`, `node`, and |
| 5 `npm`. |
5 | 6 |
6 See the [contributing guidelines](https://github.com/angular/angular.dart/blob/m
aster/CONTRIBUTING.md) for how to contribute your own code to | 7 See the [contributing guidelines](https://github.com/angular/angular.dart/blob/m
aster/CONTRIBUTING.md) |
| 8 for how to contribute your own code to |
7 | 9 |
8 1. [Prerequisite Software](#prerequisite-software) | 10 1. [Prerequisite Software](#prerequisite-software) |
9 2. [Getting the Sources](#getting-the-sources) | 11 2. [Getting the Sources](#getting-the-sources) |
10 3. [Environment Variable Setup](#environment-variable-setup) | 12 3. [Environment Variable Setup](#environment-variable-setup) |
11 4. [Installing NPM Modules and Dart Packages](#installing-npm-modules-and-dart-p
ackages) | 13 4. [Installing NPM Modules and Dart Packages](#installing-npm-modules-and-dart-p
ackages) |
12 5. [Running Tests Locally](#running-tests-locally) | 14 5. [Running Tests Locally](#running-tests-locally) |
13 6. [Continuous Integration using Travis](#continuous-integration-using-travis) | 15 6. [Dart Editor configuration](#dart-editor-configuration) |
| 16 7. [WebStorm configuration](#webstorm-configuration) |
| 17 8. [Continuous Integration using Travis](#travis-ci) |
14 | 18 |
15 ## Prerequisite Software | 19 ## Prerequisite Software |
16 | 20 |
17 Before you can build and test AngularDart, you must install and configure the | 21 Before you can build and test AngularDart, you must install and configure the |
18 following products on your development machine: | 22 following products on your development machine: |
19 | 23 |
20 * [Dart](https://www.dartlang.org/): as can be expected, AngularDart requires | 24 * [Dart](https://www.dartlang.org/): as can be expected, AngularDart requires |
21 an installation of the Dart-SDK and Dartium (a version of | 25 an installation of the Dart-SDK and Dartium (a version of |
22 [Chromium](http://www.chromium.org) with native support for Dart through the | 26 [Chromium](http://www.chromium.org) with native support for Dart through the |
23 Dart VM). One of the **simplest** ways to get both is to install the **Dart | 27 Dart VM). One of the **simplest** ways to get both is to install the **Dart |
24 Editor bundle**, which includes the editor, sdk and Dartium. See the [Dart | 28 Editor bundle**, which includes the editor, sdk and Dartium. See the [Dart |
25 tools download page for | 29 tools download page for |
26 instructions](https://www.dartlang.org/tools/download.html). | 30 instructions](https://www.dartlang.org/tools/download.html). |
27 | 31 |
28 * [Git](http://git-scm.com/) and/or the **Github app** (for | 32 * [Git](http://git-scm.com/) and/or the **Github app** (for |
29 [Mac](http://mac.github.com/) or [Windows](http://windows.github.com/)): the | 33 [Mac](http://mac.github.com/) or [Windows](http://windows.github.com/)): the |
30 [Github Guide to Installing | 34 [Github Guide to Installing |
31 Git](https://help.github.com/articles/set-up-git) is a good source of | 35 Git](https://help.github.com/articles/set-up-git) is a good source of |
32 information. | 36 information. |
33 | 37 |
34 * [Node.js](http://nodejs.org): We use Node to run a development web server, | 38 * [Node.js](http://nodejs.org): We use Node to run a development web server, |
35 run tests, and generate distributable files. We also use Node's Package | 39 run tests, and generate distributable files. We also use Node's Package |
36 Manager (`npm`). Depending on your system, you can install Node either from | 40 Manager (`npm`). Depending on your system, you can install Node either from |
37 source or as a pre-packaged bundle. | 41 source or as a pre-packaged bundle. |
38 | 42 |
39 ## Getting the Sources | 43 ## Getting the Sources |
40 | 44 |
41 Forking and Cloning the AngularDart repository: | 45 Forking and Cloning the AngularDart repository: |
42 | 46 |
43 1. Login to your Github account or create one by following the instructions give
n [here](https://github.com/signup/free). | 47 1. Login to your Github account or create one by following the instructions |
| 48 given [here](https://github.com/signup/free). |
44 Afterwards. | 49 Afterwards. |
45 2. [Fork](http://help.github.com/forking) the [main AngularDart repository](http
s://github.com/angular/angular.dart). | 50 2. [Fork](http://help.github.com/forking) the [main AngularDart repository] |
46 3. Clone your fork of the AngularDart repository and define an `upstream` remote
pointing back to the AngularDart repository that you forked in the first place: | 51 (https://github.com/angular/angular.dart). |
| 52 3. Clone your fork of the AngularDart repository and define an `upstream` remote |
| 53 pointing back to the AngularDart repository that you forked in the first place: |
47 | 54 |
48 ```shell | 55 ```shell |
49 # Clone your Github repository: | 56 # Clone your Github repository: |
50 git clone git@github.com:<github username>/angular.dart.git | 57 git clone git@github.com:<github username>/angular.dart.git |
51 | 58 |
52 # Go to the AngularDart directory: | 59 # Go to the AngularDart directory: |
53 cd angular.dart | 60 cd angular.dart |
54 | 61 |
55 # Add the main AngularDart repository as an upstream remote to your repository: | 62 # Add the main AngularDart repository as an upstream remote to your repository: |
56 git remote add upstream https://github.com/angular/angular.dart.git | 63 git remote add upstream https://github.com/angular/angular.dart.git |
57 ``` | 64 ``` |
58 | 65 |
59 ## Environment Variable Setup | 66 ## Environment Variable Setup |
60 | 67 |
61 | 68 |
62 Define the environment variables listed below. These are mainly needed for the | 69 Define the environment variables listed below. These are mainly needed for the |
63 test scripts. The notation shown here is for | 70 test scripts. The notation shown here is for |
64 [`bash`](http://www.gnu.org/software/bash/); adapt as appropriate for your | 71 [`bash`](http://www.gnu.org/software/bash/); adapt as appropriate for your |
65 favorite shell. (Examples given below of possible values for initializing the | 72 favorite shell. (Examples given below of possible values for initializing the |
66 environment variables assume Mac OS X and that you have installed the Dart | 73 environment variables assume Mac OS X and that you have installed the Dart |
67 Editor in the directory named by `$DART_EDITOR_DIR`. This is only for | 74 Editor in the directory named by `$DART_EDITOR_DIR`. This is only for |
68 illustrative purposes.) | 75 illustrative purposes.) |
69 | 76 |
70 ```shell | 77 ```shell |
71 # CHROME_BIN: path to a Chrome browser executable; e.g., | 78 # CHROME_BIN: path to a Chrome browser executable; e.g., |
72 export CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" | 79 export CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" |
73 | 80 |
74 # CHROME_CANARY_BIN: path to a Dartium browser executable; e.g., | 81 # DARTIUM_BIN: path to a Dartium browser executable; e.g., |
75 export CHROME_CANARY_BIN="$DART_EDITOR_DIR/chromium/Chromium.app/Contents/MacOS/
Chromium" | 82 export DARTIUM_BIN="$DART_EDITOR_DIR/chromium/Chromium.app/Contents/MacOS/Chromi
um" |
76 ``` | 83 ``` |
77 **Note**: the `$CHROME_CANARY_BIN` environment variable is used by karma to run
your tests | 84 **Note**: the `$DARTIUM_BIN` environment variable is used by karma to run |
78 in dartium instead of chromium. If you don't do this, the dart2js compile will m
ake the tests | 85 your tests in dartium instead of chromium. If you don't do this, the dart2js |
79 run extremely slow since it has to wait for a full js compile each time. | 86 compile will make the tests run extremely slow since it has to wait for a full |
| 87 js compile each time. |
80 | 88 |
81 You should also add the Dart SDK `bin` directory to your path and/or define `DAR
T_SDK`; e.g. | 89 You should also add the Dart SDK `bin` directory to your path and/or define |
| 90 `DART_SDK`; e.g. |
82 | 91 |
83 ```shell | 92 ```shell |
84 # DART_SDK: path to a Dart SDK directory; e.g., | 93 # DART_SDK: path to a Dart SDK directory; e.g., |
85 export DART_SDK="$DART_EDITOR_DIR/dart-sdk" | 94 export DART_SDK="$DART_EDITOR_DIR/dart-sdk" |
86 | 95 |
87 # Update PATH to include the Dart SDK bin directory | 96 # Update PATH to include the Dart SDK bin directory |
88 PATH+=":$DART_SDK/bin" | 97 PATH+=":$DART_SDK/bin" |
89 ``` | 98 ``` |
90 ## Installing NPM Modules and Dart Packages | 99 ## Installing NPM Modules and Dart Packages |
91 | 100 |
(...skipping 17 matching lines...) Expand all Loading... |
109 To run base tests: | 118 To run base tests: |
110 | 119 |
111 ```shell | 120 ```shell |
112 # Source a script to define yet more environment variables | 121 # Source a script to define yet more environment variables |
113 . ./scripts/env.sh | 122 . ./scripts/env.sh |
114 | 123 |
115 # Run io tests: | 124 # Run io tests: |
116 dart --checked test/io/all.dart | 125 dart --checked test/io/all.dart |
117 | 126 |
118 # Run expression extractor tests: | 127 # Run expression extractor tests: |
119 scripts/test-expression-extractor.sh | 128 ./scripts/test-expression-extractor.sh |
120 | 129 |
121 Run the Dart Analyzer: | 130 # Run the Dart Analyzer: |
122 ./scripts/analyze.sh | 131 ./scripts/analyze.sh |
123 ``` | 132 ``` |
124 | 133 |
125 To run Karma tests over Dartium, execute the following shell commands (which | 134 To run Karma tests over Dartium, execute the following shell commands (which |
126 will launch the Karma server): | 135 will launch the Karma server): |
127 | 136 |
128 ```shell | 137 ```shell |
129 . ./scripts/env.sh | 138 . ./scripts/env.sh |
130 node "node_modules/karma/bin/karma" start karma.conf \ | 139 node "node_modules/karma/bin/karma" start karma.conf \ |
131 --reporters=junit,dots --port=8765 --runner-port=8766 \ | 140 --reporters=junit,dots --port=8765 --runner-port=8766 \ |
132 --browsers=Dartium | 141 --browsers=Dartium |
133 ``` | 142 ``` |
134 | 143 |
135 In another shell window or tab, or from your favorite IDE, launch the Karma | 144 In another shell window or tab, or from your favorite IDE, launch the Karma |
136 tests proper by executing: | 145 tests proper by executing: |
137 | 146 |
138 ```shell | 147 ```shell |
139 . ./scripts/env.sh | 148 . ./scripts/env.sh |
140 karma_run.sh | 149 ./scripts/karma_run.sh |
141 ``` | 150 ``` |
142 | 151 |
143 **Note:**: If the dart analyzer fails with warnings, the tests will not run. | 152 **Note:**: If the dart analyzer fails with warnings, the tests will not run. |
144 You can manually run the tests if this happens: | 153 You can manually run the tests if this happens: |
145 | 154 |
146 ```shell | 155 ```shell |
147 karma run --port=8765 | 156 karma run --port=8765 |
148 ``` | 157 ``` |
149 | 158 |
150 ## Debugging | 159 **Note**: If you want to only run a single test you can alter the test you wish |
| 160 to run by changing `it` to `iit` or `describe` to `ddescribe`. This will only |
| 161 run that individual test and make it much easier to debug. `xit` and `xdescribe` |
| 162 can also be useful to exclude a test and a group of tests respectively. |
151 | 163 |
152 In the dart editor you can configure a dartium launch target for the karma test
runner debug page. | 164 ## Dart Editor configuration |
153 The menu option is under Run > Manage Launches > Create new Dartium Launch. | 165 |
| 166 In the dart editor you can configure a dartium launch target for the karma test |
| 167 runner debug page. The menu option is under "Run > Manage Launches > Create new |
| 168 Dartium Launch". |
154 | 169 |
155 ``` | 170 ``` |
156 http://localhost:8765/debug.html | 171 http://localhost:8765/debug.html |
157 ``` | 172 ``` |
158 | 173 |
159 If you want to only run a single test you can alter the test you wish to run by
changing `it` to `iit` | 174 ## WebStorm configuration |
160 or `describe` to `ddescribe`. This will only run that individual test and make i
t much easier to debug. | |
161 | 175 |
| 176 ### Recent releases |
162 | 177 |
| 178 With the recent releases of WebStorm and the karma plugin, you could run the |
| 179 test suite by only adding a karma run configuration. |
| 180 |
| 181 Right-click on the `karma.conf.js` at the root of the project and select |
| 182 "create 'karma.conf.js'...". |
| 183 |
| 184 Set the parameters as follow: |
| 185 - **Node interpreter**: `/path/to/node` |
| 186 - **Karma node package**: `/path/to/node_modules/karma` |
| 187 - **Configuration file (usually *.conf.js)**: `path/to/angular.dart/karma.conf.j
s` |
| 188 - **Environment variables**: |
| 189 - **DARTIUM_BIN**: `/path/to/dartium` |
| 190 - **PATH**: `/path/to/dart-sdk/bin` |
| 191 - **DART_FLAGS**: `--checked` |
| 192 |
| 193 Now just hit the run button next to the configuration name in the Toolbar and |
| 194 you should see the test running. The test suite is automatically executed each |
| 195 time a source file is modified. |
| 196 |
| 197 If you encounter troubles with this configuration, try using the one from the |
| 198 following section. |
| 199 |
| 200 ### Former releases |
| 201 |
| 202 Start by creating a run configuration to launch the Karma server. Go to the menu |
| 203 "Run > Edit Configuration Menu" add create a `Node.js` configuration named |
| 204 "Karma server". |
| 205 |
| 206 Set the parameters as follow: |
| 207 - **Node interpreter**: `/path/to/node` |
| 208 - **Working directory**: `/path/to/angular.dart` |
| 209 - **JavaScript file**: `node_modules/karma/bin/karma` |
| 210 - **Application parameters**: `start karma.conf --reporters dots --port 8765 --b
rowsers=Dartium` |
| 211 - **Environment variables**: |
| 212 - **DARTIUM_BIN**: `/path/to/dartium` |
| 213 - **PATH**: `/path/to/dart-sdk/bin` |
| 214 - **DART_FLAGS**: `--checked` |
| 215 |
| 216 Launch the server by selecting the "Karmer server" configuration in the toolbar |
| 217 and pressing the play icon. You should see the following message at the bottom |
| 218 of the run window: |
| 219 `INFO [Chrome 34.0.1847 (Linux)]: Connected on socket 97GpzQz-MfHFPHgHOVkc with
id 10199707` |
| 220 |
| 221 #### Running the tests |
| 222 |
| 223 You need to create a "Karma tests" run configuration. Start by copying the |
| 224 "Karma server" run configuration and xhange the **Application parameters** to |
| 225 `run --port=8765`. |
| 226 |
| 227 To execute the test suite, you just need to run this "Karma tests" |
| 228 configuration. You should make sure to execute "Karma server" first _(You do not |
| 229 need to restart the server once it has been started once)_. |
| 230 |
| 231 #### Debugging |
| 232 |
| 233 You need to create a "JavaScript Debug" configuration named "Karma debug". Set |
| 234 the parameters as follow: |
| 235 - **URL**: `http://localhost:8765/debug.html` |
| 236 - **Browser**: Dartium, |
| 237 - **Remote URLs of local files (optional)**: |
| 238 - `path/to/angular.dart`: `http://localhost:8765/base` |
| 239 - `path/to/angular.dart/lib`: `http://localhost:8765/package:angular` |
| 240 |
| 241 You can now put breakpoint in your karma tests, run this configuration and debug |
| 242 your tests step by step. |
| 243 |
| 244 You might be asked to install the "JetBrains IDE Support" in Dartium, if not you |
| 245 can install it [manually](https://chrome.google.com/webstore/detail/jetbrains-id
e-support/hmhgeddbohgjknpmjagkdomcpobmllji). |
| 246 |
| 247 <a name="travis-ci"></a> |
163 ## Continuous Integration using Travis | 248 ## Continuous Integration using Travis |
164 | 249 |
165 See the instructions given [here](https://github.com/angular/angular.dart/blob/m
aster/travis.md). | 250 See the instructions given [here](https://github.com/angular/angular.dart/blob/m
aster/travis.md). |
166 | 251 |
167 ----- | 252 |
OLD | NEW |