@@ -135,29 +135,40 @@ view_image = false
135135#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
136136async fn config_read_includes_system_layer_and_overrides ( ) -> Result < ( ) > {
137137 let codex_home = TempDir :: new ( ) ?;
138+ let ( user_dir, system_dir) = if cfg ! ( windows) {
139+ ( r"C:\Users\user" , r"C:\System" )
140+ } else {
141+ ( "/user" , "/system" )
142+ } ;
138143 write_config (
139144 & codex_home,
140- r#"
145+ & format ! (
146+ r#"
141147model = "gpt-user"
142148approval_policy = "on-request"
143149sandbox_mode = "workspace-write"
144150
145151[sandbox_workspace_write]
146- writable_roots = ["/user" ]
152+ writable_roots = [{} ]
147153network_access = true
148154"# ,
155+ serde_json:: json!( user_dir)
156+ ) ,
149157 ) ?;
150158
151159 let managed_path = codex_home. path ( ) . join ( "managed_config.toml" ) ;
152160 std:: fs:: write (
153161 & managed_path,
154- r#"
162+ format ! (
163+ r#"
155164model = "gpt-system"
156165approval_policy = "never"
157166
158167[sandbox_workspace_write]
159- writable_roots = ["/system" ]
168+ writable_roots = [{} ]
160169"# ,
170+ serde_json:: json!( system_dir)
171+ ) ,
161172 ) ?;
162173
163174 let managed_path_str = managed_path. display ( ) . to_string ( ) ;
@@ -207,7 +218,7 @@ writable_roots = ["/system"]
207218 . sandbox_workspace_write
208219 . as_ref ( )
209220 . expect ( "sandbox workspace write" ) ;
210- assert_eq ! ( sandbox. writable_roots, vec![ PathBuf :: from( "/system" ) ] ) ;
221+ assert_eq ! ( sandbox. writable_roots, vec![ PathBuf :: from( system_dir ) ] ) ;
211222 assert_eq ! (
212223 origins
213224 . get( "sandbox_workspace_write.writable_roots.0" )
@@ -350,6 +361,11 @@ async fn config_batch_write_applies_multiple_edits() -> Result<()> {
350361 let mut mcp = McpProcess :: new ( codex_home. path ( ) ) . await ?;
351362 timeout ( DEFAULT_READ_TIMEOUT , mcp. initialize ( ) ) . await ??;
352363
364+ let writable_root = if cfg ! ( windows) {
365+ r"C:\Users\codex\AppData\Local\Temp"
366+ } else {
367+ "/tmp"
368+ } ;
353369 let batch_id = mcp
354370 . send_config_batch_write_request ( ConfigBatchWriteParams {
355371 file_path : Some ( codex_home. path ( ) . join ( "config.toml" ) . display ( ) . to_string ( ) ) ,
@@ -362,7 +378,7 @@ async fn config_batch_write_applies_multiple_edits() -> Result<()> {
362378 ConfigEdit {
363379 key_path: "sandbox_workspace_write" . to_string( ) ,
364380 value: json!( {
365- "writable_roots" : [ "/tmp" ] ,
381+ "writable_roots" : [ writable_root ] ,
366382 "network_access" : false
367383 } ) ,
368384 merge_strategy: MergeStrategy :: Replace ,
@@ -404,7 +420,7 @@ async fn config_batch_write_applies_multiple_edits() -> Result<()> {
404420 . sandbox_workspace_write
405421 . as_ref ( )
406422 . expect ( "sandbox workspace write" ) ;
407- assert_eq ! ( sandbox. writable_roots, vec![ PathBuf :: from( "/tmp" ) ] ) ;
423+ assert_eq ! ( sandbox. writable_roots, vec![ PathBuf :: from( writable_root ) ] ) ;
408424 assert ! ( !sandbox. network_access) ;
409425
410426 Ok ( ( ) )
0 commit comments