os/signal: TestTerminalSignal is flaky due to GNU readline #55903
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Testing
An issue that has been verified to require only test changes, not just a test failure.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have
~/.inputrc
with this content:And run the test on tip:
Note: I don't find an easy way to disable the test cache. I ended up add
"-v", "-count=1"
toargs
(the-v
option helps revealing the abnormal behavior of the GNU readline library in the later section):go/src/cmd/dist/test.go
Lines 402 to 407 in a48fc81
What did you expect to see?
The tests pass.
What did you see instead?
What's wrong?
Now remove
~/.inputrc
and rungotip tool dist test go_test:os/signal
(which./run.bash
calls):=== CONT TestTerminalSignal signal_cgo_test.go:145: "PS1='prompt> '\r\n" signal_cgo_test.go:145: "bash-5.1$ PS1='prompt> '\r\n" - signal_cgo_test.go:145: "prompt> \r<49327/b001/signal.test -test.run=TestTerminalSignal\r\n" signal_cgo_test.go:145: "test program entering read\r\n" signal_cgo_test.go:145: "^Z\r\n" signal_cgo_test.go:145: "[1]+ Stopped GO_TEST_TERMINAL_SIGNALS=1 /tmp/go-build2200749327/b001/signal.test -test.run=TestTerminalSignal\r\n" signal_cgo_test.go:145: "prompt> fg\r\n" signal_cgo_test.go:145: "GO_TEST_TERMINAL_SIGNALS=1 /tmp/go-build2200749327/b001/signal.test -test.run=TestTerminalSignal\r\n" signal_cgo_test.go:145: "\r\n" signal_cgo_test.go:145: "read newline\r\n" signal_cgo_test.go:145: "prompt> exit $?\r\n" signal_cgo_test.go:145: "exit\r\n" --- PASS: TestTerminalSignal (0.13s)
Comparing to the output of
gotip test ./os/signal -v -count 1 -run ^TestTerminalSignal$
:=== CONT TestTerminalSignal signal_cgo_test.go:145: "PS1='prompt> '\r\n" signal_cgo_test.go:145: "\x1b[?2004hbash-5.1$ PS1='prompt> '\r\n" + signal_cgo_test.go:145: "\x1b[?2004l\r\x1b[?2004hprompt> GO_TEST_TERMINAL_SIGNALS=1 /tmp/go-build1103848064/b001/signal.test -test.run=TestTerminalSignal\r\n" signal_cgo_test.go:145: "\x1b[?2004l\rtest program entering read\r\n" signal_cgo_test.go:145: "^Z\r\n" signal_cgo_test.go:145: "[1]+ Stopped GO_TEST_TERMINAL_SIGNALS=1 /tmp/go-build1103848064/b001/signal.test -test.run=TestTerminalSignal\r\n" signal_cgo_test.go:145: "\x1b[?2004hprompt> fg\r\n" signal_cgo_test.go:145: "\x1b[?2004l\rGO_TEST_TERMINAL_SIGNALS=1 /tmp/go-build1103848064/b001/signal.test -test.run=TestTerminalSignal\r\n" signal_cgo_test.go:145: "\r\n" signal_cgo_test.go:145: "read newline\r\n" signal_cgo_test.go:145: "\x1b[?2004hprompt> exit $?\r\n" signal_cgo_test.go:145: "\x1b[?2004l\rexit\r\n" --- PASS: TestTerminalSignal (0.12s)
Even though both tests passed, the first one has shown something abnormal (see the highlighted lines in the output). Since
go tool dist test
does not pass-v
togo test
, we haven't noticed that. And when a special~/.inputrc
file is used, the abnormal behavior of readline finally fails the test.I still don't understand why the GNU readline library works correctly when
TestTerminalSignal
is run bygo test
directly, but behaves abnormally whengo test
is called bygo tool dist test
. But the fix is easy, we just need to disable it with the bash option--noediting
. CL coming soon.The text was updated successfully, but these errors were encountered: