Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

laya-go: hooks golden excludes the router and None-usage cases instead of skipping them

Adeshina Lasisiabb54d070a00
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 9ffe8a24..ab923305 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -128,11 +128,11 @@ jobs:
LAYA_GO_FIXTURES: ${{ github.workspace }}/.go-goldens
LAYA_CHECKPOINTS: ${{ github.workspace }}/laya-java/.work/checkpoints
run: go test -race -count=1 -json ./... > "$RUNNER_TEMP/go-test.json"
- # Exactly the measured count (1449 tests and subtests, on both Go versions): dropping a
+ # Exactly the measured count (1556 tests and subtests, on both Go versions): dropping a
# case fails here, and adding one means raising this number.
- name: No test was skipped
if: ${{ !cancelled() }}
- run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test.json" --min-tests 1559
+ run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test.json" --min-tests 1556
# go.mod declares go 1.22, so that is what a consumer may build with.
- name: Run the tests on the oldest supported Go
@@ -144,7 +144,7 @@ jobs:
run: go test -count=1 -json ./... > "$RUNNER_TEMP/go-test-oldest.json"
- name: No test was skipped on the oldest Go either
if: ${{ !cancelled() }}
- run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test-oldest.json" --min-tests 1559
+ run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test-oldest.json" --min-tests 1556
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: ${{ failure() }}
diff --git a/laya-go/agent/hooks_golden_test.go b/laya-go/agent/hooks_golden_test.go
index d3220362..42a4379a 100644
--- a/laya-go/agent/hooks_golden_test.go
+++ b/laya-go/agent/hooks_golden_test.go
@@ -171,9 +171,14 @@ func behaviourOf(t testing.TB, v any) map[string]string {
func TestHooksGoldenDispatch(t *testing.T) {
g := fixtures.Load(t, "hooks.json")
+ routed := 0
for _, cv := range fixtures.List(t, g.Must("dispatch")) {
c := fixtures.Obj(t, cv)
name := fixtures.Str(t, c.Must("case"))
+ if e := fixtures.Str(t, c.Must("event")); e == "on_route" {
+ routed++ // the router PR's event; Go has no router yet
+ continue
+ }
t.Run(name, func(t *testing.T) {
event := fixtures.Str(t, c.Must("event"))
var ev hookEvent
@@ -185,7 +190,7 @@ func TestHooksGoldenDispatch(t *testing.T) {
case "on_error":
ev = evError
default:
- t.Skipf("%s is the router PR's", event)
+ t.Fatalf("event %s is not ported", event)
}
rec := &recorder{}
a := testAgent(t, options{raise: fixtures.Bool(t, c.Must("raise_errors")), warn: rec.warn})
@@ -232,6 +237,9 @@ func TestHooksGoldenDispatch(t *testing.T) {
}
})
}
+ if routed != 2 { // a new on_route case, or one renamed, must be looked at, not silently dropped
+ t.Fatalf("%d on_route cases excluded, want 2", routed)
+ }
}
func TestHooksGoldenSkip(t *testing.T) {
@@ -268,15 +276,17 @@ func TestHooksGoldenSkip(t *testing.T) {
}
func TestHooksGoldenUsage(t *testing.T) {
+ pyNone := 0
for _, cv := range fixtures.List(t, fixtures.Load(t, "hooks.json").Must("usage")) {
c := fixtures.Obj(t, cv)
+ if usageIsNone(t, c) {
+ pyNone++ // a Go Prediction's Usage is a value, never None
+ continue
+ }
t.Run(fixtures.Str(t, c.Must("case")), func(t *testing.T) {
var rs []schema.Prediction
for _, rv := range fixtures.List(t, c.Must("results")) {
r := fixtures.Obj(t, rv)
- if _, none := r.Get("__usage_is_none__"); none {
- t.Skip("a Go Prediction's Usage is a value, never None")
- }
tok := func(k string) int { // missing, null and float inputs are Python-only shapes
switch v, _ := r.Get(k); x := v.(type) {
case nil:
@@ -295,6 +305,9 @@ func TestHooksGoldenUsage(t *testing.T) {
}
})
}
+ if pyNone != 1 { // Python-only shape: a result whose usage is None
+ t.Fatalf("%d None-usage cases excluded, want 1", pyNone)
+ }
}
func TestHooksGoldenTimeouts(t *testing.T) {
@@ -694,3 +707,12 @@ func TestHooksGoldenPredictBatch(t *testing.T) {
})
}
}
+
+func usageIsNone(t *testing.T, c fixtures.Object) bool {
+ for _, rv := range fixtures.List(t, c.Must("results")) {
+ if _, none := fixtures.Obj(t, rv).Get("__usage_is_none__"); none {
+ return true
+ }
+ }
+ return false
+}