3## Running tests using bin/test.sh
5`bin/test.sh` (path relative to the top level repo dir) can run selected
6test groups, generate coverage report, pass GHC RTS options when
7running tests. `test.sh` runs the tests with restricted memory, see
8`bin/test.sh` source for details on the amount of memory used or to change it.
10To generate coverage report:
13$ bin/test.sh --coverage
16To view coverage report, open `./hpc_index.html` in browser.
18See `bin/test.sh --help` for more info.
20## Building and Running Tests using cabal
22### Build a single test
25$ cabal build test:Prelude.Serial
31$ cd test; cabal build Prelude.Serial
34Build with optimizations:
37$ cabal build --flag opt ...
43$ cabal build --enable-tests all
49$ cd test; cabal build --enable-tests
52Or this, note this command does not work as expected when in the "test" dir:
55$ cabal build --enable-tests streamly-tests
60Running all test suites, use any of the following:
72Or this, note this command does not work as expected when in the "test" dir:
75$ cabal test streamly-tests
78### Build and Run a single test suite
80To run `Prelude.Serial` test-suite:
83$ cabal run test:Prelude.Serial
89$ cd test; cabal run Prelude.Serial
92Note you could use `cabal test Prelude.Serial` but that unfortunately builds
93all the test suites before running `Prelude.Serial`.
97* The test named `doctest` runs all the code snippets in a source module
98 that are written using the `>>>` markup in haddock. See `doctest.hs`.
99* Make sure you do not enclose your snippets in the `@ .. @` markup otherwise
100 they will show up verbatim in the docs and not as ghci styled snippets.
101* We use `--fast` mode of doctest, which means snippets are run as if you are
102 typing those examples from top to bottom in that order in GHCi. Previous
103 snippet's state is available to the next one.
104* A haddock section named `$setup` contains a snippet that is always run before
105 any other. When `--fast` mode is not used it is run before every snippet.
107An example setup section:
112-- >>> import Control.Monad.IO.Class (MonadIO(..))
113-- >>> import Data.Function ((&))
116Some tests that may take long can be written as follows. Just assigning
117the code to a function makes it compile but not run.
122 Stream.drain $ Stream.fromAsync $ foldMap delay [1..10]
123 Stream.drain $ Stream.concatFoldableWith Stream.async (map delay [1..10])
124 Stream.drain $ Stream.concatMapFoldableWith Stream.async delay [1..10]
125 Stream.drain $ Stream.concatForFoldableWith Stream.async [1..10] delay
131Run tests for all modules:
134$ cabal run doctests --flag doctests
137Use verbose mode to debug:
140$ cabal run doctests --flag doctests -- --verbose
143Run tests only for selected modules:
146$ cabal run doctests --flag doctests -- --modules Streamly.Prelude
149If it fails with a message that a particular modules is not loaded specify that
150module as well on the command line.
152## Naming of test modules
154Tests are organized by source modules. For example, for the source
155module `Streamly.Data.Array` and `Streamly.Internal.Data.Array` we have
156a test module `Data.Array`. For some modules tests for a source module
157are broken into multiple modules. For example, for `Streamly.Prelude` we have
158`Streamly.Prelude.Serial`, `Streamly.Prelude.Async` etc.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list