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

Side by Side Diff: tests/compiler/dart2js/cps_ir/README.md

Issue 1576093003: cpsir unittests: move all unittests into individual files and test runners. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
(Empty)
1 # CPS IR unit tests
2
3 This folder contains unit tests of the CPS IR. These tests run the compiler with
4 the cps IR and check for the output of a specific function (typically main).
5
6 To make our lives easier, most files here are autogenerated. You should never
7 have to edit a file under `expected/` or any file with an `AUTOGENERATED` header
8 (including the `_test.dart` files).
9
10 See instructions below to add or update tests.
11
12 ### Adding a new test
13
14 Every test has 3 files: an input file, a test runner file, and an expectation
15 file. The last two are auto-generated. Here is how:
16
17 * add a file under `input/` with a unique name, such as `foo_bar.dart`. Do not
18 include `_test` in the name of this file, otherwise the test framework will
19 think this test needs to be run directly in the vm and in a browser, that's
20 not our goal.
21
22 * generate the corresponding test file, by running the `up_to_date_test.dart`
23 passing `update` as an argument:
24
25 ```bash
26 dart tests/compiler/dart2js/cps_ir/up_to_date_test.dart update
27 ```
28
29 This will generate a file `foo_bar_test.dart` on this folder.
30
31 * generate the expectations of the test file by running the generated test file
32 with `update` as an argument:
33
34 ```bash
35 dart --package-root=out/ReleaseX64/packages tests/compiler/dart2js/cps_ir/foo_ba r_test.dart update
36 ```
37
38 This will generate a file `expected/foo_bar.js` with the expected output.
39
40 ### Checking a method other than main
41
42 By default, the test expectations will be generated to contain just the body of
43 the main function. If you wish to check for a different element, include a
44 comment at the top of the input test like this:
45 ```dart
46 // Method to test: function(foo)
47 ```
48 The trailing text should match the string representation of a compiler element.
49
50 **Note**: this format will likely change in the future. We would like to have a
51 canonical way to refer to elements that is independent of the internal compiler
52 implementation, we also want a way to specify more than just one element, and a
53 way to specify that an element has been tree-shaken.
54
55 ### Updating a single test expectation
56
57 To update the expectations of a test, simply regenerate it by running the test
58 file with `update` as an argument:
59
60 ```bash
61 dart --package-root=out/ReleaseX64/packages tests/compiler/dart2js/cps_ir/foo_ba r_test.dart update
62 ```
63
64 This will override the file `expected/foo_bar.js` file with the new output.
65
66 If a test fails because the expectations are out of date, you'll see this
67 suggestion in the failure message too.
68
69 ### Updating all test expectations
70
71 For convenience, we also provide a script to update all expectations at once.
72
73 ```bash
74 dart --package-root=out/ReleaseX64/packages tests/compiler/dart2js/cps_ir/update _all.dart
75 ```
76
77 It is equivalent to update each test individually. This script can be handy when
78 making cross-cutting changes that affect the output of most tests.
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/analyze_test_test.dart ('k') | tests/compiler/dart2js/cps_ir/argument_refinement_10_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698