MCPcopy Index your code
hub / github.com/coder/coder / TestParse_ParseError

Function TestParse_ParseError

coderd/util/shellparse/shellparse_test.go:142–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

140}
141
142func TestParse_ParseError(t *testing.T) {
143 t.Parallel()
144
145 t.Run("unterminated-string-no-results", func(t *testing.T) {
146 t.Parallel()
147 cmds, err := shellparse.Parse(`echo "unterminated`)
148 require.Error(t, err)
149 require.Nil(t, cmds)
150 })
151
152 t.Run("semicolon-prefix-yields-partial-results-plus-error", func(t *testing.T) {
153 t.Parallel()
154 // Some malformed inputs (e.g. trailing unterminated tokens after
155 // valid semicolon-separated commands) yield partial results
156 // alongside a non-nil error. Pin both sides of the contract so
157 // future mvdan.cc/sh upgrades that change partial-parse behavior
158 // fail this test loudly.
159 cmds, err := shellparse.Parse(`ls; cat; echo "unterminated`)
160 require.Error(t, err)
161 require.Equal(t, [][]string{{"ls"}, {"cat"}}, cmds)
162 })
163}

Callers

nothing calls this directly

Calls 4

ParseFunction · 0.92
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected