Download this file
| 1 | package opencode |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "testing" |
| 7 | |
| 8 | "amadan.net/oficina/equipo/internal/fakeopencode" |
| 9 | "amadan.net/oficina/equipo/internal/runner/containment" |
| 10 | "amadan.net/rastrillo/rastrillo/budget" |
| 11 | ) |
| 12 | |
| 13 | // TestMain is also the namespace helper, the fake OpenCode (started as |
| 14 | // the binary, opencode) and the tool proxy: the tests run them from |
| 15 | // copies of this binary. |
| 16 | func TestMain(m *testing.M) { |
| 17 | switch filepath.Base(os.Args[0]) { |
| 18 | case "opencode": |
| 19 | os.Exit(fakeopencode.Main(os.Args[1:], os.Stdin, os.Stdout, os.Stderr)) |
| 20 | case "equipo-tool-proxy": |
| 21 | os.Exit(serveToolProxy(os.Args)) |
| 22 | } |
| 23 | if len(os.Args) > 1 && os.Args[1] == "__namespace" { |
| 24 | os.Exit(containment.NamespaceMain(os.Args[2:])) |
| 25 | } |
| 26 | os.Exit(budget.Main(m)) |
| 27 | } |
| 28 | |