Expose Markdown validation selection

This commit is contained in:
2026-10-07 23:26:48 +00:00
parent 6397d41517
commit 40068af1bf
20 changed files with 403 additions and 23 deletions

View File

@@ -192,6 +192,49 @@ func TestCheckMarkdownLinksPreservesAnchorReadCause(t *testing.T) {
}
}
func TestRunSelectsMarkdownWithCombinedGoChecksAndReportsOutOfScopeLinks(t *testing.T) {
repository, _ := committedMarkdownTree(t, map[string][]byte{
"guide.md": []byte("[outside](../../outside.md)\n"),
})
commit := strings.TrimSpace(gitTree(t, repository, "rev-parse", "HEAD"))
goLog := installGoShim(t, "", false)
var output bytes.Buffer
err := Run(context.Background(), Request{
RepositoryDir: repository,
Commit: commit,
Output: &output,
Settings: Settings{
Race: true,
FullVet: true,
CompileTargets: []Target{{OS: "linux", Arch: "amd64"}},
Markdown: &MarkdownSettings{},
},
})
if err != nil {
t.Fatalf("Run() error = %v, want out-of-scope observation to succeed", err)
}
if got := output.String(); !strings.Contains(got, "outside the checkout") || !strings.Contains(got, "out of scope") {
t.Fatalf("Run() output = %q, want outside-checkout observation", got)
}
commands := readGoShimLog(t, goLog)
var testCommands []string
var validationCommands []string
for _, command := range commands {
if strings.HasPrefix(command, "test ") {
testCommands = append(testCommands, command)
}
if strings.HasPrefix(command, "test ") || strings.HasPrefix(command, "vet ") || strings.HasPrefix(command, "build ") {
validationCommands = append(validationCommands, command)
}
}
if len(testCommands) != 1 || !strings.Contains(testCommands[0], "-race") || !strings.Contains(testCommands[0], "-vet=off") {
t.Fatalf("Go test commands = %#v, want one race-enabled suite with test-time vet disabled", testCommands)
}
if len(validationCommands) != 3 || !strings.HasPrefix(validationCommands[0], "test ") || !strings.HasPrefix(validationCommands[1], "vet ") || !strings.HasPrefix(validationCommands[2], "build ") {
t.Fatalf("Go validation commands = %#v, want test, full vet, and target compilation before Markdown", validationCommands)
}
}
func committedMarkdownTree(t *testing.T, files map[string][]byte) (string, *CandidateTree) {
t.Helper()
repository := newTreeRepository(t)