Skip to content

Commit 71ec736

Browse files
committed
fix(cmd/mdsmith): address code-review round 1 findings
- Strengthen TestRunCheck_Stdin_ChecksSource and TestRunCheck_Discovered_ChecksConfiguredFiles: both fed clean Markdown and asserted only exit code 0, which a silent stdin-routing or discovery bug could also produce. Switch to content with a trailing-space diagnostic and assert exit code 1 plus the diagnostic source. - Close the pipe read end in TestRunCheck_Stdin_ChecksSource, matching the close-both-ends convention used elsewhere in this file. - Correct the touched-file count in the audit log (148, not 134 — two-dot diff --stat is the accurate count) and the internal/githooks line count cited in plan/2608021916 (1,346, not 1,347). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016AbFuwvqqq2fBiYWa3ubap
1 parent 5a2b5fb commit 71ec736

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

cmd/mdsmith/main_unit_test.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -836,18 +836,22 @@ func TestRunCheck_Stdin_ChecksSource(t *testing.T) {
836836
oldStdin := os.Stdin
837837
r, w, err := os.Pipe()
838838
require.NoError(t, err)
839+
defer r.Close() //nolint:errcheck // best-effort close on read-only pipe end
839840
os.Stdin = r
840841
defer func() { os.Stdin = oldStdin }()
841842
go func() {
842-
_, _ = w.WriteString("# Title\n\nContent here.\n")
843+
// Trailing spaces trigger a diagnostic, so a passing exit code
844+
// alone can't mask a routing bug that skips reading stdin.
845+
_, _ = w.WriteString("# Title\n\nHello \n")
843846
_ = w.Close()
844847
}()
845848

846849
var code int
847-
captureStderr(func() {
850+
stderr := captureStderr(func() {
848851
code = runCheck([]string{"-"})
849852
})
850-
assert.Equal(t, 0, code)
853+
assert.Equal(t, 1, code)
854+
assert.Contains(t, stderr, "<stdin>")
851855
}
852856

853857
func TestRunCheck_Files_ExitsOneOnDiagnostics(t *testing.T) {
@@ -868,15 +872,18 @@ func TestRunCheck_Discovered_ChecksConfiguredFiles(t *testing.T) {
868872
dir := t.TempDir()
869873
require.NoError(t, os.WriteFile(filepath.Join(dir, ".mdsmith.yml"),
870874
[]byte("files: [\"**/*.md\"]\n"), 0o644))
875+
// Trailing spaces trigger a diagnostic, so a passing exit code alone
876+
// can't mask a discovery bug that silently finds zero files.
871877
require.NoError(t, os.WriteFile(filepath.Join(dir, "test.md"),
872-
[]byte("# Title\n\nContent here.\n"), 0o644))
878+
[]byte("# Title\n\nHello \n"), 0o644))
873879
t.Chdir(dir)
874880

875881
var code int
876-
captureStderr(func() {
882+
stderr := captureStderr(func() {
877883
code = runCheck(nil)
878884
})
879-
assert.Equal(t, 0, code)
885+
assert.Equal(t, 1, code)
886+
assert.Contains(t, stderr, "test.md")
880887
}
881888

882889
// --- runFix ---

docs/development/architecture-audit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ every finding there is resolved.
1919

2020
## Audit 2026-08-02 (range: 6680ff5..2ab4b29)
2121

22-
134 touched files. Notable new surfaces: MDS073
22+
148 touched files. Notable new surfaces: MDS073
2323
slide-structure and MDS060 occurrence. MDS073 was
2424
renamed from MDS072; no leftover duplication was
2525
found. Also new: foreign-managed regions and

plan/2608021916_arch-fix-githooks-package-split.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ found this SRP smell:
3535
refactor-moves section: "Split a package by question.
3636
If the package doc comment requires 'and' to describe
3737
... the package wants to be two."
38-
- The file is 1,347 lines and cleanly separates into:
38+
- The file is 1,346 lines and cleanly separates into:
3939
- hook-script generation/validation
4040
(`BuildHookScript`, `HookMatchesCanonical`,
4141
the staging shell-function builder);

0 commit comments

Comments
 (0)