Skip to content

Commit b249834

Browse files
committed
Add test script
1 parent f675044 commit b249834

File tree

8 files changed

+60
-2
lines changed

8 files changed

+60
-2
lines changed

blueprint.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"preferredVersions": {
3+
"php": "8.0",
4+
"wp": "6.7"
5+
},
6+
"steps": [
7+
{
8+
"step": "defineWpConfigConsts",
9+
"consts": {
10+
"DISABLE_WP_CRON": false
11+
}
12+
},
13+
{
14+
"step": "activatePlugin",
15+
"pluginPath": "/wordpress/wp-content/plugins/plugin"
16+
}
17+
]
18+
}

packages/php-wasm/node/src/lib/load-runtime.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@ export async function loadNodeRuntime(
113113
options: any = {}
114114
) => {
115115
return lookupPath(path, {
116-
follow: true,
117116
...options,
117+
/**
118+
* If follow is true, a symlinked plugin will successfully be mounted during boot.
119+
* But that would break POSIX compatibility because callers need to be able to not follow symlinks.
120+
*/
121+
// follow: true,
118122
});
119123
};
120124

@@ -151,6 +155,7 @@ export async function loadNodeRuntime(
151155
{ root: absoluteSourcePath },
152156
symlinkPath
153157
);
158+
console.log('\n[DEBUG] readlink mounted symlinked path', absoluteSourcePath, '->', symlinkPath);
154159
}
155160
return symlinkPath;
156161
};

packages/php-wasm/node/src/lib/node-fs-mount.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ export function createNodeFsMountHandler(localPath: string): MountHandler {
4343
throw new Error('Unable to access the mount point in VFS.');
4444
}
4545
FS.mount(FS.filesystems['NODEFS'], { root: localPath }, vfsMountPoint);
46+
console.log('[DEBUG] createNodeFsMountHandler mounted local path', localPath, 'to', vfsMountPoint);
47+
48+
php.run({
49+
code: `<?php echo json_encode(file_exists('${vfsMountPoint}'));`,
50+
}).then((result) => {
51+
console.log('[DEBUG] createNodeFsMountHandler mounted plugin path exists', result.json);
52+
});
4653
return () => {
4754
FS!.unmount(vfsMountPoint);
4855
if (removeVfsNode) {

packages/php-wasm/node/src/test/mount.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ describe('Mounting', () => {
459459
try {
460460
await php.rmdir(directoryMountPoint);
461461
} catch (e: any) {
462-
console.log(e);
463462
const error = e as Error;
464463
expect(error.message).toContain(
465464
`Could not remove directory "${directoryMountPoint}": Device or resource busy.`

packages/playground/cli/src/run-cli.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,12 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer> {
676676
wordPressReady = true;
677677
logger.log(`Booted!`);
678678

679+
playground.run({
680+
code: `<?php echo json_encode(file_exists('/wordpress/wp-content/plugins/plugin'));`,
681+
}).then((result) => {
682+
console.log('\n[DEBUG] runCLI mounted plugin path exists', result.json);
683+
});
684+
679685
if (compiledBlueprint) {
680686
logger.log(`Running the Blueprint...`);
681687
await runBlueprintSteps(compiledBlueprint, playground);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/bero/Projects/wordpress-playground/packages/playground/cli/src/test/mount-examples/plugin

plugin-symlink

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/bero/Projects/wordpress-playground/packages/playground/cli/src/test/mount-examples/plugin

run-cli.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
current_dir=$(pwd)
4+
plugin_dir=$current_dir/packages/playground/cli/src/test/mount-examples/plugin
5+
symlink_dir=$current_dir/plugin-symlink
6+
7+
# symlink plugin
8+
ln -s $plugin_dir $symlink_dir
9+
10+
# run cli
11+
node \
12+
--experimental-wasm-jspi \
13+
--experimental-strip-types \
14+
--experimental-transform-types \
15+
--import ./packages/meta/src/node-es-module-loader/register.mts \
16+
./packages/playground/cli/src/cli.ts \
17+
server \
18+
--port=9400 \
19+
--follow-symlinks \
20+
--blueprint=$current_dir/blueprint.json \
21+
--mount=$symlink_dir:/wordpress/wp-content/plugins/plugin

0 commit comments

Comments
 (0)