Skip to content

Secure, Fast, and Extensible Sandbox runtime for AI agents.

fix(execd): gate PTY env tests behind !windows like the code they cover

高然4cbd48165561
diff --git a/components/execd/pkg/runtime/env_test.go b/components/execd/pkg/runtime/env_test.go
index 5dd9e4b80..6fc26a5b2 100644
--- a/components/execd/pkg/runtime/env_test.go
+++ b/components/execd/pkg/runtime/env_test.go
@@ -307,33 +307,3 @@ func TestUserProcessEnvironmentFiltersBlacklist(t *testing.T) {
require.Contains(t, joined, "OPENSANDBOX_ID=sandbox-1")
require.NotContains(t, joined, "EXECD_ACCESS_TOKEN")
}
-
-func TestPTYSessionEnvDefaultsTerm(t *testing.T) {
- t.Setenv("EXECD_ENVS", "")
- applyTestBinding(t, &binding.RuntimeBinding{SandboxID: "sandbox-1"})
-
- t.Setenv("TERM", "")
- require.Equal(
- t,
- []string{"TERM=" + defaultPTYTerm},
- terminalEntries(ptySessionEnv()),
- )
-}
-
-func TestPTYSessionEnvKeepsExistingTerm(t *testing.T) {
- t.Setenv("EXECD_ENVS", "")
- applyTestBinding(t, &binding.RuntimeBinding{SandboxID: "sandbox-1"})
-
- t.Setenv("TERM", "xterm")
- require.Equal(t, []string{"TERM=xterm"}, terminalEntries(ptySessionEnv()))
-}
-
-func terminalEntries(env []string) []string {
- var found []string
- for _, kv := range env {
- if strings.HasPrefix(kv, "TERM=") {
- found = append(found, kv)
- }
- }
- return found
-}
diff --git a/components/execd/pkg/runtime/pty_session_test.go b/components/execd/pkg/runtime/pty_session_test.go
index 38c30b75d..5f380be0e 100644
--- a/components/execd/pkg/runtime/pty_session_test.go
+++ b/components/execd/pkg/runtime/pty_session_test.go
@@ -28,6 +28,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/alibaba/opensandbox/internal/safego"
+
+ "github.com/alibaba/opensandbox/execd/pkg/binding"
)
func replayContains(t *testing.T, s *ptySession, substr string, timeout time.Duration) bool {
@@ -392,3 +394,33 @@ func waitForLine(ch <-chan string, target string, timeout time.Duration) bool {
}
}
}
+
+func TestPTYSessionEnvDefaultsTerm(t *testing.T) {
+ t.Setenv("EXECD_ENVS", "")
+ applyTestBinding(t, &binding.RuntimeBinding{SandboxID: "sandbox-1"})
+
+ t.Setenv("TERM", "")
+ require.Equal(
+ t,
+ []string{"TERM=" + defaultPTYTerm},
+ terminalEntries(ptySessionEnv()),
+ )
+}
+
+func TestPTYSessionEnvKeepsExistingTerm(t *testing.T) {
+ t.Setenv("EXECD_ENVS", "")
+ applyTestBinding(t, &binding.RuntimeBinding{SandboxID: "sandbox-1"})
+
+ t.Setenv("TERM", "xterm")
+ require.Equal(t, []string{"TERM=xterm"}, terminalEntries(ptySessionEnv()))
+}
+
+func terminalEntries(env []string) []string {
+ var found []string
+ for _, kv := range env {
+ if strings.HasPrefix(kv, "TERM=") {
+ found = append(found, kv)
+ }
+ }
+ return found
+}