diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-09-29 23:56:37 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-09-30 16:04:48 +0900 |
| commit | b94e6faa9d20dab9b179ee40b5f749c7f13d3f9a (patch) | |
| tree | 519f48fcbf21bd59e1b2384ae977132661f0a324 /cmd/mbf/internal/ci/ci_test.go | |
| parent | d65adbd06033147fa7ffb5c1b919ab4f40e68b83 (diff) | |
cmd/mbf: proof-of-concept CI servicedevelop
This accepts CI work over a shared read-only cache directory. This
replaces the nix CI service and prepares the removal of nix from the
test infrastructure.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/mbf/internal/ci/ci_test.go')
| -rw-r--r-- | cmd/mbf/internal/ci/ci_test.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/cmd/mbf/internal/ci/ci_test.go b/cmd/mbf/internal/ci/ci_test.go new file mode 100644 index 00000000..b5ed134e --- /dev/null +++ b/cmd/mbf/internal/ci/ci_test.go @@ -0,0 +1,55 @@ +package ci_test + +import ( + "bytes" + "context" + "os" + "path/filepath" + "testing" + + "hakurei.app/cmd/mbf/internal/ci" +) + +func TestFollow(t *testing.T) { + t.Parallel() + + pathname := filepath.Join(t.TempDir(), "f") + w, err := os.Create(pathname) + if err != nil { + t.Fatal(err) + } + + var buf bytes.Buffer + ctx, cancel := context.WithCancel(t.Context()) + + var want string + go func() { + defer cancel() + for _, s := range []string{ + "\xde\xad\xbe\xef", + "\xff\xff\xff\xff", + "\x00\x00", + } { + want += s + if _, _err := w.WriteString(s); _err != nil { + panic(_err) + } + } + }() + +retry: + if err = ci.Follow(ctx, pathname, &buf); err != nil { + t.Fatal(err) + } + <-ctx.Done() + + // the inotify event takes time to arrive, and there is no way to + // synchronise for this cleanly + if buf.Len() != len(want) { + goto retry + } + + if got := buf.String(); got != want { + t.Fatalf("follow: %q, want %q", got, want) + } +} |
