Skip to content

Commit a69c66b

Browse files
Antoine ToussaintAntoine Toussaint
authored andcommitted
chore: consume Core v0.2.111
1 parent 6e7c893 commit a69c66b

3 files changed

Lines changed: 63 additions & 1 deletion

File tree

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.25.12
55
toolchain go1.26.4
66

77
require (
8-
github.com/codefly-dev/core v0.2.102
8+
github.com/codefly-dev/core v0.2.111
99
gopkg.in/yaml.v3 v3.0.1
1010
)
1111

‎go.sum‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg
3939
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
4040
github.com/codefly-dev/core v0.2.102 h1:zRhxdF22cjC+qgFZgk9JsRIxCeziz7S2evxL3VkF/7I=
4141
github.com/codefly-dev/core v0.2.102/go.mod h1:PIAaqnsNqvEO2IhRhgxXKqaxHQ2cwxnWsegABRPvbgM=
42+
github.com/codefly-dev/core v0.2.111 h1:u3I0+vEi2/Mb1aFSw+i/ZcDT3MBX0qt7L8UK6tlNGug=
43+
github.com/codefly-dev/core v0.2.111/go.mod h1:e3xNBpBgMOzraxGaFbbiYtMYyhLAEoP7Cy2yaMrvV5U=
4244
github.com/codefly-dev/gortk v0.2.0 h1:7bOlS5valYz2zil+fZctQNcPCYBcPj86abcw9N8h1hQ=
4345
github.com/codefly-dev/gortk v0.2.0/go.mod h1:dDWUMFgAP063OCGhTEpV7FFUj9+zTcxxO/nV80VKEwg=
4446
github.com/cyphar/filepath-securejoin v0.6.1 h1:5CeZ1jPXEiYt3+Z6zqprSAgSWiggmpVyciv8syjIpVE=

‎pkg/runtime/runtime_test.go‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,66 @@ func TestRuntimeHonorsTypedSelectionWithDefaultRunner(t *testing.T) {
9696
assertRuntimeTestLeftSourceClean(t, dir)
9797
}
9898

99+
// TestRuntimeFormulaNormalizesUnittestDisplaySelection proves the production
100+
// agent boundary accepts the canonical case identity returned by unittest
101+
// (`method (module.Class)`) and routes it back through a formula that consumes
102+
// dotted loader names. Result-driven callers must not need Python runner
103+
// grammar, and an unselected failure makes accidental suite widening visible.
104+
func TestRuntimeFormulaNormalizesUnittestDisplaySelection(t *testing.T) {
105+
if _, err := exec.LookPath("uv"); err != nil {
106+
t.Fatalf("uv is required for the production Python runtime: %v", err)
107+
}
108+
root := t.TempDir()
109+
testsDir := filepath.Join(root, "tests")
110+
if err := os.MkdirAll(testsDir, 0o755); err != nil {
111+
t.Fatal(err)
112+
}
113+
runner := `import sys
114+
import unittest
115+
116+
names = [arg for arg in sys.argv[1:] if not arg.startswith("--")]
117+
suite = unittest.defaultTestLoader.loadTestsFromNames(names or ["test_sample"])
118+
result = unittest.TextTestRunner(verbosity=2).run(suite)
119+
raise SystemExit(0 if result.wasSuccessful() else 1)
120+
`
121+
cases := `import unittest
122+
123+
class SampleTests(unittest.TestCase):
124+
def test_selected_pass(self):
125+
self.assertEqual(2, 2)
126+
127+
def test_unselected_failure(self):
128+
self.assertEqual(1, 2)
129+
`
130+
for path, content := range map[string]string{
131+
filepath.Join(testsDir, "runtests.py"): runner,
132+
filepath.Join(testsDir, "test_sample.py"): cases,
133+
} {
134+
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
135+
t.Fatal(err)
136+
}
137+
}
138+
139+
svc := pythonservice.New(&resources.Agent{Kind: "codefly:service", Name: "python"})
140+
svc.SourceLocation = root
141+
rt := pythonruntime.New(svc)
142+
resp, err := rt.Test(context.Background(), &runtimev0.TestRequest{
143+
Filters: []string{"test_selected_pass (test_sample.SampleTests)"},
144+
Formula: &runtimev0.TestFormula{
145+
Command: []string{"python", "runtests.py"},
146+
Output: "unittest-text",
147+
Provisioning: map[string]string{"cwd": "tests"},
148+
},
149+
})
150+
if err != nil {
151+
t.Fatalf("Test: %v", err)
152+
}
153+
if resp.GetResult().GetState() != runtimev0.TestRunResult_PASSED || resp.GetCounts().GetTotal() != 1 || resp.GetCounts().GetPassed() != 1 {
154+
t.Fatalf("selected result = %s counts=%+v message=%q, want only the selected passing case", resp.GetResult().GetState(), resp.GetCounts(), resp.GetResult().GetMessage())
155+
}
156+
assertRuntimeTestLeftSourceClean(t, root)
157+
}
158+
99159
// TestRuntimeDefaultRunnerMaterializesDeclaredRequirements proves the remote
100160
// agent surface, not only Core's helper. The imported package is available
101161
// exclusively through requirements.txt, so a pytest-only uv overlay must fail

0 commit comments

Comments
 (0)