Provide ready attention UI fixture and explicit Android tool path
This commit is contained in:
@@ -20,6 +20,17 @@ time while iterating — the full suite is for the end.
|
||||
|
||||
## The dev device
|
||||
|
||||
The ADB executable is `/Users/alan/Library/Android/sdk/platform-tools/adb`.
|
||||
Use that absolute path (or explicitly add its directory to PATH); `adb: command
|
||||
not found` alone is not evidence that the leased phone is disconnected.
|
||||
|
||||
For populated attention review, `TestExportReadyAttentionReviewFixture` exports a
|
||||
create-only scratch database when `PIPELINES_ATTENTION_REVIEW_DIR` names a new
|
||||
directory. Its fixture.json identifies one failed, one finished and one waiting
|
||||
run and the workspace. Build a scratch server, read back those states, and keep
|
||||
the owned server alive through all UI interactions. The export itself does not
|
||||
leave a server running or configure a phone. Never use a dead scratch endpoint.
|
||||
|
||||
Only the **UI reviewer**, while its stage holds a declared runner-exclusive resource
|
||||
for the selected phone, may use the device. Implementers and code reviewers do code,
|
||||
builds, unit tests and source review only: **no adb, installs, captures, device-setting
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
// Operator-invoked scratch fixture only. No devices or live databases are used.
|
||||
func TestExportReadyAttentionReviewFixture(t *testing.T) {
|
||||
dir := os.Getenv("PIPELINES_ATTENTION_REVIEW_DIR")
|
||||
if dir == "" {
|
||||
t.Skip("explicit export directory required")
|
||||
}
|
||||
if err := os.Mkdir(dir, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
workspace := filepath.Join(dir, "workspace")
|
||||
if err := os.Mkdir(workspace, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
db := filepath.Join(dir, "attention.db")
|
||||
store, err := pipeline.Open(db)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer store.Close()
|
||||
if _, err := store.Submit(ctx, "Attention fixture", humanPipelineSource); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
items, err := store.List(ctx)
|
||||
if err != nil || len(items) != 1 {
|
||||
t.Fatal("missing fixture definition", err)
|
||||
}
|
||||
definition, err := store.Get(ctx, items[0].ID, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, status := range []string{"failed", "succeeded"} {
|
||||
id, _, err := store.CreateRun(ctx, definition, "fixture-"+status, workspace, false, nil, map[string]any{"prompt": "Controlled " + status + " attention entry"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
outcome := "success"
|
||||
if status == "failed" {
|
||||
outcome = "error"
|
||||
}
|
||||
if err := store.FinishRun(ctx, id, status, outcome, "Controlled fixture", nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
r, err := newRunner(ctx, store)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.execute = successExecute
|
||||
waiting, err := r.start(protocol.Message{PipelineID: definition.ID, Version: 1, RequestKey: "fixture-waiting", Workspace: workspace, Input: map[string]any{"prompt": "Controlled waiting attention entry"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.wg.Wait()
|
||||
readback, err := store.GetRun(ctx, waiting.ID)
|
||||
if err != nil || readback.Status != protocol.RunStatusWaiting || len(readback.Steps) != 1 {
|
||||
t.Fatalf("waiting fixture invalid: %+v %v", readback, err)
|
||||
}
|
||||
data, err := json.MarshalIndent(map[string]any{"database": db, "workspace": workspace, "waiting_run": waiting.ID, "failed_run": 1, "finished_run": 2}, "", " ")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, "fixture.json"), data, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user