rho-coding-agent 3.11.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
use std::process::Command;

use base64::Engine as _;
use pretty_assertions::assert_eq;
use rho_protocol::methods::{
    FsGitCheckout, FsListing, FsReadContent, FsResolved, FsSubfolder, HostStreamEnd,
};

use super::*;
use crate::app::daemon_host::machine_test_support::*;

/// The NUL-ended paths of a `files` stream, sorted.
fn sorted_paths(bytes: &[u8]) -> Vec<String> {
    let mut paths: Vec<String> = bytes
        .split(|&byte| byte == 0)
        .filter(|path| !path.is_empty())
        .map(|path| String::from_utf8(path.to_vec()).unwrap())
        .collect();
    paths.sort();
    paths
}

fn branch(reference: &str) -> Option<FsGitCheckout> {
    Some(FsGitCheckout::new(Some(GitHead::Branch {
        reference: reference.to_owned(),
    })))
}

// Covers: `look` names a linked worktree's project as its main checkout,
// a bare repository's worktree's as itself, and a subfolder's as its
// checkout, lists each subfolder that is a checkout with what its HEAD
// names (a branch; a commit, through a relative `gitdir:` file; nothing
// for a reftable repository's stub) and one that isn't without, an empty
// `gitdir:` included, and
// answers what isn't a folder or isn't there.
// Owner: daemon host calls.
#[tokio::test]
async fn look_resolves_projects_and_lists_checkouts() {
    let dir = tempfile::tempdir().unwrap();
    let root = dir.path();
    let main = root.join("main");
    repository(&main, &[("sub/a.txt", "a")]);
    git(
        &main,
        &["worktree", "add", "-q", "-b", "feature", "../linked"],
    );
    let commit = "0123456789abcdef0123456789abcdef01234567";
    std::fs::create_dir_all(root.join("pointer")).unwrap();
    std::fs::write(root.join("pointer/.git"), "gitdir: ../elsewhere\n").unwrap();
    std::fs::create_dir_all(root.join("elsewhere")).unwrap();
    std::fs::write(root.join("elsewhere/HEAD"), format!("{commit}\n")).unwrap();
    // A `.git` file naming no git dir, beside a stray HEAD.
    std::fs::create_dir_all(root.join("blank")).unwrap();
    std::fs::write(root.join("blank/.git"), "gitdir: \n").unwrap();
    std::fs::write(root.join("blank/HEAD"), "ref: refs/heads/stray\n").unwrap();
    std::fs::create_dir_all(root.join("reftable/.git")).unwrap();
    std::fs::write(
        root.join("reftable/.git/HEAD"),
        "ref: refs/heads/.invalid\n",
    )
    .unwrap();
    let bare = root.join("bare");
    std::fs::create_dir_all(&bare).unwrap();
    git(&bare, &["clone", "-q", "--bare", "../main", "repo.git"]);
    git(
        &bare.join("repo.git"),
        &["worktree", "add", "-q", "-b", "side", "../tree"],
    );
    std::fs::write(root.join("file.txt"), "").unwrap();
    let machine = machine();

    let looked = machine
        .look(
            caller(),
            FsLookParams::new(Some(host(&main.join("sub"))), Some(host(root))),
        )
        .await
        .unwrap();
    let linked = machine
        .look(
            caller(),
            FsLookParams::new(
                Some(host(&root.join("linked"))),
                Some(host(&root.join("file.txt"))),
            ),
        )
        .await
        .unwrap();
    let missing = machine
        .look(
            caller(),
            FsLookParams::new(
                Some(host(&root.join("file.txt"))),
                Some(host(&root.join("gone"))),
            ),
        )
        .await
        .unwrap();
    let bare_tree = machine
        .look(
            caller(),
            FsLookParams::new(Some(host(&bare.join("tree"))), None),
        )
        .await
        .unwrap();

    assert_eq!(
        looked.resolved,
        Some(FsResolved::Folder {
            real: real(&main.join("sub")),
            project: real(&main),
        })
    );
    let Some(FsListing::Listed {
        real: listed,
        mut subfolders,
    }) = looked.listing
    else {
        panic!("not listed: {:?}", looked.listing);
    };
    subfolders.sort_by(|a, b| a.name.cmp(&b.name));
    assert_eq!(listed, Some(real(root)));
    assert_eq!(
        subfolders,
        [
            FsSubfolder::new("bare", None),
            FsSubfolder::new("blank", None),
            FsSubfolder::new("elsewhere", None),
            FsSubfolder::new("linked", branch("refs/heads/feature")),
            FsSubfolder::new("main", branch("refs/heads/main")),
            FsSubfolder::new(
                "pointer",
                Some(FsGitCheckout::new(Some(GitHead::Detached {
                    commit: commit.to_owned()
                })))
            ),
            FsSubfolder::new("reftable", Some(FsGitCheckout::new(None))),
        ]
    );
    assert_eq!(
        linked.resolved,
        Some(FsResolved::Folder {
            real: real(&root.join("linked")),
            project: real(&main),
        })
    );
    assert_eq!(linked.listing, Some(FsListing::NotFolder));
    assert_eq!(
        bare_tree.resolved,
        Some(FsResolved::Folder {
            real: real(&bare.join("tree")),
            project: real(&bare.join("tree")),
        })
    );
    assert_eq!(missing.resolved, Some(FsResolved::NotFolder));
    assert_eq!(missing.listing, Some(FsListing::Gone));
}

// Covers: `look` resolves a symlink to the folder it names, lists a
// symlinked folder as a subfolder and a broken one as gone, and reads a
// checkout whose HEAD is a FIFO as one with no head rather than waiting
// on the FIFO for a writer.
// Owner: daemon host calls.
#[cfg(unix)]
#[tokio::test]
async fn look_reads_through_symlinks_and_never_waits_on_a_fifo() {
    let dir = tempfile::tempdir().unwrap();
    let root = dir.path();
    let target = root.join("target");
    std::fs::create_dir_all(target.join(".git")).unwrap();
    std::fs::write(target.join(".git/HEAD"), "ref: refs/heads/main\n").unwrap();
    std::os::unix::fs::symlink(&target, root.join("link")).unwrap();
    std::os::unix::fs::symlink(root.join("nowhere"), root.join("dangling")).unwrap();
    let piped = root.join("piped");
    std::fs::create_dir_all(piped.join("git")).unwrap();
    std::fs::write(piped.join(".git"), "gitdir: git\n").unwrap();
    let made = Command::new("mkfifo")
        .arg(piped.join("git/HEAD"))
        .status()
        .unwrap();
    assert!(made.success());
    let machine = machine();

    let looked = machine
        .look(
            caller(),
            FsLookParams::new(Some(host(&root.join("link"))), Some(host(root))),
        )
        .await
        .unwrap();
    let dangling = machine
        .look(
            caller(),
            FsLookParams::new(None, Some(host(&root.join("dangling")))),
        )
        .await
        .unwrap();

    assert_eq!(
        looked.resolved,
        Some(FsResolved::Folder {
            real: real(&target),
            project: real(&target),
        })
    );
    let Some(FsListing::Listed { mut subfolders, .. }) = looked.listing else {
        panic!("not listed: {:?}", looked.listing);
    };
    subfolders.sort_by(|a, b| a.name.cmp(&b.name));
    assert_eq!(
        subfolders,
        [
            FsSubfolder::new("link", branch("refs/heads/main")),
            FsSubfolder::new("piped", Some(FsGitCheckout::new(None))),
            FsSubfolder::new("target", branch("refs/heads/main")),
        ]
    );
    assert_eq!(dangling.resolved, None);
    assert_eq!(dangling.listing, Some(FsListing::Gone));
}

// Covers: in a git work tree `files` streams the files git tracks that
// are there and the untracked ones it doesn't ignore, `/`-joined, but not
// an untracked repository inside it or a submodule, which aren't files;
// and a limit inside a path ends the stream truncated after the whole
// paths before it.
// Owner: daemon host calls.
#[tokio::test]
async fn files_streams_what_git_sees_there_up_to_the_limit() {
    let dir = tempfile::tempdir().unwrap();
    let repo = dir.path().join("repo");
    repository(
        &repo,
        &[
            (".gitignore", "ignored.txt\n"),
            ("gone.txt", "gone"),
            ("kept.txt", "kept"),
            ("nested/deep.txt", "deep"),
        ],
    );
    std::fs::remove_file(repo.join("gone.txt")).unwrap();
    std::fs::write(repo.join("new.txt"), "new").unwrap();
    std::fs::write(repo.join("ignored.txt"), "ignored").unwrap();
    // git lists this one as `inner/`.
    repository(&repo.join("inner"), &[("inner.txt", "inner")]);
    // A submodule checked out: its folder is there.
    std::fs::create_dir(repo.join("module")).unwrap();
    git(
        &repo,
        &[
            "update-index",
            "--add",
            "--cacheinfo",
            "160000,0123456789abcdef0123456789abcdef01234567,module",
        ],
    );
    let machine = machine();
    let caller = caller();

    let all = machine
        .files(caller.clone(), FsFilesParams::new(host(&repo), 1 << 20))
        .await
        .unwrap();
    let (bytes, end) = read_out(&caller, all.stream).await;
    // Past the first path streamed, into the second, in git's own order.
    let first = &bytes[..=bytes.iter().position(|&byte| byte == 0).unwrap()];
    let limit = first.len() as u64 + 3;
    let cut = machine
        .files(caller.clone(), FsFilesParams::new(host(&repo), limit))
        .await
        .unwrap();
    let (cut_bytes, cut_end) = read_out(&caller, cut.stream).await;

    assert_eq!(
        sorted_paths(&bytes),
        [".gitignore", "kept.txt", "nested/deep.txt", "new.txt"]
    );
    assert_eq!(end, HostStreamEnd::Done);
    assert_eq!(cut_bytes, first);
    assert_eq!(cut_end, HostStreamEnd::Truncated);
}

// Covers: `files` lists a file a merge left in conflict once, though git
// lists it once for each side's stage.
// Owner: daemon host calls.
#[tokio::test]
async fn files_lists_a_file_in_conflict_once() {
    let dir = tempfile::tempdir().unwrap();
    let repo = dir.path().join("repo");
    repository(&repo, &[("both.txt", "base\n")]);
    git(&repo, &["checkout", "-q", "-b", "theirs"]);
    std::fs::write(repo.join("both.txt"), "theirs\n").unwrap();
    git(&repo, &["commit", "-q", "-am", "theirs"]);
    git(&repo, &["checkout", "-q", "main"]);
    std::fs::write(repo.join("both.txt"), "ours\n").unwrap();
    git(&repo, &["commit", "-q", "-am", "ours"]);
    let merged = git_command(&repo, &["merge", "-q", "theirs"])
        .output()
        .unwrap();
    assert!(!merged.status.success(), "the merge didn't conflict");
    let caller = caller();

    let listed = machine()
        .files(caller.clone(), FsFilesParams::new(host(&repo), 1 << 20))
        .await
        .unwrap();
    let (bytes, end) = read_out(&caller, listed.stream).await;

    assert_eq!(sorted_paths(&bytes), ["both.txt"]);
    assert_eq!(end, HostStreamEnd::Done);
}

// Covers: outside a git work tree `files` walks the folder, listing
// nested files by `/`-joined paths and no folder, and leaving out a name
// that is not UTF-8.
// Owner: daemon host calls.
#[tokio::test]
async fn files_walks_a_folder_outside_git() {
    let dir = tempfile::tempdir().unwrap();
    let folder = dir.path();
    std::fs::create_dir_all(folder.join("a")).unwrap();
    std::fs::create_dir_all(folder.join("empty")).unwrap();
    std::fs::write(folder.join("a/b.txt"), "b").unwrap();
    std::fs::write(folder.join("top.txt"), "top").unwrap();
    // A name that is not UTF-8 cannot travel, so it is left out. (macOS
    // refuses to make one.)
    #[cfg(target_os = "linux")]
    {
        use std::os::unix::ffi::OsStrExt as _;
        let name = std::ffi::OsStr::from_bytes(b"not-utf8-\xff");
        std::fs::write(folder.join(name), "x").unwrap();
    }
    let caller = caller();

    let listed = machine()
        .files(caller.clone(), FsFilesParams::new(host(folder), 1 << 20))
        .await
        .unwrap();
    let (bytes, end) = read_out(&caller, listed.stream).await;

    assert_eq!(sorted_paths(&bytes), ["a/b.txt", "top.txt"]);
    assert_eq!(end, HostStreamEnd::Done);
}

// Covers: outside a git work tree `files` lists a symlink to a folder that
// holds it as a file, rather than following it around the cycle, and the
// walk ends.
// Owner: daemon host calls.
#[cfg(unix)]
#[tokio::test]
async fn files_walk_lists_a_symlinked_folder_cycle_as_a_file() {
    let dir = tempfile::tempdir().unwrap();
    let folder = dir.path();
    std::fs::create_dir_all(folder.join("a")).unwrap();
    std::fs::write(folder.join("a/b.txt"), "b").unwrap();
    std::os::unix::fs::symlink(folder, folder.join("a/up")).unwrap();
    let caller = caller();

    let listed = machine()
        .files(caller.clone(), FsFilesParams::new(host(folder), 1 << 20))
        .await
        .unwrap();
    let (bytes, end) = read_out(&caller, listed.stream).await;

    assert_eq!(sorted_paths(&bytes), ["a/b.txt", "a/up"]);
    assert_eq!(end, HostStreamEnd::Done);
}

/// What `read` answered for a file of 5 bytes.
fn content(read: FsRead) -> FsReadContent {
    let FsRead::File {
        size,
        modified_ns,
        content,
    } = read
    else {
        panic!("not a file: {read:?}");
    };
    assert_eq!(size, 5);
    assert!(modified_ns.is_some());
    content
}

fn inline(data: &[u8], truncated: bool) -> FsReadContent {
    FsReadContent::Inline {
        data: base64::engine::general_purpose::STANDARD.encode(data),
        truncated,
    }
}

// Covers: `read` answers a file within the limit whole in the answer and
// one past it cut and marked, and streams one past `inline_bytes`, its
// stream ending done, or truncated at the limit.
// Owner: daemon host calls.
#[tokio::test]
async fn read_answers_inline_up_to_the_limit_and_streams_past_inline_bytes() {
    let dir = tempfile::tempdir().unwrap();
    let folder = host(dir.path());
    std::fs::write(dir.path().join("hello.txt"), "hello").unwrap();
    let file = HostPath::new("hello.txt");
    let machine = machine();
    let caller = caller();
    let read = |limit, inline_bytes| {
        machine.read(
            caller.clone(),
            FsReadParams::new(folder.clone(), file.clone(), limit, inline_bytes),
        )
    };

    let whole = content(read(5, 64).await.unwrap());
    let cut = content(read(4, 64).await.unwrap());
    let streamed = content(read(64, 0).await.unwrap());
    let streamed_cut = content(read(4, 2).await.unwrap());

    assert_eq!(whole, inline(b"hello", false));
    assert_eq!(cut, inline(b"hell", true));
    let FsReadContent::Stream { stream } = streamed else {
        panic!("not streamed: {streamed:?}");
    };
    assert_eq!(
        read_out(&caller, stream).await,
        (b"hello".to_vec(), HostStreamEnd::Done)
    );
    let FsReadContent::Stream { stream } = streamed_cut else {
        panic!("not streamed: {streamed_cut:?}");
    };
    assert_eq!(
        read_out(&caller, stream).await,
        (b"hell".to_vec(), HostStreamEnd::Truncated)
    );
}

// Covers: `read` answers gone for a folder and for nothing, and fails
// for a `folder` that isn't one.
// Owner: daemon host calls.
#[tokio::test]
async fn read_answers_gone_for_what_isnt_a_file() {
    let dir = tempfile::tempdir().unwrap();
    std::fs::create_dir(dir.path().join("sub")).unwrap();
    std::fs::write(dir.path().join("hello.txt"), "hello").unwrap();
    let machine = machine();
    let read = |folder: &Path, path: &str| {
        machine.read(
            caller(),
            FsReadParams::new(host(folder), HostPath::new(path), 64, 64),
        )
    };

    let folder = read(dir.path(), "sub").await.unwrap();
    let missing = read(dir.path(), "missing.txt").await.unwrap();
    let in_a_file = read(&dir.path().join("hello.txt"), "x").await.unwrap_err();

    assert_eq!(folder, FsRead::Gone);
    assert_eq!(missing, FsRead::Gone);
    assert_eq!(in_a_file.code, ErrorCode::HostCallFailed.code());
}

// Covers: `read` answers gone for a FIFO, without waiting on it for a
// writer, which would hang the call.
// Owner: daemon host calls.
#[cfg(unix)]
#[tokio::test]
async fn read_answers_gone_for_a_fifo() {
    let dir = tempfile::tempdir().unwrap();
    let made = Command::new("mkfifo")
        .arg(dir.path().join("pipe"))
        .status()
        .unwrap();
    assert!(made.success());

    let read = machine()
        .read(
            caller(),
            FsReadParams::new(host(dir.path()), HostPath::new("pipe"), 64, 64),
        )
        .await
        .unwrap();

    assert_eq!(read, FsRead::Gone);
}

// Covers: `look` resolves a folder the daemon may not enter as not a
// folder, and lists one it may read but not enter with no real path.
// Owner: daemon host calls.
#[cfg(unix)]
#[tokio::test]
async fn look_treats_a_folder_it_cannot_enter_as_no_folder() {
    use std::os::unix::fs::PermissionsExt as _;
    // SAFETY: geteuid takes nothing and cannot fail.
    if unsafe { libc::geteuid() } == 0 {
        // Root enters every folder.
        return;
    }
    let dir = tempfile::tempdir().unwrap();
    let shut = dir.path().join("shut");
    let unsearchable = dir.path().join("unsearchable");
    std::fs::create_dir(&shut).unwrap();
    std::fs::create_dir(&unsearchable).unwrap();
    std::fs::set_permissions(&shut, std::fs::Permissions::from_mode(0o000)).unwrap();
    std::fs::set_permissions(&unsearchable, std::fs::Permissions::from_mode(0o400)).unwrap();

    let looked = machine()
        .look(
            caller(),
            FsLookParams::new(Some(host(&shut)), Some(host(&unsearchable))),
        )
        .await
        .unwrap();
    // So the temporary folder can be removed.
    for folder in [&shut, &unsearchable] {
        std::fs::set_permissions(folder, std::fs::Permissions::from_mode(0o700)).unwrap();
    }

    assert_eq!(looked.resolved, Some(FsResolved::NotFolder));
    assert_eq!(
        looked.listing,
        Some(FsListing::Listed {
            real: None,
            subfolders: Vec::new(),
        })
    );
}

// Covers: `make_folder` takes the first free name, counting anything at
// a name, a dangling symlink included, as taken.
// Owner: daemon host calls.
#[cfg(unix)]
#[tokio::test]
async fn make_folder_takes_the_first_free_name() {
    let dir = tempfile::tempdir().unwrap();
    let parent = dir.path().join("leads");
    std::fs::create_dir_all(parent.join("name")).unwrap();
    std::fs::create_dir_all(parent.join("name-2")).unwrap();
    std::os::unix::fs::symlink(parent.join("nowhere"), parent.join("name-3")).unwrap();

    let made = machine()
        .make_folder(
            caller(),
            FsMakeFolderParams::new(host(&parent), Some("name".to_owned())),
        )
        .await
        .unwrap();

    assert_eq!(made.path, real(&parent.join("name-4")));
}

// Covers: `make_folder` with no name makes the parent with its own
// parents and answers it resolved, and refuses a name that is more than
// one path part, making nothing.
// Owner: daemon host calls.
#[tokio::test]
async fn make_folder_makes_the_parent_and_refuses_a_path_for_a_name() {
    let dir = tempfile::tempdir().unwrap();
    let parent = dir.path().join("a/b");
    let machine = machine();

    let made = machine
        .make_folder(caller(), FsMakeFolderParams::new(host(&parent), None))
        .await
        .unwrap();
    let refused = machine
        .make_folder(
            caller(),
            FsMakeFolderParams::new(host(&parent), Some("../x".to_owned())),
        )
        .await
        .unwrap_err();

    assert_eq!(made.path, real(&parent));
    assert_eq!(refused.code, ErrorCode::InvalidParams.code());
    assert!(!dir.path().join("a/x").exists());
}

// Covers: a `make_folder` name is one path part on every machine, and on
// Windows none that holds a character Windows refuses, names a device, or
// ends in what Windows trims; the rules for both are checked everywhere.
// Owner: daemon host calls.
#[test]
fn folder_names_follow_the_machines_rules() {
    // Each name, then whether it is taken elsewhere and on Windows.
    let cases = [
        ("plain", true, true),
        ("conference", true, true),
        ("", false, false),
        ("..", false, false),
        ("a/b", false, false),
        (r"a\b", false, false),
        ("a:b", true, false),
        ("tab\there", true, false),
        ("con", true, false),
        ("NUL.txt", true, false),
        ("com1", true, false),
        ("name.", true, false),
        ("name ", true, false),
    ];

    let rules = cases.map(|(name, ..)| {
        (
            name,
            is_folder_name(name, false),
            is_folder_name(name, true),
        )
    });

    assert_eq!(rules, cases);
}

// Covers: `remove_empty_folder` removes an empty folder, and fails on one
// that holds a file, leaving it.
// Owner: daemon host calls.
#[tokio::test]
async fn remove_empty_folder_removes_only_an_empty_one() {
    let dir = tempfile::tempdir().unwrap();
    let empty = dir.path().join("empty");
    let full = dir.path().join("full");
    std::fs::create_dir(&empty).unwrap();
    std::fs::create_dir(&full).unwrap();
    std::fs::write(full.join("file.txt"), "kept").unwrap();
    let machine = machine();

    machine
        .remove_empty_folder(caller(), FsRemoveEmptyFolderParams::new(host(&empty)))
        .await
        .unwrap();
    let refused = machine
        .remove_empty_folder(caller(), FsRemoveEmptyFolderParams::new(host(&full)))
        .await
        .unwrap_err();

    assert!(!empty.exists());
    assert_eq!(refused.code, ErrorCode::HostCallFailed.code());
    assert!(full.join("file.txt").exists());
}