Skip to content

Commit f8b6ded

Browse files
Added 'filename' metadata tag to 'CONTRIBUTING.md'.
1 parent 45cf145 commit f8b6ded

File tree

1 file changed

+47
-16
lines changed

1 file changed

+47
-16
lines changed

CONTRIBUTING.md

+47-16
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,75 @@ Your pull request should:
3131
## Running the Tests
3232
To run all tests, invoke the runtests target using jake:
3333

34-
`jake runtests`
34+
```Shell
35+
jake runtests
36+
```
3537

3638
This run will all tests; to run only a specific subset of tests, use:
3739

38-
`jake runtests tests=<regex>`
40+
```Shell
41+
jake runtests tests=<regex>
42+
```
3943

4044
e.g. to run all compiler baseline tests:
4145

42-
`jake runtests tests=compiler`
46+
```Shell
47+
jake runtests tests=compiler
48+
```
4349

44-
or to run specifc test:tests\cases\compiler\2dArrays.ts
50+
or to run specifc test: `tests\cases\compiler\2dArrays.ts`
4551

46-
`jake runtests tests=2dArrays`
52+
```Shell
53+
jake runtests tests=2dArrays
54+
```
4755

4856
## 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.
5058

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:
5260

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.
5767

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.
5969
**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.
6070

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+
export function f() {
78+
}
79+
80+
// @filename: file2.ts
81+
import { f as g } from "file1";
82+
83+
var x = g();
84+
```
85+
86+
One can also write a project test, but it is slightly more involved.
87+
6188
## 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.
6390

6491
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use
6592

66-
`jake diff`
93+
```Shell
94+
jake diff
95+
```
6796

6897
After verifying that the changes in the baselines are correct, run
6998

70-
`jake baseline-accept`
99+
```Shell
100+
jake baseline-accept
101+
```
71102

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.
73104

74105
**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

Comments
 (0)