Task 02 (the whole runner) ended at 21:08 with no file and no commit: Ornith wrote the
implementation out in its reply (~700 lines), OpenCode compacted the session, and the model
then emitted a malformed tool call. It had also looked for the given test at a wrong path
("_files/…" relative to the plan: my ambiguity).
- 02-runner → 02-runner-core (types, Submit, Status, Touch, Cancel; no goroutines) and
03-runner-workers; the given test split to match (runner_core_test.go gains three tests:
queued storage, cancel while queued, Status never moves the lease); later tasks renumbered
04-09 and every cross-reference checked.
- Copy paths spelled from the repo root.
- guard.PreCheck (+ its test) is committed here by the owner: the old task 05 told the
implementer to edit internal/guard/, which AGENTS.md forbids. My contradiction.
- AGENTS.md rule 6: write code into files early, in small steps.
Both runner test files compile against a panic-only skeleton (the core file also alone) and
fail there on panic: todo.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package config
|
|
|
|
// P6 task 08: the [batch] block and ParseSize.
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestBatchBlock(t *testing.T) {
|
|
p := filepath.Join(t.TempDir(), "sift.toml")
|
|
body := "[batch]\ndisabled = false\ntargets_per_job = 16\njobs_per_caller = 2\njobs_total = 4\nworkers = 2\nttl = \"12h\"\nmax_bytes = \"32MiB\"\n"
|
|
if err := os.WriteFile(p, []byte(body), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
f, err := Load(p)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
b := f.Batch
|
|
if b.Disabled || b.TargetsPerJob != 16 || b.JobsPerCaller != 2 || b.JobsTotal != 4 || b.Workers != 2 || b.TTL != "12h" || b.MaxBytes != "32MiB" {
|
|
t.Fatalf("batch block %+v", b)
|
|
}
|
|
// No block: zero values, and batch is on (the runner applies its own defaults).
|
|
empty := filepath.Join(t.TempDir(), "empty.toml")
|
|
if err := os.WriteFile(empty, []byte("listen = \":8443\"\n"), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if f, err := Load(empty); err != nil || f.Batch != (Batch{}) {
|
|
t.Fatalf("no [batch] block: %+v %v", f.Batch, err)
|
|
}
|
|
}
|
|
|
|
func TestParseSize(t *testing.T) {
|
|
const def = 7
|
|
for _, c := range []struct {
|
|
in string
|
|
want int64
|
|
}{
|
|
{"64MiB", 64 << 20},
|
|
{"512KiB", 512 << 10},
|
|
{"1GiB", 1 << 30},
|
|
{"1000", 1000},
|
|
{" 2MiB ", 2 << 20},
|
|
{"", def},
|
|
{"junk", def},
|
|
{"-1MiB", def},
|
|
{"0", def},
|
|
{"12MB", def}, // decimal units are not accepted: say MiB
|
|
} {
|
|
if got := ParseSize(c.in, def); got != c.want {
|
|
t.Errorf("ParseSize(%q) = %d, want %d", c.in, got, c.want)
|
|
}
|
|
}
|
|
}
|