diff --git a/commands/attach.go b/commands/attach.go index 3cb503e..8313f21 100644 --- a/commands/attach.go +++ b/commands/attach.go @@ -22,8 +22,9 @@ func (command *Attach) Execute(maybeHandle []string) error { }) failIf(err) - _, err = process.Wait() + status, err := process.Wait() failIf(err) + os.Exit(status) return nil } diff --git a/test/attach.bats b/test/attach.bats new file mode 100755 index 0000000..367d2ae --- /dev/null +++ b/test/attach.bats @@ -0,0 +1,14 @@ +#!/usr/bin/env bats + +load test_helper + +@test "it returns exit code from attach" { + handle=$(gaol create) + assert_success + + process_id=$(gaol run -c 'sh -c "sleep 1; exit 42"' $handle) + assert_success + + run gaol attach $handle -p $process_id + assert_equal $status 42 +} diff --git a/test/create.bats b/test/create.bats index 1e2dff1..6c8e174 100755 --- a/test/create.bats +++ b/test/create.bats @@ -24,7 +24,7 @@ load test_helper } @test "a created container bind mount is read-write by default" { - handle=$(gaol create -m .:/tmp/cmnt) + handle=$(gaol create -m /bin:/tmp/cmnt) assert_success run gaol run -a -c "/bin/sh -c 'cat /proc/self/mounts | grep /tmp/cmnt'" $handle @@ -34,7 +34,7 @@ load test_helper } @test "a created container can have read-only bind mounts" { - handle=$(gaol create -m .:/tmp/cmnt:ro) + handle=$(gaol create -m /bin:/tmp/cmnt:ro) assert_success run gaol run -a -c "/bin/sh -c 'cat /proc/self/mounts | grep /tmp/cmnt'" $handle @@ -45,7 +45,7 @@ load test_helper @test "a created container can have explicit read-write bind mounts" { - handle=$(gaol create -m .:/tmp/cmnt:rw) + handle=$(gaol create -m /bin:/tmp/cmnt:rw) assert_success run gaol run -a -c "/bin/sh -c 'cat /proc/self/mounts | grep /tmp/cmnt'" $handle