Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sed script to help with updating the damlc ITs #7727

Merged
merged 1 commit into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add sed script to help with updating the damlc ITs
Updating the expected dignostics for `damlc`'s integration tests can
be quite tedious. This PR adds a `sed` script to simplify it a bit.
See the included readme for details.

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
hurryabit committed Oct 16, 2020
commit 59e16318ef2b563e7b196550a1971d80a535edc3
24 changes: 24 additions & 0 deletions compiler/damlc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ work via `bazel run`. For testing, install the SDK with
`daml-sdk-head` and then use `daml-head damlc`.


## Updating expected diagnostics in the damlc integration tests

Most of the `.daml` files in `tests/daml-test-files` contain comments of the
form
```haskell
-- @WARN range=1:1-1:10; Something to warn about
```
These comments specify the diagnostics we expect when compiling the file.
Sometimes these expectations change for various reasons and updating the
comments can be quite tedious, particularly when there are many of them.
You can extract the comments reflecting the updated expectations from the
compiler output by copying the output into the clipboard and running
```sh
# On MacOS
pbpaste | sed -n -r -f compiler/damlc/tests/extract-diagnostics.sed

# On Linux
xclip -out -selection clipboard | sed -n -r -f compiler/damlc/tests/extract-diagnostics.sed
```
If a test case in the `damlc` intgration tests fails, it will print the
compiler output. Alternative, you can run `damlc` as described above to get
the output.


## Updating daml-doc's golden tests

Run
Expand Down
21 changes: 21 additions & 0 deletions compiler/damlc/tests/extract-diagnostics.sed
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/Range:/ {
s/^ *Range: */range=/
s/$/;/
h
}
/Severity:/ {
s/^ *Severity: *Ds//
s/Warning/Warn/
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
s/^/-- @/
G
h
}
/Message:/ {
n
s/^ *//
H
g
s/\n/ /g
p
}