Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blueprints: add unit tests to the rmdir step #1021

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

reimic
Copy link
Contributor

@reimic reimic commented Feb 8, 2024

Adds tests to the rmdir step.

Related to #756

@reimic reimic changed the title Blueprints: add unit tests to steps Blueprints: add unit tests to the rmdir step Feb 9, 2024
@reimic reimic closed this Feb 11, 2024
@reimic reimic reopened this Feb 11, 2024
@adamziel adamziel added [Package][@wp-playground] Blueprints [Type] Reliability Playground uptime, reliability, not crashing labels Feb 11, 2024
@reimic
Copy link
Contributor Author

reimic commented Mar 2, 2024

All tests pass, but there is some unexpected behavior. An error is printed out. I don't think this should be the case. Also, a different test which also tests an error-throwing scenario passes without any stack trace being printed out. It implies an error is thrown and somehow not properly handled by the async expect vitest funtion.

What is more, it properly asserts the error message is as expected. But still prints the thing. I see this behavior in other tests, but it still seems wrong.

The print:

Error: 
stderr | src/lib/steps/rmdir.spec.ts > Blueprint step rmdir() > should fail when the directory is a file
    at Object.ensureErrnoError (/workspaces/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:2537:29)
    at Object.staticInit (/workspaces/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:2545:6)
    at Module.init (/workspaces/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6693:4)
    at Module.loadPHPRuntime (/workspaces/wordpress-playground/packages/php-wasm/universal/src/lib/load-php-runtime.ts:128:37)
    at Function.loadRuntime (/workspaces/wordpress-playground/packages/php-wasm/node/src/lib/node-php.ts:73:16)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Function.load (/workspaces/wordpress-playground/packages/php-wasm/node/src/lib/node-php.ts:46:4)
    at /workspaces/wordpress-playground/packages/playground/blueprints/src/lib/steps/rmdir.spec.ts:8:9
    at async Promise.all (index 0)
    at callSuiteHook (file:///workspaces/wordpress-playground/node_modules/@vitest/runner/dist/index.js:518:23) {
  node: undefined,
  setErrno: [Function (anonymous)],
  errno: 54,
  message: 'FS error'
} { path: '/php/dir/index.php' }
 ✓ src/lib/steps/rmdir.spec.ts  (5 tests) 831ms
 Test Files  1 passed (1)
      Tests  5 passed (5)
   Start at  10:46:33
   Duration  992ms

@adamziel
Copy link
Collaborator

adamziel commented Mar 5, 2024

Nice find, that's an issue with the BasePHP API. There are two ways forward here. Either:

  • Easy: Add an isDir check around this line and throw an exception if it fails
  • Hard: Untangle Emscripten's exception throwing flow to catch the Error 54 when it's thrown. It seems to be stored for later when it happens and only thrown either asynchronously or on the next fs operation. Maybe this isn't worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package][@wp-playground] Blueprints [Type] Reliability Playground uptime, reliability, not crashing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants