| ... | @@ -1517,6 +1517,51 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => { | ... | @@ -1517,6 +1517,51 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => { |
| 1517 | }), | 1517 | }), |
| 1518 | ); | 1518 | ); |
| 1519 | | 1519 | |
| | 1520 | it.effect("allows worktree removal to run longer than the default command timeout", () => |
| | 1521 | Effect.gen(function* () { |
| | 1522 | const delegate = yield* ChildProcessSpawner.ChildProcessSpawner; |
| | 1523 | const removalStarted = yield* Deferred.make<void>(); |
| | 1524 | const delayedRemovalSpawner = ChildProcessSpawner.make((command) => |
| | 1525 | Effect.gen(function* () { |
| | 1526 | if ( |
| | 1527 | ChildProcess.isStandardCommand(command) && |
| | 1528 | command.args[0] === "worktree" && |
| | 1529 | command.args[1] === "remove" |
| | 1530 | ) { |
| | 1531 | yield* Deferred.succeed(removalStarted, undefined); |
| | 1532 | yield* Effect.sleep("31 seconds"); |
| | 1533 | } |
| | 1534 | return yield* delegate.spawn(command); |
| | 1535 | }), |
| | 1536 | ); |
| | 1537 | const driver = yield* makeGitVcsDriverCore().pipe( |
| | 1538 | Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, delayedRemovalSpawner), |
| | 1539 | Effect.provide(ServerConfigLayer), |
| | 1540 | ); |
| | 1541 | const cwd = yield* makeTmpDir(); |
| | 1542 | const { initialBranch } = yield* initRepoWithCommit(cwd); |
| | 1543 | const fileSystem = yield* FileSystem.FileSystem; |
| | 1544 | const pathService = yield* Path.Path; |
| | 1545 | const worktreePath = pathService.join(yield* makeTmpDir("git-worktrees-"), "slow-removal"); |
| | 1546 | |
| | 1547 | yield* driver.createWorktree({ |
| | 1548 | cwd, |
| | 1549 | path: worktreePath, |
| | 1550 | refName: initialBranch, |
| | 1551 | newRefName: "feature/slow-removal", |
| | 1552 | }); |
| | 1553 | |
| | 1554 | const removal = yield* driver |
| | 1555 | .removeWorktree({ cwd, path: worktreePath, force: true }) |
| | 1556 | .pipe(Effect.forkChild({ startImmediately: true })); |
| | 1557 | yield* Deferred.await(removalStarted); |
| | 1558 | yield* TestClock.adjust("31 seconds"); |
| | 1559 | yield* Fiber.join(removal); |
| | 1560 | |
| | 1561 | assert.equal(yield* fileSystem.exists(worktreePath), false); |
| | 1562 | }), |
| | 1563 | ); |
| | 1564 | |
| 1520 | it.effect("removes the same worktree path twice without failing", () => | 1565 | it.effect("removes the same worktree path twice without failing", () => |
| 1521 | Effect.gen(function* () { | 1566 | Effect.gen(function* () { |
| 1522 | const cwd = yield* makeTmpDir(); | 1567 | const cwd = yield* makeTmpDir(); |