You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b575bbd
Browse filesBrowse the repository at this point in the historyBrowse files
fix: the test sandbox travels with each engine test, and the engine ignores the test runner
The engine refused to start when NODE_TEST_CONTEXT was in its environment
without a sandbox, and the preload npm test adds sandboxed every test file.
Node's test runner sets that variable for every process it starts, so an
engine command started from a repository's own test exited 1, and such a
test could no longer run the engine on its repository or write a file into
it. Both worked before the sandbox existed.
The sandbox is now a module, tests/engine-sandbox.ts, that every engine
test file imports first: the temporary directory for the engine and the
node:fs guard on the repository. It holds however the file is started, by
hand without the preload included. tests/no-vapi-api.ts is what it was
before the sandbox, and src/base-dir.ts never looks at the test runner's
environment. A test file that doesn't import the module is left alone: the
commands it starts and the engine modules it imports work in its
repository, and it writes where it likes.
In the engine's own repository (a runner whose GITHUB_REPOSITORY is
VapiAI/gitops, or a clone whose origin is) a test file without the import
fails the suite. In any other repository that check is skipped.
tests/base-dir.test.ts fails when a module under src/ works out the
repository's directory for itself.
npm test no longer starts a test runner inside a test. The suite run
inside copies of a customer-shaped repository, and the other tests that
start a runner of their own, move to tests/repository/ and run with
npm run test:repository, one file at a time, and as a CI job in the
engine's own repository. A suite inside a suite tripled the time npm test
took and reached the twenty-second limits some tests give a command
sooner on a slow machine. Each copy now holds a test of the customer's
own and runs the engine's test files only.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/guides/commands.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ The other commands are direct only.
23
23
|`npm run promote`|`npm run promote -- --pipeline <p> --from <org> --to <org> [--apply]`| Plan, or apply, a [promotion](promotion.md) between orgs. |
24
24
|`npm run build`|`npm run build`| Type-check the code and tests. |
25
25
|`npm test`|`npm test`| Run the test suite. |
26
+
|`npm run test:repository`|`npm run test:repository`| For work on the engine itself: run the test suite inside copies of a repository and check that no file in them changed. Takes a few minutes. |
26
27
27
28
Pull and push never automatically rename UUID-suffixed state keys to match
28
29
local files. A local file without a UUID mapping remains subject to the
// Node's test runner sets this for every test file it runs. Without the
18
-
// sandbox a test would read and write the real repository: refuse.
19
-
if(process.env.NODE_TEST_CONTEXT)
20
-
thrownewError(
21
-
"The engine was loaded by a test without tests/no-vapi-api.ts, so it would work in this repository instead of a temporary directory. Run tests with `npm test` or `node --import tsx --import ./tests/no-vapi-api.ts --test <file>`.",
0 commit comments