From 65e03d673d31f9a6c9c2bd187a4ff2219444b16f Mon Sep 17 00:00:00 2001 From: polinasok <51177946+polinasok@users.noreply.github.com> Date: Tue, 29 Mar 2022 11:01:04 -0700 Subject: [PATCH] dlv_test: fix TestChildProcessExitWhenNoDebugInfo to actually test strip binary (#2949) Co-authored-by: Polina Sokolova --- cmd/dlv/dlv_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/dlv/dlv_test.go b/cmd/dlv/dlv_test.go index 1533906d..9a5e670a 100644 --- a/cmd/dlv/dlv_test.go +++ b/cmd/dlv/dlv_test.go @@ -295,9 +295,15 @@ func TestChildProcessExitWhenNoDebugInfo(t *testing.T) { fix := protest.BuildFixture("http_server", protest.LinkStrip) // dlv exec the binary file and expect error. - if _, err := exec.Command(dlvbin, "exec", fix.Path).CombinedOutput(); err == nil { + out, err := exec.Command(dlvbin, "exec", "--headless", "--log", fix.Path).CombinedOutput() + t.Log(string(out)) + if err == nil { t.Fatalf("Expected err when launching the binary without debug info, but got nil") } + // Test only for dlv's prefix of the error like "could not launch process: could not open debug info" + if !strings.Contains(string(out), "could not launch process") { + t.Fatalf("Expected logged error 'could not launch process: ...'") + } // search the running process named fix.Name cmd := exec.Command("ps", "-aux")