fix(testing): use UUIDs for Vitest include files · openclaw/openclaw@aa4978e
vincentkoc
·
2026-06-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@
|
2 | 2 | // scripts/test-projects.mjs, and focused tests. Exports are intentionally |
3 | 3 | // granular so project selection stays testable without spawning Vitest. |
4 | 4 | import { spawnSync } from "node:child_process"; |
| 5 | +import { randomUUID } from "node:crypto"; |
5 | 6 | import fs from "node:fs"; |
6 | 7 | import os from "node:os"; |
7 | 8 | import path from "node:path"; |
@@ -2674,7 +2675,7 @@ export function createVitestRunSpecs(args, params = {}) {
|
2674 | 2675 | const includeFilePath = plan.includePatterns |
2675 | 2676 | ? path.join( |
2676 | 2677 | params.tempDir ?? os.tmpdir(), |
2677 | | -`openclaw-vitest-include-${process.pid}-${Date.now()}-${index}.json`, |
| 2678 | +`openclaw-vitest-include-${randomUUID()}-${index}.json`, |
2678 | 2679 | ) |
2679 | 2680 | : null; |
2680 | 2681 | return { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -14,6 +14,7 @@ import {
|
14 | 14 | buildFullSuiteVitestRunPlans, |
15 | 15 | buildVitestArgs, |
16 | 16 | buildVitestRunPlans, |
| 17 | +createVitestRunSpecs, |
17 | 18 | findUnmatchedExplicitTestTargets, |
18 | 19 | formatFailedShardDigest, |
19 | 20 | listFullExtensionVitestProjectConfigs, |
@@ -1715,6 +1716,20 @@ describe("scripts/test-projects changed-target routing", () => {
|
1715 | 1716 | ]); |
1716 | 1717 | }); |
1717 | 1718 | |
| 1719 | +it("uses collision-resistant include-file names for scoped Vitest specs", () => { |
| 1720 | +const tempDir = path.join("tmp", "openclaw-vitest-specs"); |
| 1721 | +const [spec] = createVitestRunSpecs(["src/plugin-sdk/temp-path.test.ts"], { |
| 1722 | +baseEnv: {}, |
| 1723 | + tempDir, |
| 1724 | +}); |
| 1725 | + |
| 1726 | +expect(path.dirname(spec?.includeFilePath ?? "")).toBe(tempDir); |
| 1727 | +expect(path.basename(spec?.includeFilePath ?? "")).toMatch( |
| 1728 | +/^openclaw-vitest-include-[0-9a-f-]{36}-0\.json$/u, |
| 1729 | +); |
| 1730 | +expect(spec?.includeFilePath).not.toMatch(new RegExp(`${process.pid}-\\d+-0\\.json$`, "u")); |
| 1731 | +}); |
| 1732 | + |
1718 | 1733 | it("routes explicit commands light tests to the lighter commands lane", () => { |
1719 | 1734 | const plans = buildVitestRunPlans(["src/commands/status-json-runtime.test.ts"], process.cwd()); |
1720 | 1735 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。