oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package runnerproto_test
2
3import (
4 "amadan.net/oficina/equipo/internal/runner/provider"
5 "amadan.net/oficina/equipo/internal/testci"
6 "os"
7 "os/exec"
8 "path/filepath"
9 "strings"
10 "testing"
11)
12
13func TestDirectBinaryBoundaries(t *testing.T) {
14 for _, pkg := range []string{".", "../../cmd/equipo-runner"} {
15 list := exec.Command("go", "list", "-deps", pkg)
16 testci.GoCommand(t, list)
17 raw, err := list.CombinedOutput()
18 if err != nil {
19 t.Fatal(err)
20 }
21 if strings.Contains(string(raw), "/internal/directlive") || pkg == "." && strings.Contains(string(raw), "/provider/codex") {
22 t.Fatal("production binary links adapter/certification worker", pkg)
23 }
24 }
25}
26func TestCheckPolicyNoRedundantRunner(t *testing.T) {
27 p, err := provider.BuildCheckPolicy(provider.CheckPolicyInputs{Workspace: t.TempDir(), GoRoot: t.TempDir(), ModuleCache: t.TempDir(), Binary: "/usr/bin/true", RunnerBinary: "/usr/bin/true", Bwrap: "/usr/bin/bwrap", Argv: []string{"/opt/codex"}})
28 if err != nil {
29 t.Fatal(err)
30 }
31 for _, m := range p.Mounts {
32 if m.Target == "/opt/equipo-runner" {
33 t.Fatal("unused runner mount retained")
34 }
35 }
36}
37
38func TestRunnerPrerequisitesDoNotExecuteCodex(t *testing.T) {
39 root := t.TempDir()
40 marker := filepath.Join(root, "executed")
41 binary := filepath.Join(root, "codex")
42 if err := os.WriteFile(binary, []byte("#!/bin/sh\ntouch '"+marker+"'\necho 'codex-cli 0.165.0'\n"), 0700); err != nil {
43 t.Fatal(err)
44 }
45 cmd := exec.Command("make", "-C", "../..", "runner-prerequisites")
46 cmd.Env = append(os.Environ(), "EQUIPO_CODEX_PATH="+binary)
47 testci.Files(t, "../../Makefile", "../../scripts/runner-prerequisites.py")
48 _, err := cmd.CombinedOutput()
49 if _, stat := os.Stat(marker); stat == nil {
50 t.Fatal("CI executed a provider binary")
51 }
52 if err == nil {
53 t.Fatal("unrecognized binary accepted")
54 }
55}
56