Repository navigation
fix(tests): give each test run its own temp fixture root - #276
Merged
Merged
Conversation
- tests/shared.js hardcoded TEST_ROOT to /tmp/docmd-brute-tests, and feature-integration.test.js and security.test.js hardcoded their own fixed /tmp dirs, so two test runs on one host wrote into the same fixture dirs and broke each other (setup() wipes a dir another run is still using) - The dirs were never removed, so a small tmpfs /tmp could fill up over time - TEST_ROOT is now created per run with fs.mkdtempSync(path.join(os.tmpdir(), 'docmd-tests-')) and removed on exit, SIGINT and SIGTERM - The process that creates it exports it as DOCMD_TEST_ROOT, so child test processes the runner spawns (feature-integration, security) reuse their parent run's dir and leave cleanup to the parent - feature-integration.test.js imports TEST_ROOT from shared.js; security.test.js uses a security/ subdir of it, keeping its fixtures apart as before - Add tests/cli-contracts/test-root.test.js (registered in tests/runner.js as test-root): checks the root is under os.tmpdir(), a second run gets a different root and removes it on exit, and a child with DOCMD_TEST_ROOT reuses the parent root without removing it
- The title registered for host-flag in tests/runner.js carried two ids from the author's own tracker (AC-2, AC-15), added by mistake in docmd-io#269 - They mean nothing in this repo, so the title now just says what the test checks
Member
|
Excellent fix for test concurrency and fixture isolation. Replacing the static Verified and merging! |
mgks
added a commit
that referenced
this pull request
Nov 11, 2026
…ture additions Synchronize working branch 'dev-0.9.10' with 'main' following the review, security audit, and integration of 6 community pull requests alongside our static asset root mirroring feature. Merged Community Contributions: - PR #271 (@GPT-AGI / Ting Zhang): fix(parser): resolve folder-index links from nested pages Fixes relative link resolution for non-index folder references from deep subdirectories. - PR #274 (@svallory): fix(core): build finds 0 pages when an ancestor folder matches .gitignore Confines gitignore matching to repository root and avoids empty builds when parent paths match ignore patterns. - PR #275 (@svallory): fix(build): keep git tree clean after pnpm -r run build Eliminates timestamps from generated plugin registry and ignores pre-built native binaries across architectures. - PR #276 (@svallory): fix(tests): give each test run its own temp fixture root Isolates test fixtures into unique run directories under os.tmpdir() to prevent concurrency collisions. - PR #272 (@svallory): feat(api,core): plugin actions receive caller context; one shared action host Introduces shared ActionHost with caller context (identity, mode, transport, headers without cookies), origin allowlisting, and unified rebuild queue. - PR #273 (@svallory): feat(core): docmd serve, a production server for the built site Adds zero-dependency production HTTP/WS server with gzip compression, security headers (CSP, HSTS, CORS), health check endpoints (/healthz, /livez, /readyz), and SPA / clean URL routing. Working Branch Features Included: - feat(core): Zero-config static root asset mirroring Copies static assets from 'public/' or 'static/' (and docs/public/) directly to the output root ('site/'), preserving directory structure and files like 'funding.json', 'CNAME', and '.well-known/'. Adds canonical 'static' configuration option with support for boolean or custom directory lists. - feat(cli): --host flag support for dev and serve commands (defaults to loopback 127.0.0.1 for CWE-1385 protection, configurable to 0.0.0.0 for container / LAN hosting). Documentation Impact: - Configuration Reference: Document 'static' setting (boolean | string[]). - CLI Reference: Document 'docmd serve' command options and '--host' flag. - Plugin Guide: Document ActionHost caller context and execution modes.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A side fix found while working on #267 (not one of its numbered steps).
Problem:
tests/shared.jssetsTEST_ROOT = '/tmp/docmd-brute-tests',tests/feature-integration.test.jsuses the same fixed dir, andtests/security.test.jsuses/tmp/docmd-brute-security. Two test runs on one host (two worktrees, two CI jobs on one runner, a run while another is still going) write into the same fixture dirs and break each other./tmpfills up over time (ENOSPC).Repro on main: start
node tests/runner.js --only=exit-codestwice at once. One run passes, the other failsmigrate --help exits 0andvalidate --json with no errors exits 0, becausesetup()wipes a fixture dir the other run is still using./tmp/docmd-brute-testsis still there afterwards.Fix:
tests/shared.js:TEST_ROOTis created per run withfs.mkdtempSync(path.join(os.tmpdir(), 'docmd-tests-'))and removed on exit, SIGINT and SIGTERM.DOCMD_TEST_ROOT, so the child test processes the runner spawns reuse their parent run's dir and leave the cleanup to the parent. Running a test file directly still works: it creates and removes its own dir.tests/feature-integration.test.jsimportsTEST_ROOTfromshared.js;tests/security.test.jsuses asecurity/subdir of it, so its fixtures stay apart as before.tests/cli-contracts/test-root.test.js, registered astest-rootintests/runner.js.host-flagtitle intests/runner.jslost two ids from my own tracker (AC-2, AC-15) that slipped in with fix(cli): honour --host in docmd dev and workspace dev #269.Not changed:
tests/security.test.jsalso uses two fixed canary dirs (/tmp/docmd-openapi-canary,/tmp/docmd-evil-plugin). I left them alone to keep this PR small; happy to move them under the run root in a follow-up.Type of change
How it was verified
test-rootchecks that the root is directly underos.tmpdir()and nameddocmd-tests-*, that a second run (fresh process withoutDOCMD_TEST_ROOT) gets a different root and removes it when it exits, and that a child withDOCMD_TEST_ROOTset reuses the parent root and does not remove it.Results:
node tests/runner.js --only=test-root,exit-codes,plugin-contract,mcp-read-doc,features,security: 321 passed, 0 failed. Nodocmd-tests-*dir left in the temp dir afterwards.DOCMD_TEST_ROOTpointed at a known dir,--only=security,features(256 passed) writes the feature fixtures into it and the security fixtures into itssecurity/subdir, so the spawned test files do use the runner's root.node tests/runner.js --only=exit-codesat once: both pass (7 passed each). On main, one of them fails 2 checks.--only=featuresrun (SIGINT to the process group) removes the run's dir./tmp/docmd-brute-testsinshared.jsfails 4 of the 7test-rootchecks.Checklist: