You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+47-16
Original file line number
Diff line number
Diff line change
@@ -31,44 +31,75 @@ Your pull request should:
31
31
## Running the Tests
32
32
To run all tests, invoke the runtests target using jake:
33
33
34
-
`jake runtests`
34
+
```Shell
35
+
jake runtests
36
+
```
35
37
36
38
This run will all tests; to run only a specific subset of tests, use:
37
39
38
-
`jake runtests tests=<regex>`
40
+
```Shell
41
+
jake runtests tests=<regex>
42
+
```
39
43
40
44
e.g. to run all compiler baseline tests:
41
45
42
-
`jake runtests tests=compiler`
46
+
```Shell
47
+
jake runtests tests=compiler
48
+
```
43
49
44
-
or to run specifc test:tests\cases\compiler\2dArrays.ts
50
+
or to run specifc test:`tests\cases\compiler\2dArrays.ts`
45
51
46
-
`jake runtests tests=2dArrays`
52
+
```Shell
53
+
jake runtests tests=2dArrays
54
+
```
47
55
48
56
## Adding a Test
49
-
To add a new testcase, simply place a .ts file in tests\cases\compiler containing code that exemplifies the bugfix or change you are making.
57
+
To add a new testcase, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making.
50
58
51
-
These files support metadata tags in the format // @name: value. The supported names and values are:
59
+
These files support metadata tags in the format `// @metaDataName: value`. The supported names and values are:
52
60
53
-
* comments, sourcemap, noimplicitany, declaration: true or false (corresponds to the compiler command-line options of the same name)
54
-
* target: ES3 or ES5 (same as compiler)
55
-
* out, outDir: path (same as compiler)
56
-
* module: local, commonjs, or amd (local corresponds to not passing any compiler --module flag)
61
+
*`comments`, `sourcemap`, `noimplicitany`, `declaration`: true or false (corresponds to the compiler command-line options of the same name)
62
+
*`target`: ES3 or ES5 (same as compiler)
63
+
*`out`, outDir: path (same as compiler)
64
+
*`module`: local, commonjs, or amd (local corresponds to not passing any compiler --module flag)
65
+
*`fileName`: path
66
+
* These tags delimit sections of a file to be used as separate compilation units. They are useful for tests relating to modules. See below for examples.
57
67
58
-
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in tests\cases\conformance in an appropriately-named subfolder.
68
+
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in `tests\cases\conformance` in an appropriately-named subfolder.
59
69
**Note** that filenames here must be distinct from all other compiler testcase names, so you may have to work a bit to find a unique name if it's something common.
60
70
71
+
# Tests for multiple files
72
+
73
+
When one needs to test for scenarios which require multiple files, it is useful to use the `fileName` metadata tag as such:
74
+
75
+
```TypeScript
76
+
// @filename: file1.ts
77
+
exportfunction f() {
78
+
}
79
+
80
+
// @filename: file2.ts
81
+
import { fasg } from"file1";
82
+
83
+
var x =g();
84
+
```
85
+
86
+
One can also write a project test, but it is slightly more involved.
87
+
61
88
## Managing the Baselines
62
-
Compiler testcases generate baselines that track the emitted .js, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
89
+
Compiler testcases generate baselines that track the emitted `.js`, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
63
90
64
91
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use
65
92
66
-
`jake diff`
93
+
```Shell
94
+
jake diff
95
+
```
67
96
68
97
After verifying that the changes in the baselines are correct, run
69
98
70
-
`jake baseline-accept`
99
+
```Shell
100
+
jake baseline-accept
101
+
```
71
102
72
-
to establish the new baselines as the desired behavior. This will change the files in tests\baselines\reference, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
103
+
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
73
104
74
105
**Note** that baseline-accept should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run.
0 commit comments