Skip to content

Commit b2d7d77

Browse files
committed
fix expectation + waitForTermination
1 parent d180cc0 commit b2d7d77

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Dompurify/DompurifyService.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,20 @@ public function throwIfFailedOnTerm(): void
113113
throw new ProcessFailedException($this->serviceProcess);
114114
}
115115

116+
public function waitForTermination(int $timeout): void
117+
{
118+
$elapsed = 0;
119+
$sleepInterval = 100; // Sleep for 100 milliseconds
120+
121+
while ($this->serviceProcess->isRunning() && $elapsed < $timeout) {
122+
usleep($sleepInterval * 1000);
123+
$elapsed += $sleepInterval;
124+
}
125+
126+
if ($this->serviceProcess->isRunning()) {
127+
throw new XsslessException('Process did not terminate within the given timeout');
128+
}
129+
}
130+
116131
// ========================================================================
117132
}

tests/Dompurify/DompurifyServiceTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
));
7171

7272
expect(fn () => $service->start())->toThrow(ProcessFailedException::class);
73-
expect($service->serviceProcess->getTermSignal())->toBe(127);
74-
// TODO: fix https://github.com/medilies/xssless/actions/runs/10283025153/job/28455979969
75-
// TODO: wait for signal
73+
$service->waitForTermination(1000);
74+
expect($service->serviceProcess->getExitCode())->toBe(127);
7675
});

0 commit comments

Comments
 (0)