vm: improve error message for (*executor).checkError

It is helpful if something goes wrong.
This commit is contained in:
Anna Shaleva 2021-11-29 11:09:39 +03:00
parent 7c48177bf7
commit 6cdb701a9d

View file

@ -104,7 +104,8 @@ func (e *executor) checkNextLine(t *testing.T, expected string) {
func (e *executor) checkError(t *testing.T, expectedErr error) {
line, err := e.out.ReadString('\n')
require.NoError(t, err)
require.True(t, strings.HasPrefix(line, "Error: "+expectedErr.Error()))
expected := "Error: " + expectedErr.Error()
require.True(t, strings.HasPrefix(line, expected), fmt.Errorf("expected `%s`, got `%s`", expected, line))
}
func (e *executor) checkStack(t *testing.T, items ...interface{}) {