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
Update letop-punning tests, add note to CONTRIBUTING (#2748)
* Fix redundancy in letop-punning tests
* Notes on adding a test in CONTRIBUTING
* CHANGES entry
* Edits per @EmileTrotignon
* Typo repair
* Edits per @Julow
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+51-2Lines changed: 51 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,8 +19,57 @@ We heartily welcome pull requests. To ensure an effective contribution, please a
19
19
1. For significant, invasive, or output-affecting changes, consider opening an issue for discussion before committing substantial time and effort.
20
20
2. If you're new to the project, starting with the [Good first issues](https://github.com/ocaml-ppx/ocamlformat/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22Good-first-issue+%3Agreen_heart%3A%22) can be beneficial.
21
21
3. Fork the repository and create your branch from `main`.
22
-
4. If you've added code that should be tested, supplement it with tests located in the `test/` directory.
23
-
5. Ensure that the test suite passes (see [Running the tests](#running-the-tests) for instructions).
22
+
4. Ensure that the test suite passes (see [Running the tests](#running-the-tests) for instructions). If there are changes in the tests,
23
+
verify that they are expected. If no existing test output changed, you likely need to add new tests (see [Adding a test](#adding-a-test)).
24
+
25
+
### Adding a Test
26
+
27
+
#### Golden Tests
28
+
29
+
The majority of tests for `ocamlformat` are so called "golden" or "expect" tests. These
30
+
tests all consist of running `ocamlformat` on `.ml` files and comparing the
31
+
output to expected output stored in reference files. The `dune` configuration
32
+
for this is automatically generated for you based on the files present in these
33
+
directories the first time `dune runtest` is executed.
34
+
35
+
These are separated into `test/failing` and `test/passing` directories.
36
+
37
+
To add a test showing currently incorrect behavior, add a `.ml` file to
38
+
`test/failing/tests`. If command line arguments are needed, create a
39
+
corresponding `.ml.opts` file with the same name. The output of these tests
40
+
will be stored in `.ml.broken-ref` files.
41
+
42
+
To add a test showing correct behavior, add a `.ml` file to `test/passing/tests`
43
+
or update an existing file there. These tests are similar to the failing tests,
44
+
including the use of the `.ml.opts` files for command line arguments, however the
45
+
same file will be tested against all of the built-in configurations (e.g.
46
+
`default`, `janestreet`, etc.), with outputs appearing in sub folders named
47
+
`refs.<configuration>`.
48
+
49
+
In both cases, if multiple sets of options are desired, you can create multiple
50
+
`.ml.opts` files with names provided after a `-`, for example `mytest.ml` can have
51
+
`mytest-foo.ml.opts` and `mytest-bar.ml.opts`. This will create multiple test targets.
52
+
53
+
The first time you [run the tests](#running-the-tests), the `dune.inc` file will
54
+
be updated. Once you have promoted this, subsequent runs will show you any
55
+
differences between the expected and actual outputs, which can be accepted with
56
+
`dune promote`.
57
+
58
+
#### cram-Style Tests
59
+
60
+
The remaining tests are not designed to test the formatting output of
61
+
`ocamlformat`, but rather the command line interface behavior, such as error
62
+
messages and help text.
63
+
64
+
These are found in `test/cli` and are written using
0 commit comments