Skip to content

Commit cbbb466

Browse files
committed
test(scripts): route docs i18n module changes
1 parent c2de9d0 commit cbbb466

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

scripts/test-projects.test-support.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,13 @@ function resolveDocsI18nBehaviorTargets(changedPath) {
26772677
return ["test/scripts/docs-i18n-behavior.test.ts"];
26782678
}
26792679

2680+
function resolveDocsI18nGoTargets(changedPath) {
2681+
if (!/^scripts\/docs-i18n\/(?:go\.(?:mod|sum)|[^/]+\.go)$/u.test(changedPath)) {
2682+
return null;
2683+
}
2684+
return ["test/scripts/docs-i18n.test.ts"];
2685+
}
2686+
26802687
function resolveK8sManifestTargets(changedPath) {
26812688
if (!/^scripts\/k8s\/manifests\/[^/]+\.yaml$/u.test(changedPath)) {
26822689
return null;
@@ -2714,6 +2721,7 @@ function resolveToolingTestTargets(changedPath, cwd = process.cwd()) {
27142721
TOOLING_TEST_TARGETS.get(changedPath) ??
27152722
resolveUpgradeSurvivorConfigRecipeTargets(changedPath) ??
27162723
resolveDocsI18nBehaviorTargets(changedPath) ??
2724+
resolveDocsI18nGoTargets(changedPath) ??
27172725
resolveK8sManifestTargets(changedPath) ??
27182726
resolveParallelsToolingTestTargets(changedPath);
27192727
const conventionalTargets = resolveConventionalToolingTestTargets(changedPath, cwd);

test/scripts/docs-i18n.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Docs i18n tests cover the Go module backing docs translation.
2+
import { spawnSync } from "node:child_process";
3+
import { describe, expect, it } from "vitest";
4+
5+
describe("docs-i18n Go module", () => {
6+
it("passes Go tests", () => {
7+
const result = spawnSync("go", ["test", "./...", "-count=1"], {
8+
cwd: "scripts/docs-i18n",
9+
encoding: "utf8",
10+
});
11+
12+
expect(result.error).toBeUndefined();
13+
expect(result.status, result.stderr || result.stdout).toBe(0);
14+
});
15+
});

test/scripts/test-projects.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,19 @@ describe("scripts/test-projects changed-target routing", () => {
10841084
}
10851085
});
10861086

1087+
it("keeps docs i18n Go module edits on Go module tests", () => {
1088+
for (const modulePath of [
1089+
"scripts/docs-i18n/main.go",
1090+
"scripts/docs-i18n/main_test.go",
1091+
"scripts/docs-i18n/go.mod",
1092+
]) {
1093+
expect(resolveChangedTestTargetPlan([modulePath]), modulePath).toEqual({
1094+
mode: "targets",
1095+
targets: ["test/scripts/docs-i18n.test.ts"],
1096+
});
1097+
}
1098+
});
1099+
10871100
it("keeps k8s manifest edits on manifest tests", () => {
10881101
expect(resolveChangedTestTargetPlan(["scripts/k8s/manifests/configmap.yaml"])).toEqual({
10891102
mode: "targets",

0 commit comments

Comments
 (0)