Skip to content

Commit 8483c7b

Browse files
committed
add event log
1 parent 66dc235 commit 8483c7b

File tree

3 files changed

+129
-4
lines changed

3 files changed

+129
-4
lines changed

scripts/eventlog-dump.fish

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/usr/bin/env fish
2+
3+
# Dump a GHC RTS .eventlog to a plain-text file using the ghc-events CLI.
4+
# Usage:
5+
# scripts/eventlog-dump.fish <file.eventlog> [output.txt] [starts_with_prefix] [contains_substring]
6+
#
7+
# Notes:
8+
# - Attempts to find ghc-events in PATH, ~/.cabal/bin, or ~/.local/bin.
9+
# - If not found, will try: cabal install ghc-events
10+
# - Output defaults to <basename>.events.txt in the current directory.
11+
12+
function usage
13+
echo "Usage: (basename (status filename)) <file.eventlog> [output.txt] [starts_with_prefix] [contains_substring]"
14+
exit 2
15+
end
16+
17+
if test (count $argv) -lt 1
18+
usage
19+
end
20+
21+
set evlog $argv[1]
22+
if not test -f $evlog
23+
echo "error: file not found: $evlog" >&2
24+
exit 1
25+
end
26+
27+
if test (count $argv) -ge 2
28+
set out $argv[2]
29+
else
30+
set base (basename $evlog)
31+
if string match -q '*\.eventlog' $base
32+
set out (string replace -r '\\.eventlog$' '.events.txt' -- $base)
33+
else
34+
set out "$base.events.txt"
35+
end
36+
end
37+
38+
# Optional prefix filter: only keep lines that start with this string
39+
set filter_prefix ""
40+
if test (count $argv) -ge 3
41+
set filter_prefix $argv[3]
42+
end
43+
44+
# Optional contains filter: only keep lines that contain this substring (applied after prefix filter if both provided)
45+
set filter_contains ""
46+
if test (count $argv) -ge 4
47+
set filter_contains $argv[4]
48+
end
49+
50+
function find_ghc_events --description "echo absolute path to ghc-events or empty"
51+
if command -sq ghc-events
52+
command -s ghc-events
53+
return 0
54+
end
55+
if test -x ~/.cabal/bin/ghc-events
56+
echo ~/.cabal/bin/ghc-events
57+
return 0
58+
end
59+
if test -x ~/.local/bin/ghc-events
60+
echo ~/.local/bin/ghc-events
61+
return 0
62+
end
63+
return 1
64+
end
65+
66+
set ghc_events_bin (find_ghc_events)
67+
68+
if test -z "$ghc_events_bin"
69+
echo "ghc-events not found; attempting to install via 'cabal install ghc-events'..." >&2
70+
if not command -sq cabal
71+
echo "error: cabal not found; please install ghc-events manually (e.g., via cabal)." >&2
72+
exit 1
73+
end
74+
cabal install ghc-events
75+
set ghc_events_bin (find_ghc_events)
76+
if test -z "$ghc_events_bin"
77+
echo "error: ghc-events still not found after installation." >&2
78+
exit 1
79+
end
80+
end
81+
82+
echo "Dumping events from $evlog to $out..."
83+
set -l stream_cmd "$ghc_events_bin show $evlog"
84+
85+
if test -n "$filter_prefix" -o -n "$filter_contains"
86+
# Stream through filters
87+
eval $stream_cmd | while read -l line
88+
set -l keep 1
89+
if test -n "$filter_prefix"
90+
if not string match -q -- "$filter_prefix*" -- $line
91+
set keep 0
92+
end
93+
end
94+
if test $keep -eq 1 -a -n "$filter_contains"
95+
if not string match -q -- "*$filter_contains*" -- $line
96+
set keep 0
97+
end
98+
end
99+
if test $keep -eq 1
100+
echo $line
101+
end
102+
end > $out
103+
else
104+
eval $stream_cmd > $out
105+
end
106+
set exit_code $status
107+
108+
if test $exit_code -ne 0
109+
echo "error: dump failed with exit code $exit_code" >&2
110+
exit $exit_code
111+
end
112+
113+
set -l size ""
114+
if command -sq stat
115+
# macOS stat prints size with -f%z; suppress errors if not supported
116+
set size (stat -f%z $out 2>/dev/null)
117+
end
118+
if test -z "$size"
119+
set size (wc -c < $out)
120+
end
121+
122+
echo "Wrote $out ($size bytes)."

scripts/flaky-test-loop.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ while true; do
161161
HLS_TEST_HARNESS_STDERR="${LOG_STDERR}" \
162162
TASTY_NUM_THREADS=1 \
163163
TASTY_PATTERN="${pattern}" \
164-
"$(get_bin_path "${bin_name}")" >"${log}" 2>&1
164+
"$(get_bin_path "${bin_name}")" +RTS -l -olhlint.eventlog -RTS >"${log}" 2>&1
165165
set -e
166166

167167
if grep -aFiq -- "${BROKEN_PIPE_RE}" "${log}"; then
@@ -170,7 +170,7 @@ while true; do
170170
echo "[loop] --- Tail (last 60 lines) ---" >&2
171171
tail -n 60 "${log}" >&2
172172
exit 1
173-
elif grep -aEqi -- "${TEST_FAILED_RE}" "${log}"; then
173+
elif grep -aEq -- "${TEST_FAILED_RE}" "${log}"; then
174174
echo "[loop] Test failure detected in iteration ${iter} for pattern '${pattern}'. Stopping." | tee -a "${log}" >&2
175175
echo "[loop] Log file: ${log} (abs: $(pwd)/${log})" | tee -a "${log}" >&2
176176
echo "[loop] --- Tail (last 60 lines) ---" >&2

scripts/flaky-test-patterns.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# One tasty pattern per line. Lines starting with # are comments.
22
# Blank lines are ignored.
33

4-
open close
4+
# open close
55
# non local variable
66
# Notification Handlers
77
# bidirectional module dependency with hs-boot
@@ -14,4 +14,7 @@ open close
1414
# hls-pragmas-plugin-tests::/inline: RULES/
1515

1616
# hls-graph cancel leaks asynchronous exception to the next session
17-
hls-hlint-plugin-tests::adding hlint flags to plugin configuration removes hlint diagnostics
17+
# hls-hlint-plugin-tests::adding hlint flags to plugin configuration removes hlint diagnostics
18+
# hls-explicit-imports-plugin-tests::ExplicitUsualCase inlay hints with client caps
19+
# hls-class-plugin-tests::Creates a placeholder for fmap
20+
hls-rename-plugin-tests::Rename

0 commit comments

Comments
 (0)