Skip to content

Commit 3b5c5dc

Browse files
committed
added a comment
1 parent 75c31cc commit 3b5c5dc

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

ghcide/test/exe/Main.hs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
22
-- SPDX-License-Identifier: Apache-2.0
33

4+
{-
5+
NOTE On enforcing determinism
6+
7+
The tests below use two mechanisms to enforce deterministic LSP sequences:
8+
9+
1. Progress reporting: waitForProgress(Begin|Done)
10+
2. Diagnostics: expectDiagnostics
11+
12+
Either is fine, but diagnostics are generally more reliable.
13+
14+
Mixing them both in the same test is NOT FINE as it will introduce race
15+
conditions since multiple interleavings are possible. In other words,
16+
the sequence of diagnostics and progress reports is not deterministic.
17+
For example:
18+
19+
< do something >
20+
waitForProgressDone
21+
expectDiagnostics [...]
22+
23+
- When the diagnostics arrive after the progress done message, as they usually do, the test will pass
24+
- When the diagnostics arrive before the progress done msg, when on a slow machine occasionally, the test will timeout
25+
26+
Therefore, avoid mixing both progress reports and diagnostics in the same test
27+
-}
28+
429
{-# LANGUAGE AllowAmbiguousTypes #-}
530
{-# LANGUAGE CPP #-}
631
{-# LANGUAGE DataKinds #-}

0 commit comments

Comments
 (0)