Skip to content

Commit c873424

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

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

.github/workflows/run-tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ jobs:
1818
matrix:
1919
os: [ubuntu-latest, windows-latest]
2020
php: [8.3, 8.2]
21-
stability: [prefer-lowest, prefer-stable]
2221

23-
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
22+
name: P${{ matrix.php }} - ${{ matrix.os }}
2423

2524
steps:
2625
- name: Checkout code
@@ -41,7 +40,7 @@ jobs:
4140
- name: Install dependencies
4241
run: |
4342
composer i --no-interaction
44-
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
43+
composer update --prefer-dist --no-interaction
4544
4645
- name: List Installed Dependencies
4746
run: composer show -D

src/Dompurify/DompurifyService.php

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

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

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(20000);
74+
expect($service->serviceProcess->getExitCode())->toBe(127);
7675
});

0 commit comments

Comments
 (0)