package gitutil import ( "os/exec" "testing" ) // os/exec refuses to start a command that carries a Cancel it did not get from // CommandContext, and the sandbox-wrapped commands in knotserver are exactly // that shape, so containment has to degrade instead of breaking them func TestContainContextlessCommand(t *testing.T) { cmd := Contain(exec.Command("git", "version")) out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("%v: %s", err, out) } if !cmd.SysProcAttr.Setpgid { t.Fatal("a contained command has to lead its own process group") } if cmd.WaitDelay == 0 { t.Fatal("a contained command has to bound its wait") } }