summaryrefslogtreecommitdiff
path: root/utils/check-exact/README
blob: 07a7f26ed9b4daec68bedb49a9f78ba2ca10802b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

This programme is intended to be used by any GHC developers working on
the AST and/or pretty printer by providing a way to check that using
exact print on the ParsedSource reproduces the original source.
Except for stripping trailing whitespace on lines, and discarding
tabs.

This utility is also intended to be used in tests, so that when new features are
added the ability to round-trip the AST via exact is tested.

Usage

In a test Makefile

  $(CHECK_EXACT) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" FileToParse.hs

AZ: update the rest here
See examples in (REPO_HOME)/testsuite/tests/printer/Makefile

The utility generates the following files for ToBeTested.hs

  - ToBeTested.ppr.hs      : the ppr result
  - ToBeTested.hs.ast      : the AST of the original source
  - ToBeTested.hs.ast.new  : the AST of the re-parsed ppr source

For local development/testing
-----------------------------

From this directory, start a ghci session by

../../_build/stage1/bin/ghc --interactive

Update Main.hs. the _tt function to firstly have the full local path
of the _build/stage1/lib directory, and secondly to be cofigured to
run the test of interest, by adding a new line to the many already
there or commenting in the one (only) to be tested.

ghci> :l Main.hs
ghci> _tt
*** Exception: ExitSuccess

Note: GHC may complain about missing modules, etc, this is not a
problem, the test passes if it gives ExitSuccess at the end.

Logging can be turned on by flipping the comments in Utils.hs

debugEnabledFlag = True
-- debugEnabledFlag = False