Skip to content

Commit e84b10e

Browse files
committed
Add golden tests for create-message-template
1 parent fb7264a commit e84b10e

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ Pull requests that make it easier to understand or navigate are very
6969
welcome. The main generator `site.hs` is formatted using
7070
[Ormolu](https://github.com/tweag/ormolu).
7171

72+
Finally, if you want to work on the scaffolding tool, it has a simplistic test script at
73+
`test/create-message-template/test.sh`.
74+
7275
## Reference: The Anatomy of a Message
7376

7477
The Haskell Message Index is generated from a collection of files on
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
This tool helps you create the scaffolding for a new error message on the error-message-index.
2+
You can leave any of the text fields blank and fill them in by hand later.
3+
4+
· Which tool's error code do you want to document?
5+
1) GHC
6+
2) GHCup
7+
3) Stack
8+
Input (Default = GHC):
9+
· What is the numeric code that you want to document?
10+
For example, enter "01234" if you want to document GHC-01234.
11+
Input:
12+
· What is the title of the error message?
13+
This is used as the title of the documentation page as well as in links to the page.
14+
Input:
15+
· Give a short summary of the error message.
16+
This appears on the overview page that lists all the documented errors and warnings.
17+
Input:
18+
· What is the severity of the diagnostic?
19+
1) Error
20+
2) Warning
21+
Input (Default = Error):
22+
23+
· Which version of the tool emitted the numeric code (not the message) for the first time?
24+
Note: For GHC this is most likely 9.6.1.
25+
Input:
26+
· How many examples should be generated?
27+
Input:
28+
· Give a name for example 1
29+
The name should not contain spaces and begin with a lowercase letter.
30+
Input:
31+
· Give a name for example 2
32+
The name should not contain spaces and begin with a lowercase letter.
33+
Input:
34+
· Creating scaffolding...
35+
·· Created file messages/GHC-101010/index.md with these contents:
36+
37+
---
38+
title: My Title
39+
summary: My summary which has a few words
40+
severity: error
41+
introduced: 9.6.1
42+
---
43+
44+
Insert your error message here.
45+
·· Creating blank example in directory messages/GHC-101010/stunning-example...
46+
·· Creating blank example in directory messages/GHC-101010/sublime-example...
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
101010
3+
My Title
4+
My summary which has a few words
5+
6+
9.6.1
7+
2
8+
stunning-example
9+
sublime-example

test/create-message-template/test.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
cd "$(dirname $0)"
6+
trap "rm -rf golden*.output.txt messages" EXIT
7+
8+
result=true
9+
10+
for input in golden*.input.txt; do
11+
output="$(basename -s .input.txt "$input").output.txt"
12+
golden="$(basename -s .input.txt "$input").expected.txt"
13+
runghc ../../message-index/create-message-template.hs < "$input" > "$output"
14+
if [ ! -e "$golden" ]; then
15+
cp "$output" "$golden"
16+
echo "$golden created."
17+
else
18+
if diff -u "$golden" "$output"
19+
then
20+
echo "$golden ok."
21+
else
22+
result=false
23+
echo "$golden failed."
24+
fi
25+
fi
26+
done
27+
28+
$result

0 commit comments

Comments
 (0)