























@@ -8,6 +8,7 @@ import os from "node:os";
88import path from "node:path";
99import { isChannelSurfaceTestFile } from "../test/vitest/vitest.channel-paths.mjs";
1010import {
11+commandsLightTestFiles,
1112isCommandsLightTarget,
1213resolveCommandsLightIncludePattern,
1314} from "../test/vitest/vitest.commands-light-paths.mjs";
@@ -37,11 +38,13 @@ import { isWhatsAppExtensionRoot } from "../test/vitest/vitest.extension-whatsap
3738import { isZaloExtensionRoot } from "../test/vitest/vitest.extension-zalo-paths.mjs";
3839import {
3940isPluginSdkLightTarget,
41+pluginSdkLightTestFiles,
4042resolvePluginSdkLightIncludePattern,
4143} from "../test/vitest/vitest.plugin-sdk-paths.mjs";
4244import { fullSuiteVitestShards } from "../test/vitest/vitest.test-shards.mjs";
4345import { isUnitUiTestTarget } from "../test/vitest/vitest.ui-paths.mjs";
4446import {
47+getUnitFastTestFiles,
4548resolveUnitFastTestIncludePattern,
4649resolveUnitFastTimerTestIncludePattern,
4750} from "../test/vitest/vitest.unit-fast-paths.mjs";
@@ -255,6 +258,10 @@ function uniqueOrdered(values) {
255258return [...new Set(values)];
256259}
257260261+function isPathAtOrUnder(relative, root) {
262+return relative === root || relative.startsWith(`${root}/`);
263+}
264+258265/**
259266 * Orders full-suite specs so expensive shards start first in parallel runs.
260267 */
@@ -1179,13 +1186,66 @@ function expandExplicitSourceTestTargets(targetArgs, cwd) {
11791186if (relative === "src/commands" && isExistingDirectoryTarget(targetArg, cwd)) {
11801187return [COMMANDS_LIGHT_VITEST_CONFIG, COMMANDS_VITEST_CONFIG];
11811188}
1189+const exactDirectoryTargets = resolveExactSourceDirectoryTestTargets(targetArg, cwd);
1190+if (exactDirectoryTargets) {
1191+return exactDirectoryTargets;
1192+}
11821193const targets = resolveExplicitSourceTestTargets(targetArg, cwd, {
11831194 forceFullImportGraph,
11841195});
11851196return targets && targets.length > 0 ? targets : [targetArg];
11861197});
11871198}
118811991200+const exactSourceDirectoryRoots = [
1201+"src/acp",
1202+"src/agents",
1203+"src/auto-reply",
1204+"src/channels",
1205+"src/cli",
1206+"src/commands",
1207+"src/config",
1208+"src/cron",
1209+"src/daemon",
1210+"src/gateway",
1211+"src/hooks",
1212+"src/infra",
1213+"src/logging",
1214+"src/media",
1215+"src/media-understanding",
1216+"src/plugin-sdk",
1217+"src/plugins",
1218+"src/process",
1219+"src/secrets",
1220+"src/shared",
1221+"src/tasks",
1222+"src/tui",
1223+"src/utils",
1224+"src/wizard",
1225+"ui/src",
1226+];
1227+1228+function isExactSourceDirectoryTarget(relative) {
1229+return exactSourceDirectoryRoots.some((root) => isPathAtOrUnder(relative, root));
1230+}
1231+1232+function resolveExactSourceDirectoryTestTargets(targetArg, cwd) {
1233+if (!isExistingDirectoryTarget(targetArg, cwd)) {
1234+return null;
1235+}
1236+const relative = toRepoRelativeTarget(targetArg, cwd).replace(/\/+$/u, "");
1237+if (!isExactSourceDirectoryTarget(relative)) {
1238+return null;
1239+}
1240+const prefix = `${relative}/`;
1241+const lightTargets = uniqueOrdered([
1242+ ...getUnitFastTestFiles(),
1243+ ...pluginSdkLightTestFiles,
1244+ ...commandsLightTestFiles,
1245+]).filter((file) => file.startsWith(prefix));
1246+return lightTargets.length > 0 ? [...lightTargets, targetArg] : null;
1247+}
1248+11891249/**
11901250 * Finds explicit test path targets that do not match any known project plan.
11911251 */
@@ -1935,7 +1995,7 @@ function classifyTarget(arg, cwd) {
19351995if (isControlUiE2eTarget(relative)) {
19361996return "uiE2e";
19371997}
1938-if (relative.startsWith("ui/src/")) {
1998+if (isPathAtOrUnder(relative, "ui/src")) {
19391999if (isUnitUiTestTarget(relative)) {
19402000return "unitUi";
19412001}
@@ -2066,76 +2126,76 @@ function classifyTarget(arg, cwd) {
20662126if (isBundledPluginDependentUnitTestFile(relative)) {
20672127return "bundled";
20682128}
2069-if (relative.startsWith("src/channels/")) {
2129+if (isPathAtOrUnder(relative, "src/channels")) {
20702130return "channel";
20712131}
2072-if (relative.startsWith("src/gateway/")) {
2132+if (isPathAtOrUnder(relative, "src/gateway")) {
20732133return "gateway";
20742134}
2075-if (relative.startsWith("src/hooks/")) {
2135+if (isPathAtOrUnder(relative, "src/hooks")) {
20762136return "hooks";
20772137}
2078-if (relative.startsWith("src/infra/")) {
2138+if (isPathAtOrUnder(relative, "src/infra")) {
20792139return "infra";
20802140}
2081-if (relative.startsWith("src/config/")) {
2141+if (isPathAtOrUnder(relative, "src/config")) {
20822142return "runtimeConfig";
20832143}
2084-if (relative.startsWith("src/cron/")) {
2144+if (isPathAtOrUnder(relative, "src/cron")) {
20852145return "cron";
20862146}
2087-if (relative.startsWith("src/daemon/")) {
2147+if (isPathAtOrUnder(relative, "src/daemon")) {
20882148return "daemon";
20892149}
2090-if (relative.startsWith("src/media-understanding/")) {
2150+if (isPathAtOrUnder(relative, "src/media-understanding")) {
20912151return "mediaUnderstanding";
20922152}
2093-if (relative.startsWith("src/media/")) {
2153+if (isPathAtOrUnder(relative, "src/media")) {
20942154return "media";
20952155}
2096-if (relative.startsWith("src/logging/")) {
2156+if (isPathAtOrUnder(relative, "src/logging")) {
20972157return "logging";
20982158}
2099-if (relative.startsWith("src/plugin-sdk/")) {
2159+if (isPathAtOrUnder(relative, "src/plugin-sdk")) {
21002160return isPluginSdkLightTarget(relative) ? "pluginSdkLight" : "pluginSdk";
21012161}
2102-if (relative.startsWith("src/process/")) {
2162+if (isPathAtOrUnder(relative, "src/process")) {
21032163return "process";
21042164}
2105-if (relative.startsWith("src/secrets/")) {
2165+if (isPathAtOrUnder(relative, "src/secrets")) {
21062166return "secrets";
21072167}
2108-if (relative.startsWith("src/shared/")) {
2168+if (isPathAtOrUnder(relative, "src/shared")) {
21092169return "sharedCore";
21102170}
2111-if (relative.startsWith("src/tasks/")) {
2171+if (isPathAtOrUnder(relative, "src/tasks")) {
21122172return "tasks";
21132173}
2114-if (relative.startsWith("src/tui/")) {
2174+if (isPathAtOrUnder(relative, "src/tui")) {
21152175return "tui";
21162176}
2117-if (relative.startsWith("src/acp/")) {
2177+if (isPathAtOrUnder(relative, "src/acp")) {
21182178return "acp";
21192179}
2120-if (relative.startsWith("src/cli/")) {
2180+if (isPathAtOrUnder(relative, "src/cli")) {
21212181return "cli";
21222182}
2123-if (relative.startsWith("src/commands/")) {
2183+if (isPathAtOrUnder(relative, "src/commands")) {
21242184return isCommandsLightTarget(relative) ? "commandLight" : "command";
21252185}
2126-if (relative.startsWith("src/auto-reply/")) {
2186+if (isPathAtOrUnder(relative, "src/auto-reply")) {
21272187return "autoReply";
21282188}
2129-if (relative.startsWith("src/agents/")) {
2189+if (isPathAtOrUnder(relative, "src/agents")) {
21302190return "agent";
21312191}
2132-if (relative.startsWith("src/plugins/")) {
2192+if (isPathAtOrUnder(relative, "src/plugins")) {
21332193return "plugin";
21342194}
2135-if (relative.startsWith("src/utils/")) {
2195+if (isPathAtOrUnder(relative, "src/utils")) {
21362196return "utils";
21372197}
2138-if (relative.startsWith("src/wizard/")) {
2198+if (isPathAtOrUnder(relative, "src/wizard")) {
21392199return "wizard";
21402200}
21412201return "default";
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。