Skip to content

Commit 259d47b

Browse files
committed
Treat guest path surfaces as nonlocal in examples
1 parent b9dbb11 commit 259d47b

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

lib/codex/examples_support.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ defmodule Codex.ExamplesSupport do
113113
@spec ssh_enabled?() :: boolean()
114114
def ssh_enabled?, do: match?(%SSHContext{execution_surface: %ExecutionSurface{}}, context())
115115

116+
@spec nonlocal_path_execution_surface?() :: boolean()
117+
def nonlocal_path_execution_surface? do
118+
ExecutionSurface.nonlocal_path_surface?(execution_surface())
119+
end
120+
116121
@spec danger_full_access?() :: boolean()
117122
def danger_full_access?, do: context().example_danger_full_access == true
118123

@@ -134,7 +139,7 @@ defmodule Codex.ExamplesSupport do
134139
cwd
135140

136141
_ ->
137-
if ssh_enabled?(), do: nil, else: File.cwd!()
142+
if nonlocal_path_execution_surface?(), do: nil, else: File.cwd!()
138143
end
139144
end
140145

@@ -423,7 +428,7 @@ defmodule Codex.ExamplesSupport do
423428

424429
defp maybe_put_local_codex_path(attrs, mode) do
425430
cond do
426-
ssh_enabled?() ->
431+
nonlocal_path_execution_surface?() ->
427432
{:ok, maybe_put_execution_surface(attrs)}
428433

429434
local_codex_override?(attrs) ->

test/codex/examples_support_test.exs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,26 @@ defmodule Codex.ExamplesSupportTest do
181181
end
182182
end
183183

184+
describe "path semantics readiness" do
185+
test "guest-path execution surfaces suppress local example cwd defaults and local codex resolution" do
186+
Process.put(
187+
{ExamplesSupport, :ssh_context},
188+
%ExamplesSupport.SSHContext{
189+
argv: [],
190+
execution_surface: %ExecutionSurface{surface_kind: :test_guest_local}
191+
}
192+
)
193+
194+
assert ExamplesSupport.nonlocal_path_execution_surface?() == true
195+
assert ExamplesSupport.example_working_directory() == nil
196+
assert {:ok, options} = ExamplesSupport.codex_options(%{})
197+
assert options.codex_path_override == nil
198+
assert options.execution_surface.surface_kind == :test_guest_local
199+
after
200+
Process.delete({ExamplesSupport, :ssh_context})
201+
end
202+
end
203+
184204
describe "ensure_remote_working_directory/1" do
185205
test "skips ssh examples that need a remote cwd when none is configured" do
186206
assert {:ok, context} = ExamplesSupport.parse_argv(["--ssh-host", "example.internal"])

0 commit comments

Comments
 (0)