delve/pkg/terminal/terminal_test.go
Alessandro Arzilli 13ad7dc1d5
*: misc improvements to config command and substitute-path rules (#3335)
A series of interconnected changes to both the terminal command
'config', DAP command 'dlv config', quality of life improvements to how
substitute-path works, and better documentation.

- Let 'config substitute-path' show the current substitute path rules
- Add a -clear command to 'config substitute-path'
- Support 'config-debug-info-directories'
- rewrite SubstitutePath to be platform independent (see below)
- document path substitution more

Regarding the rewrite of SubstitutePath: the previous version used
runtime.GOOS and filepath.IsAbs to determine which filepath separator to use
and if matching should be case insensitive. This is wrong in all situations
where the client and server run on different OSes, when examining core files
and when cross-compilation is involved.

The new version of SubstitutePath checks the rules and the input path to
determine if Windows is involved in the process, if it looks like it is it
switches to case-insensitive matching. It uses a lax version of
filepath.IsAbs to determine if a path is absolute and tries to avoid having
to select a path separator as much as possible

Fixes #2891, #2890, #2889, #3179, #3332, #3343
2023-05-02 12:23:59 -07:00

26 lines
620 B
Go

package terminal
import (
"errors"
"net/rpc"
"testing"
)
func TestIsErrProcessExited(t *testing.T) {
tests := []struct {
name string
err error
result bool
}{
{"empty error", errors.New(""), false},
{"non-ServerError", errors.New("Process 33122 has exited with status 0"), false},
{"ServerError with zero status", rpc.ServerError("Process 33122 has exited with status 0"), true},
{"ServerError with non-zero status", rpc.ServerError("Process 2 has exited with status 25"), true},
}
for _, test := range tests {
if isErrProcessExited(test.err) != test.result {
t.Error(test.name)
}
}
}