1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
11 var _ = Suite(&ScriptSuite{})
13 type ScriptSuite struct{}
15 func (s *ScriptSuite) TestExecScript(c *C) {
16 for _, test := range []struct {
21 {[]string{`foo`}, `exec 'foo'`},
22 {[]string{`foo`, `bar baz`}, `exec 'foo' 'bar baz'`},
23 {[]string{`foo"`, "'waz 'qux\n"}, `exec 'foo"' ''\''waz '\''qux` + "\n" + `'`},
25 c.Logf("%+v -> %+v", test.args, test.script)
26 c.Check(execScript(test.args, nil), Equals, "#!/bin/sh\n"+test.script+"\n")
28 c.Check(execScript([]string{"sh", "-c", "echo $foo"}, map[string]string{"foo": "b'ar"}), Equals, "#!/bin/sh\nfoo='b'\\''ar' exec 'sh' '-c' 'echo $foo'\n")