Skip to content

Commit

Permalink
nit: Clean up after node PHP popen() test (#1280)
Browse files Browse the repository at this point in the history
This cleans up an untracked file that is created by the unit tests.
Otherwise, there is an untracked "out" file leftover after running the
tests.

## Testing Instructions

CI
  • Loading branch information
brandonpayton authored Apr 19, 2024
1 parent d27b503 commit 451b419
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/php-wasm/node/src/test/php.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,25 @@ describe.each(SupportedPHPVersions)('PHP %s', (phpVersion) => {
});

it('popen("cat", "w")', async () => {
const result = await php.run({
code: `<?php
$fp = popen("cat > out", "w");
fwrite($fp, "WordPress\n");
fclose($fp);
try {
const result = await php.run({
code: `<?php
$fp = popen("cat > out", "w");
fwrite($fp, "WordPress\n");
fclose($fp);
sleep(1); // @TODO: call js_wait_until_process_exits() in fclose();
sleep(1); // @TODO: call js_wait_until_process_exits() in fclose();
$fp = popen("cat out", "r");
echo 'stdout: ' . fread($fp, 1024);
pclose($fp);
`,
});
$fp = popen("cat out", "r");
echo 'stdout: ' . fread($fp, 1024);
pclose($fp);
`,
});

expect(result.text).toEqual('stdout: WordPress\n');
expect(result.text).toEqual('stdout: WordPress\n');
} finally {
rmSync('out', { force: true });
}
});
});

Expand Down

0 comments on commit 451b419

Please sign in to comment.