Skip to content

Commit 11ae76e

Browse files
authored
Merge pull request #3704 from lwm/contrib-docs
Add testing notes to CONTRIBUTING.md + some tidbits
2 parents 1fd0850 + 0ed202d commit 11ae76e

File tree

1 file changed

+77
-7
lines changed

1 file changed

+77
-7
lines changed

CONTRIBUTING.md

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and use the provided template to include all necessary details.
88
The more detailed your report, the faster it can be resolved and will ensure it
99
is resolved in the right way. Once your bug has been resolved, the responsible
1010
person will tag the issue as _Needs confirmation_ and assign the issue back to
11-
you. Once you have tested and confirmed that the issue is resolved, close the
11+
you. Once you have tested and confirmed that the issue is resolved, close the
1212
issue. If you are not a member of the project, you will be asked for
1313
confirmation and we will close it.
1414

@@ -19,14 +19,12 @@ If you would like to help with documentation, please note that for most cases
1919
the Wiki has been deprecated in favor of markdown files placed in a new `/doc`
2020
subdirectory of the repository itself. Please submit a
2121
[pull request](https://help.github.com/articles/using-pull-requests/) with your
22-
changes/additions.
22+
changes/additions based off the [the stable branch](https://github.com/commercialhaskell/stack/tree/stable).
2323

2424
The documentation is rendered on [haskellstack.org](http://haskellstack.org) by
2525
readthedocs.org using Sphinx and CommonMark. Since links and formatting vary
2626
from GFM, please check the documentation there before submitting a PR to fix
27-
those. In particular, links to other documentation files intentionally have
28-
`.html` extensions instead of `.md`, unfortunately (see
29-
[#1506](https://github.com/commercialhaskell/stack/issues/1506) for details).
27+
those.
3028

3129
If your changes move or rename files, or subsume Wiki content, please continue
3230
to leave a file/page in the old location temporarily, in addition to the new
@@ -85,7 +83,79 @@ stack install hlint
8583
Once installed, you can check your changes with:
8684

8785
```
88-
hlint src/ test/ --cpp-simple
86+
$ ./etc/scripts/hlint.sh
8987
```
9088

91-
Where `--cpp-simple` strips `#` lines.
89+
## Testing
90+
91+
The Stack code has both unit tests and integration tests. Integration tests can
92+
be found in the [test/integration](https://github.com/commercialhaskell/stack/tree/master/test/integration)
93+
folder and unit tests, in the [src/test](https://github.com/commercialhaskell/stack/tree/master/src/test)
94+
folder. Tests are written using the [Hspec](https://hspec.github.io/) framework. In
95+
order to run the full test suite, you can simply do:
96+
97+
```bash
98+
$ stack test
99+
```
100+
101+
The `--file-watch` is a very useful option to get quick feedback. However,
102+
running the entire test suite after each file change will slow you down. You'll
103+
need to specify which test suite (unit test or integration) and pass arguments
104+
to specify which module you'd specifically like to run to get quick feedback. A
105+
description of this follows below.
106+
107+
### Working with Unit Tests
108+
109+
If you would like to run the unit tests on their own, you can:
110+
111+
```bash
112+
$ stack test stack:stack-test
113+
```
114+
115+
Running an individual module works like this:
116+
117+
```bash
118+
$ stack test stack:stack-test --ta "-m <PATTERN>"
119+
```
120+
121+
Where `<PATTERN>` is the name of the module without `Spec.hs`.
122+
123+
You may also load tests into GHCi and run them with:
124+
125+
```bash
126+
$ stack ghci stack:stack-test --only-main
127+
# GHCi starting up output ...
128+
> :main -m "<PATTERN>"
129+
```
130+
131+
Where again, `<PATTERN>` is the name of the module without `Spec.hs`.
132+
133+
### Working with Integration Tests
134+
135+
Running the integration tests is a little involved, you'll need to:
136+
137+
```bash
138+
$ stack test stack:integration-test --flag stack:stack-integration-tests
139+
```
140+
141+
Running an individual module works like this:
142+
143+
```bash
144+
$ stack test stack:stack-integration-test --flag stack:integration-tests --ta "-m <PATTERN>"
145+
```
146+
147+
Where `<PATTERN>` is the name of the folder listed in the
148+
[test/integration/tests/](https://github.com/commercialhaskell/stack/tree/master/test/integration/tests)
149+
folder.
150+
151+
You may also achieve this through GHCi with:
152+
153+
```bash
154+
$ stack ghci stack:stack-integration-test
155+
# GHCi starting up output ...
156+
> :main -m "<PATTERN>"
157+
```
158+
159+
Where again, `<PATTERN>` is the name of the folder listed in the
160+
[test/integration/tests/](https://github.com/commercialhaskell/stack/tree/master/test/integration/tests)
161+
folder.

0 commit comments

Comments
 (0)