Merge pull request 'Fix a race in the cancel_command test' (#82) from fix-cancel-test-race into main
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 16s
CI / Test (jest) (push) Successful in 22s
CI / Security (npm audit) (push) Successful in 19s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m11s
CI / Integration (api) (push) Successful in 3m11s
CI / UI (playwright) (push) Successful in 2m36s
CI / Deploy (push) Successful in 17s
CI / Deploy worker (push) Successful in 10s
CI / Notify (push) Successful in 2s
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 16s
CI / Test (jest) (push) Successful in 22s
CI / Security (npm audit) (push) Successful in 19s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m11s
CI / Integration (api) (push) Successful in 3m11s
CI / UI (playwright) (push) Successful in 2m36s
CI / Deploy (push) Successful in 17s
CI / Deploy worker (push) Successful in 10s
CI / Notify (push) Successful in 2s
This commit was merged in pull request #82.
This commit is contained in:
commit
64703482fd
1 file changed
+3
-1
@@ -126,7 +126,9 @@ describe('cancel_command (#8)', () => {
|
||||
test('cancelling stops the command and everything it started', async () => {
|
||||
const w = makeWorker();
|
||||
const pidFile = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'pulse-cancel-')), 'pid');
|
||||
const pending = w.executeCommand({ command: `sleep 30 & echo $! > ${pidFile}; wait`, execution_id: 'ex-c', command_id: 'cmd-c' });
|
||||
// Write then rename: the shell creates a redirect target before writing to it,
|
||||
// so reading ${pidFile} directly could see an empty file (pid 0).
|
||||
const pending = w.executeCommand({ command: `sleep 30 & echo $! > ${pidFile}.tmp && mv ${pidFile}.tmp ${pidFile}; wait`, execution_id: 'ex-c', command_id: 'cmd-c' });
|
||||
for (let i = 0; i < 50 && !fs.existsSync(pidFile); i++) await new Promise(r => setTimeout(r, 50));
|
||||
const childPid = Number(fs.readFileSync(pidFile, 'utf8'));
|
||||
expect(alive(childPid)).toBe(true);
|
||||
|
||||
Reference in new issue
Block a user