package thin import "testing" // A Claude step's shell worked when one of its Bash calls came back // without an error; it had none when it ran Bash and every call failed // (refused, or the sandbox could not start). A step that never ran Bash // had a shell it did not use. func TestShellUse(t *testing.T) { bash := func(id string) []byte { return []byte(`{"type":"assistant","session_id":"s","message":{"content":[{"type":"tool_use","id":"` + id + `","name":"Bash","input":{"command":"go test ./..."}}]}}`) } read := []byte(`{"type":"assistant","session_id":"s","message":{"content":[{"type":"tool_use","id":"r1","name":"Read","input":{"file_path":"/workspace/a"}}]}}`) result := func(id string, failed bool) []byte { e := "false" if failed { e = "true" } return []byte(`{"type":"user","session_id":"s","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"` + id + `","content":"x","is_error":` + e + `}]}}`) } for name, c := range map[string]struct { frames [][]byte none bool }{ "never ran": {[][]byte{read, result("r1", true)}, false}, "all refused": {[][]byte{bash("b1"), result("b1", true), bash("b2"), result("b2", true), read, result("r1", false)}, true}, "one worked": {[][]byte{bash("b1"), result("b1", true), bash("b2"), result("b2", false)}, false}, "no result yet": {[][]byte{bash("b1")}, true}, "another's error": {[][]byte{bash("b1"), result("b1", false), result("zz", true)}, false}, } { var s shellUse for _, f := range c.frames { s.frame(f) } if s.none() != c.none { t.Errorf("%s: none %v, want %v (%+v)", name, s.none(), c.none, s) } } }