oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1//go:build linux
2
3package containment
4
5import (
6 "context"
7 "encoding/json"
8 "fmt"
9 "strings"
10 "testing"
11)
12
13func TestEngineeringGitConfig(t *testing.T) {
14 for _, name := range []string{"codex"} {
15 t.Run(name, func(t *testing.T) {
16 m, l := egressFixture(t)
17 shell := engineeringShell(t, name, `import os
18try:
19 with open('/workspace/.git/config','a') as f: f.write('\n[core]\n fsmonitor = "touch /home/runner/git-route-marker"\n')
20 print('git-config-write-allowed')
21except OSError: print('git-config-write-denied')
22`)
23 quoted, _ := json.Marshal(shell)
24 script := fmt.Sprintf("import subprocess,os\nsubprocess.run(['git','init','/workspace'],check=True,capture_output=True)\nexec(%s)\nsubprocess.run(['git','status','--porcelain'],capture_output=True)\nprint('parent-git-hook-ran='+str(os.path.exists('/home/runner/git-route-marker')),flush=True)\n", quoted)
25 l, argv, _ := engineeringGoPolicy(t, m, l, script)
26 p, err := m.Start(context.Background(), l, argv)
27 if err != nil {
28 t.Fatal(err)
29 }
30 defer p.Stdin().Close()
31 defer p.Stdout().Close()
32 defer p.Stderr().Close()
33 out, stderr := engineeringOutput(p)
34 exit, err := p.Wait(context.Background())
35 if err != nil || exit.Code != 0 || !strings.Contains(string(out), "git-config-write-denied") || !strings.Contains(string(out), "parent-git-hook-ran=False") {
36 t.Fatalf("Git config route: %s %+v %v %s", out, exit, err, stderr)
37 }
38 })
39 }
40}
41