Skip to content

Commit

Permalink
tests for shell
Browse files Browse the repository at this point in the history
  • Loading branch information
seletskiy committed Jun 8, 2016
1 parent 7f19202 commit 5a027b6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ func run(
runner *remoteExecutionRunner,
stdin string,
) error {
debugf(`running command`)

execution, err := runner.run(cluster, nil)
if err != nil {
return hierr.Errorf(
Expand Down
10 changes: 7 additions & 3 deletions remote_execution_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ func wrapCommandIntoShell(command string, shell string, args []string) string {
return command
}

command = strings.Replace(shell, `{}`, command, -1)

if len(args) == 0 {
return command
}

escapedArgs := []string{}
for _, arg := range args {
escapedArgs = append(escapedArgs, escapeCommandArgumentStrict(arg))
}

return strings.Replace(shell, `{}`, command, -1) +
" _ " +
strings.Join(escapedArgs, " ")
return command + " _ " + strings.Join(escapedArgs, " ")
}

func joinCommand(command []string) string {
Expand Down
17 changes: 17 additions & 0 deletions tests/testcases/sync/can-create-run-directory-under-sudo.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tests:put test-file <<EOF
line1
line2
EOF

tests:ensure :orgalorg:with-key -exmn 'true' -S test-file

:check-uploaded-file() {
local container_ip="$2"

# We need ssh there, because of /var/run is a tmpfs and not accessible
# from host.
tests:ensure :ssh "$container_ip" cat "/var/run/orgalorg/*/test-file"
tests:assert-no-diff "test-file" "stdout"
}

containers:do :check-uploaded-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests:put test-file <<EOF
line1
line2
EOF

tests:ensure :orgalorg:with-key -emn 'echo 1:$1 2:$2' \
--args first --args second -r /tmp -S test-file

tests:assert-stdout "1:first 2:second"

0 comments on commit 5a027b6

Please sign in to comment.