From d88ab37a32b730431a0adbb31922f34c5e2fec3b Mon Sep 17 00:00:00 2001
From: K1-R1 <77465250+K1-R1@users.noreply.github.com>
Date: Sun, 15 Mar 2026 12:25:59 +0000
Subject: [PATCH 1/3] test: add golden file acceptance testing
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Introduce a comprehensive golden file test suite that verifies smoosh
output is byte-for-byte correct across all modes, formats, and feature
combinations. Adds 17 new @test blocks (215 total, up from 198).
- test/fixtures/golden-repo/ — 19 fixture files (no .git/) covering
docs, code, config, hidden files, edge cases (empty, no-newline,
CDATA, deeply nested paths, secrets pattern, unicode-safe content)
- test/smoosh_golden.bats — golden test runner with normalise() to
strip timestamps and temp paths, UPDATE_GOLDEN=1 to regenerate, and
Bash 3.2-compatible chunked test using find + while loop
- test/golden/expected/ — 17 committed expected output files covering
docs/code/all modes, text/xml/md formats, TOC, line numbers, filter
flags (--only, --exclude, --include), chunking, hidden files, and
the stdout/stderr outputs (--dry-run, --json, --quiet)
- test/ACCEPTANCE.md — manual test runbook for interactive mode,
remote repo, NotebookLM, Claude Projects, ChatGPT, secrets
detection, agent/CI usage, and golden file regression
- CONTRIBUTING.md — UPDATE_GOLDEN=1 workflow documented
- README.md — test count updated from 198 to 215
- .gitignore — negation rule for test/fixtures/golden-repo/.env.example
Signed-off-by: K1-R1 <77465250+K1-R1@users.noreply.github.com>
---
.gitignore | 3 +
CONTRIBUTING.md | 21 ++
README.md | 2 +-
test/ACCEPTANCE.md | 265 +++++++++++++++++
test/fixtures/golden-repo/.env.example | 3 +
test/fixtures/golden-repo/.github/ci.yml | 8 +
test/fixtures/golden-repo/Makefile | 7 +
test/fixtures/golden-repo/README.md | 4 +
test/fixtures/golden-repo/app.py | 11 +
test/fixtures/golden-repo/aws-creds.py | 4 +
test/fixtures/golden-repo/cdata-break.md | 4 +
.../golden-repo/deep/nested/path/doc.md | 4 +
test/fixtures/golden-repo/empty.md | 0
test/fixtures/golden-repo/guide.rst | 5 +
test/fixtures/golden-repo/index.js | 9 +
test/fixtures/golden-repo/journal.org | 7 +
test/fixtures/golden-repo/main.go | 12 +
test/fixtures/golden-repo/manual.adoc | 5 +
test/fixtures/golden-repo/no-newline.md | 1 +
test/fixtures/golden-repo/notes.txt | 4 +
test/fixtures/golden-repo/package.json | 5 +
test/fixtures/golden-repo/paper.tex | 6 +
test/fixtures/golden-repo/src/lib.rs | 9 +
test/golden/expected/all-md.golden | 206 ++++++++++++++
test/golden/expected/chunked-md.golden | 114 ++++++++
test/golden/expected/code-md.golden | 192 +++++++++++++
test/golden/expected/code-xml-toc.golden | 251 +++++++++++++++++
.../expected/docs-md-line-numbers.golden | 111 ++++++++
.../expected/docs-md-toc-line-numbers.golden | 128 +++++++++
test/golden/expected/docs-md-toc.golden | 128 +++++++++
test/golden/expected/docs-md.golden | 111 ++++++++
test/golden/expected/docs-text.golden | 112 ++++++++
test/golden/expected/docs-xml.golden | 121 ++++++++
test/golden/expected/dry-run.golden | 20 ++
test/golden/expected/exclude-deep-md.golden | 100 +++++++
test/golden/expected/include-hidden-md.golden | 239 ++++++++++++++++
test/golden/expected/include-json-md.golden | 123 ++++++++
test/golden/expected/json.golden | 13 +
test/golden/expected/only-py-md.golden | 20 ++
test/golden/expected/quiet.golden | 1 +
test/smoosh_golden.bats | 266 ++++++++++++++++++
41 files changed, 2654 insertions(+), 1 deletion(-)
create mode 100644 test/ACCEPTANCE.md
create mode 100644 test/fixtures/golden-repo/.env.example
create mode 100644 test/fixtures/golden-repo/.github/ci.yml
create mode 100644 test/fixtures/golden-repo/Makefile
create mode 100644 test/fixtures/golden-repo/README.md
create mode 100644 test/fixtures/golden-repo/app.py
create mode 100644 test/fixtures/golden-repo/aws-creds.py
create mode 100644 test/fixtures/golden-repo/cdata-break.md
create mode 100644 test/fixtures/golden-repo/deep/nested/path/doc.md
create mode 100644 test/fixtures/golden-repo/empty.md
create mode 100644 test/fixtures/golden-repo/guide.rst
create mode 100644 test/fixtures/golden-repo/index.js
create mode 100644 test/fixtures/golden-repo/journal.org
create mode 100644 test/fixtures/golden-repo/main.go
create mode 100644 test/fixtures/golden-repo/manual.adoc
create mode 100644 test/fixtures/golden-repo/no-newline.md
create mode 100644 test/fixtures/golden-repo/notes.txt
create mode 100644 test/fixtures/golden-repo/package.json
create mode 100644 test/fixtures/golden-repo/paper.tex
create mode 100644 test/fixtures/golden-repo/src/lib.rs
create mode 100644 test/golden/expected/all-md.golden
create mode 100644 test/golden/expected/chunked-md.golden
create mode 100644 test/golden/expected/code-md.golden
create mode 100644 test/golden/expected/code-xml-toc.golden
create mode 100644 test/golden/expected/docs-md-line-numbers.golden
create mode 100644 test/golden/expected/docs-md-toc-line-numbers.golden
create mode 100644 test/golden/expected/docs-md-toc.golden
create mode 100644 test/golden/expected/docs-md.golden
create mode 100644 test/golden/expected/docs-text.golden
create mode 100644 test/golden/expected/docs-xml.golden
create mode 100644 test/golden/expected/dry-run.golden
create mode 100644 test/golden/expected/exclude-deep-md.golden
create mode 100644 test/golden/expected/include-hidden-md.golden
create mode 100644 test/golden/expected/include-json-md.golden
create mode 100644 test/golden/expected/json.golden
create mode 100644 test/golden/expected/only-py-md.golden
create mode 100644 test/golden/expected/quiet.golden
create mode 100644 test/smoosh_golden.bats
diff --git a/.gitignore b/.gitignore
index 95272ef..1480bb3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,6 @@ todos/
# test artefacts
/tmp/
+
+# fixture files that intentionally resemble secrets/env files
+!test/fixtures/golden-repo/.env.example
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 827ac61..a82685f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -41,6 +41,27 @@ bats test/*.bats # all tests
bats test/smoosh_args.bats # specific file
```
+## Golden File Tests
+
+The golden file suite (`test/smoosh_golden.bats`) verifies that smoosh output
+is byte-for-byte correct across all modes, formats, and feature combinations.
+
+If you intentionally change smoosh's output format (for example, adding a new
+header field or changing the section separator), regenerate the expected files:
+
+```bash
+UPDATE_GOLDEN=1 bats test/smoosh_golden.bats
+```
+
+Then review the diff to confirm the changes are intentional before committing:
+
+```bash
+git diff test/golden/
+```
+
+The golden files live in `test/golden/expected/`. Never edit them by hand —
+always use `UPDATE_GOLDEN=1` to regenerate them from a passing smoosh run.
+
## Updating the Demos
The demos are recorded with [VHS](https://github.com/charmbracelet/vhs)
diff --git a/README.md b/README.md
index 9ad2c4a..edbe230 100644
--- a/README.md
+++ b/README.md
@@ -323,7 +323,7 @@ smoosh counts words using `wc -w`, which splits on whitespace. Code files
with dense syntax (JSON, minified JS) count differently than prose.
**Is it overengineered for a shell script?**
-Absolutely. 198 tests, 100% file inclusion verification, CDATA escaping for
+Absolutely. 215 tests, 100% file inclusion verification, CDATA escaping for
XML output, and a box-drawing letter logo. But your codebase deserves to be
smooshed properly.
diff --git a/test/ACCEPTANCE.md b/test/ACCEPTANCE.md
new file mode 100644
index 0000000..67b3908
--- /dev/null
+++ b/test/ACCEPTANCE.md
@@ -0,0 +1,265 @@
+# smoosh Acceptance Test Runbook
+
+This document describes the manual acceptance tests for smoosh. Run these
+before any major release or when the automated tests are insufficient to
+verify a change — for example, when interactive mode, network behaviour, or
+AI tool integration is involved.
+
+All automated tests can be run with `bats test/*.bats`. The scenarios below
+cover what cannot be automated: interactive TTY behaviour and end-to-end
+upload flows with real AI tools.
+
+---
+
+## Setup
+
+Install smoosh or build from source:
+
+ brew install K1-R1/tap/smoosh # installed release
+ # or
+ ./smoosh --version # local dev build (run from repo root)
+
+Pick a real git repository to test against — the smoosh repo itself works
+well. All examples below use `.` for the current directory.
+
+---
+
+## 1. Interactive Mode
+
+smoosh opens an interactive guided experience when called with no arguments
+in a real terminal (TTY).
+
+**Steps:**
+
+1. Open a terminal (not inside a script or pipe).
+2. Change into any git repository: `cd /path/to/some/repo`
+3. Run `smoosh` with no arguments.
+
+**Expected behaviour:**
+
+- The logo and tagline appear.
+- smoosh scans the repo and shows a summary table: docs, code, config, and
+ other file counts with example extensions.
+- A prompt asks which mode to use (`docs`, `code`, `all`, or `q` to quit).
+- After selecting a mode, smoosh processes and writes output to `_smooshes/`.
+- A summary table shows file count, word count, token estimate, and chunk count.
+
+**Pass criteria:**
+
+- [ ] Interactive prompt appears (not skipped)
+- [ ] Repo scan table shows plausible file counts
+- [ ] Selecting `docs` produces `.md` output files
+- [ ] Output lands in `_smooshes/`
+- [ ] No error messages or stack traces
+
+---
+
+## 2. Remote Repository
+
+smoosh can clone and process a remote repo in a single command.
+
+**Steps:**
+
+ smoosh https://github.com/K1-R1/smoosh
+
+**Expected behaviour:**
+
+- smoosh clones the repo to a temp directory.
+- Processes it in docs mode (default).
+- Writes output to `_smooshes/` in the current directory (not inside the
+ clone).
+- Cleans up the temp clone on exit.
+
+**Pass criteria:**
+
+- [ ] Clone succeeds (no "Remote clone failed" error)
+- [ ] Output files appear in `_smooshes/` of the working directory
+- [ ] Output contains smoosh's own `README.md` content
+- [ ] Temp clone is removed after the run
+
+---
+
+## 3. NotebookLM Upload
+
+Verify that smoosh output can be uploaded to NotebookLM and queried.
+
+**Steps:**
+
+1. Run smoosh on a real codebase:
+
+ cd /path/to/some/repo
+ smoosh --code
+
+2. Go to [notebooklm.google.com](https://notebooklm.google.com) and create
+ a new notebook.
+3. Click **Add source → Upload file**.
+4. Upload each `.md` file from `_smooshes/`.
+5. Wait for processing (usually 30–60 seconds).
+6. Ask a question that can only be answered with the uploaded content, for
+ example:
+ - "What functions are defined in this codebase?"
+ - "What does the main entry point do?"
+ - "List all the files included in this upload."
+
+**Pass criteria:**
+
+- [ ] Upload succeeds (no error from NotebookLM)
+- [ ] NotebookLM answers questions using specific file content (cites sources)
+- [ ] Answer is not a hallucination (verifiable against the actual code)
+- [ ] Word count per file is within NotebookLM's 500,000-word limit per source
+
+**NotebookLM plan limits (early 2026):**
+
+| Plan | Max sources | Max words/source |
+|-------|-------------|------------------|
+| Free | 50 | 500,000 |
+| Plus | 300 | 500,000 |
+| Ultra | 600 | 500,000 |
+
+---
+
+## 4. Claude Projects Upload
+
+Verify that smoosh output can be added to a Claude Project and queried.
+
+**Steps:**
+
+1. Run smoosh:
+
+ smoosh --code
+
+2. Go to [claude.ai](https://claude.ai) and open or create a Project.
+3. Open the project knowledge panel.
+4. Upload the files from `_smooshes/`.
+5. Start a conversation and ask a code-specific question, for example:
+ - "What language is the main entry point written in?"
+ - "Are there any tests in this codebase?"
+
+**Pass criteria:**
+
+- [ ] Upload succeeds
+- [ ] Claude answers using specific content from the uploaded files
+- [ ] Claude does not claim it cannot access the files
+
+---
+
+## 5. ChatGPT Upload
+
+Verify that smoosh output can be attached to a ChatGPT conversation.
+
+**Steps:**
+
+1. Run smoosh:
+
+ smoosh --code
+
+2. Open [chatgpt.com](https://chatgpt.com) and start a new conversation.
+3. Attach the files from `_smooshes/` using the paperclip icon.
+4. Ask a specific question about the uploaded codebase.
+
+**Pass criteria:**
+
+- [ ] Files attach without errors
+- [ ] ChatGPT answers using content from the uploaded files
+- [ ] For repos with multiple chunks: all chunks can be attached
+
+---
+
+## 6. Secrets Detection
+
+Verify that secrets are flagged and excluded from output.
+
+**Steps:**
+
+1. Create a temporary test repo:
+
+ mkdir /tmp/secrets-test && cd /tmp/secrets-test
+ git init && git config user.email "t@t.com" && git config user.name "T"
+ echo '# Docs' > README.md
+ echo 'AWS_ACCESS_KEY_ID = "AKIAIOSFODNN7EXAMPLE"' > creds.py
+ git add -A && git commit -m "init"
+
+2. Run smoosh:
+
+ smoosh --code .
+
+**Expected behaviour:**
+
+- smoosh prints a secrets warning mentioning `creds.py`.
+- The warning includes a disclaimer ("basic pattern matching only").
+- `creds.py` does not appear in the output files.
+- `README.md` appears in the output files.
+- Exit code is 0 (secrets detected is a warning, not a failure).
+
+**Pass criteria:**
+
+- [ ] Warning appears on stderr
+- [ ] `creds.py` content is absent from `_smooshes/` output
+- [ ] `README.md` content is present in `_smooshes/` output
+- [ ] Exit code is 0
+
+---
+
+## 7. Agent / CI Usage
+
+Verify that smoosh works in a headless, non-interactive environment.
+
+**Steps:**
+
+ smoosh --code --no-interactive --json --quiet . 2>/dev/null
+
+**Expected behaviour:** an error — `--json` and `--quiet` cannot be combined.
+
+Then:
+
+ smoosh --code --no-interactive --json . 2>/dev/null | jq .
+
+**Expected behaviour:**
+
+- Valid JSON is printed to stdout.
+- JSON includes `repo`, `files_processed`, `total_words`, `chunks`, and
+ `exit_code` fields.
+- Exit code is 0.
+
+**Pass criteria:**
+
+- [ ] `--json` and `--quiet` together print an error and exit 1
+- [ ] `--json` alone produces valid, parseable JSON
+- [ ] `exit_code` in JSON matches the actual process exit code
+
+---
+
+## 8. Regression: Golden File Tests
+
+The automated golden file tests (run as part of `bats test/*.bats`) verify
+that smoosh output is byte-for-byte identical to the checked-in expected
+files. Run them to confirm no regressions:
+
+ bats test/smoosh_golden.bats
+
+All 17 tests should pass.
+
+If you intentionally change smoosh's output format (for example, adding a
+new header field), regenerate the golden files:
+
+ UPDATE_GOLDEN=1 bats test/smoosh_golden.bats
+
+Then review `git diff test/golden/` to confirm the changes are intentional
+before committing.
+
+---
+
+## Completing a Release Acceptance Run
+
+Tick every checkbox above, then record the result:
+
+| Scenario | Result | Notes |
+|----------|--------|-------|
+| 1. Interactive mode | Pass / Fail | |
+| 2. Remote repository | Pass / Fail | |
+| 3. NotebookLM upload | Pass / Fail | |
+| 4. Claude Projects upload | Pass / Fail | |
+| 5. ChatGPT upload | Pass / Fail | |
+| 6. Secrets detection | Pass / Fail | |
+| 7. Agent / CI usage | Pass / Fail | |
+| 8. Golden file tests | Pass / Fail | |
diff --git a/test/fixtures/golden-repo/.env.example b/test/fixtures/golden-repo/.env.example
new file mode 100644
index 0000000..17535e8
--- /dev/null
+++ b/test/fixtures/golden-repo/.env.example
@@ -0,0 +1,3 @@
+DATABASE_URL=postgres://localhost:5432/mydb
+SECRET_KEY=your-secret-key-here
+DEBUG=false
diff --git a/test/fixtures/golden-repo/.github/ci.yml b/test/fixtures/golden-repo/.github/ci.yml
new file mode 100644
index 0000000..5b8caa4
--- /dev/null
+++ b/test/fixtures/golden-repo/.github/ci.yml
@@ -0,0 +1,8 @@
+name: CI
+on: [push, pull_request]
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - run: echo "Golden fixture CI workflow"
diff --git a/test/fixtures/golden-repo/Makefile b/test/fixtures/golden-repo/Makefile
new file mode 100644
index 0000000..b0eb533
--- /dev/null
+++ b/test/fixtures/golden-repo/Makefile
@@ -0,0 +1,7 @@
+.PHONY: all clean
+
+all:
+ @echo "Golden fixture Makefile"
+
+clean:
+ @echo "Nothing to clean"
diff --git a/test/fixtures/golden-repo/README.md b/test/fixtures/golden-repo/README.md
new file mode 100644
index 0000000..a2c2777
--- /dev/null
+++ b/test/fixtures/golden-repo/README.md
@@ -0,0 +1,4 @@
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
diff --git a/test/fixtures/golden-repo/app.py b/test/fixtures/golden-repo/app.py
new file mode 100644
index 0000000..c3e98b9
--- /dev/null
+++ b/test/fixtures/golden-repo/app.py
@@ -0,0 +1,11 @@
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
diff --git a/test/fixtures/golden-repo/aws-creds.py b/test/fixtures/golden-repo/aws-creds.py
new file mode 100644
index 0000000..f0718ce
--- /dev/null
+++ b/test/fixtures/golden-repo/aws-creds.py
@@ -0,0 +1,4 @@
+# Golden fixture secrets file.
+# This file contains a fake AWS key for secrets detection testing.
+AWS_ACCESS_KEY_ID = "AKIAIOSFODNN7EXAMPLE"
+AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
diff --git a/test/fixtures/golden-repo/cdata-break.md b/test/fixtures/golden-repo/cdata-break.md
new file mode 100644
index 0000000..a71dbef
--- /dev/null
+++ b/test/fixtures/golden-repo/cdata-break.md
@@ -0,0 +1,4 @@
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
diff --git a/test/fixtures/golden-repo/deep/nested/path/doc.md b/test/fixtures/golden-repo/deep/nested/path/doc.md
new file mode 100644
index 0000000..c345958
--- /dev/null
+++ b/test/fixtures/golden-repo/deep/nested/path/doc.md
@@ -0,0 +1,4 @@
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
diff --git a/test/fixtures/golden-repo/empty.md b/test/fixtures/golden-repo/empty.md
new file mode 100644
index 0000000..e69de29
diff --git a/test/fixtures/golden-repo/guide.rst b/test/fixtures/golden-repo/guide.rst
new file mode 100644
index 0000000..03a5d29
--- /dev/null
+++ b/test/fixtures/golden-repo/guide.rst
@@ -0,0 +1,5 @@
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
diff --git a/test/fixtures/golden-repo/index.js b/test/fixtures/golden-repo/index.js
new file mode 100644
index 0000000..90e3dbc
--- /dev/null
+++ b/test/fixtures/golden-repo/index.js
@@ -0,0 +1,9 @@
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
diff --git a/test/fixtures/golden-repo/journal.org b/test/fixtures/golden-repo/journal.org
new file mode 100644
index 0000000..f91e9ff
--- /dev/null
+++ b/test/fixtures/golden-repo/journal.org
@@ -0,0 +1,7 @@
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
diff --git a/test/fixtures/golden-repo/main.go b/test/fixtures/golden-repo/main.go
new file mode 100644
index 0000000..c692b02
--- /dev/null
+++ b/test/fixtures/golden-repo/main.go
@@ -0,0 +1,12 @@
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
diff --git a/test/fixtures/golden-repo/manual.adoc b/test/fixtures/golden-repo/manual.adoc
new file mode 100644
index 0000000..18e720c
--- /dev/null
+++ b/test/fixtures/golden-repo/manual.adoc
@@ -0,0 +1,5 @@
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
diff --git a/test/fixtures/golden-repo/no-newline.md b/test/fixtures/golden-repo/no-newline.md
new file mode 100644
index 0000000..56d2633
--- /dev/null
+++ b/test/fixtures/golden-repo/no-newline.md
@@ -0,0 +1 @@
+This file has no trailing newline at the end.
\ No newline at end of file
diff --git a/test/fixtures/golden-repo/notes.txt b/test/fixtures/golden-repo/notes.txt
new file mode 100644
index 0000000..7326c96
--- /dev/null
+++ b/test/fixtures/golden-repo/notes.txt
@@ -0,0 +1,4 @@
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
diff --git a/test/fixtures/golden-repo/package.json b/test/fixtures/golden-repo/package.json
new file mode 100644
index 0000000..0180bc4
--- /dev/null
+++ b/test/fixtures/golden-repo/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
diff --git a/test/fixtures/golden-repo/paper.tex b/test/fixtures/golden-repo/paper.tex
new file mode 100644
index 0000000..99fae23
--- /dev/null
+++ b/test/fixtures/golden-repo/paper.tex
@@ -0,0 +1,6 @@
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/fixtures/golden-repo/src/lib.rs b/test/fixtures/golden-repo/src/lib.rs
new file mode 100644
index 0000000..d793aa7
--- /dev/null
+++ b/test/fixtures/golden-repo/src/lib.rs
@@ -0,0 +1,9 @@
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/golden/expected/all-md.golden b/test/golden/expected/all-md.golden
new file mode 100644
index 0000000..dc6acad
--- /dev/null
+++ b/test/golden/expected/all-md.golden
@@ -0,0 +1,206 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: Makefile
+---
+
+.PHONY: all clean
+
+all:
+ @echo "Golden fixture Makefile"
+
+clean:
+ @echo "Nothing to clean"
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: index.js
+---
+
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: main.go
+---
+
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
+
+
+
+---
+### File: src/lib.rs
+---
+
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/golden/expected/chunked-md.golden b/test/golden/expected/chunked-md.golden
new file mode 100644
index 0000000..1ce6b87
--- /dev/null
+++ b/test/golden/expected/chunked-md.golden
@@ -0,0 +1,114 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+--- CHUNK BOUNDARY ---
+# Repository Compilation: golden-repo (Part 2)
+Generated: TIMESTAMP
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/code-md.golden b/test/golden/expected/code-md.golden
new file mode 100644
index 0000000..232ff7a
--- /dev/null
+++ b/test/golden/expected/code-md.golden
@@ -0,0 +1,192 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: index.js
+---
+
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: main.go
+---
+
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
+
+
+
+---
+### File: src/lib.rs
+---
+
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/golden/expected/code-xml-toc.golden b/test/golden/expected/code-xml-toc.golden
new file mode 100644
index 0000000..d497217
--- /dev/null
+++ b/test/golden/expected/code-xml-toc.golden
@@ -0,0 +1,251 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ which breaks CDATA sections.
+The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
+
+]]>
+
+
diff --git a/test/golden/expected/docs-md-line-numbers.golden b/test/golden/expected/docs-md-line-numbers.golden
new file mode 100644
index 0000000..5d15b57
--- /dev/null
+++ b/test/golden/expected/docs-md-line-numbers.golden
@@ -0,0 +1,111 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+0001 | # Golden Repo
+0002 |
+0003 | This is the readme for the golden test fixture repository.
+0004 | It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+0001 | # CDATA Edge Case
+0002 |
+0003 | This file contains the sequence ]]> which breaks CDATA sections.
+0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+0001 | # Deeply Nested Document
+0002 |
+0003 | This document lives at a deeply nested path to test path handling.
+0004 | smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+0001 | User Guide
+0002 | ==========
+0003 |
+0004 | This guide covers the basic usage of the golden fixture project.
+0005 | See the readme for an overview of the project structure.
+
+
+
+---
+### File: journal.org
+---
+
+0001 | #+TITLE: Project Journal
+0002 | #+DATE: 2026-01-01
+0003 |
+0004 | * Overview
+0005 |
+0006 | This org file documents the golden fixture project history.
+0007 | Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+0001 | = Technical Manual
+0002 | :doctype: article
+0003 |
+0004 | This manual describes the technical details of the golden fixture project.
+0005 | Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+0001 | This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+0001 | Release notes for golden fixture project.
+0002 |
+0003 | Version one introduces the initial set of fixture files.
+0004 | These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+0001 | \documentclass{article}
+0002 | \title{Golden Fixture Paper}
+0003 | \begin{document}
+0004 | \maketitle
+0005 | This paper describes the golden fixture test repository.
+0006 | \end{document}
diff --git a/test/golden/expected/docs-md-toc-line-numbers.golden b/test/golden/expected/docs-md-toc-line-numbers.golden
new file mode 100644
index 0000000..9845599
--- /dev/null
+++ b/test/golden/expected/docs-md-toc-line-numbers.golden
@@ -0,0 +1,128 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+## Table of Contents
+
+| # | File | Words |
+|---|------|-------|
+| 1 | README.md | 21 |
+| 2 | cdata-break.md | 25 |
+| 3 | deep/nested/path/doc.md | 27 |
+| 4 | empty.md | 0 |
+| 5 | guide.rst | 24 |
+| 6 | journal.org | 24 |
+| 7 | manual.adoc | 29 |
+| 8 | no-newline.md | 9 |
+| 9 | notes.txt | 22 |
+| 10 | paper.tex | 15 |
+| **Total** | **10 files** | **196** |
+
+
+
+---
+### File: README.md
+---
+
+0001 | # Golden Repo
+0002 |
+0003 | This is the readme for the golden test fixture repository.
+0004 | It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+0001 | # CDATA Edge Case
+0002 |
+0003 | This file contains the sequence ]]> which breaks CDATA sections.
+0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+0001 | # Deeply Nested Document
+0002 |
+0003 | This document lives at a deeply nested path to test path handling.
+0004 | smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+0001 | User Guide
+0002 | ==========
+0003 |
+0004 | This guide covers the basic usage of the golden fixture project.
+0005 | See the readme for an overview of the project structure.
+
+
+
+---
+### File: journal.org
+---
+
+0001 | #+TITLE: Project Journal
+0002 | #+DATE: 2026-01-01
+0003 |
+0004 | * Overview
+0005 |
+0006 | This org file documents the golden fixture project history.
+0007 | Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+0001 | = Technical Manual
+0002 | :doctype: article
+0003 |
+0004 | This manual describes the technical details of the golden fixture project.
+0005 | Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+0001 | This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+0001 | Release notes for golden fixture project.
+0002 |
+0003 | Version one introduces the initial set of fixture files.
+0004 | These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+0001 | \documentclass{article}
+0002 | \title{Golden Fixture Paper}
+0003 | \begin{document}
+0004 | \maketitle
+0005 | This paper describes the golden fixture test repository.
+0006 | \end{document}
diff --git a/test/golden/expected/docs-md-toc.golden b/test/golden/expected/docs-md-toc.golden
new file mode 100644
index 0000000..a32a814
--- /dev/null
+++ b/test/golden/expected/docs-md-toc.golden
@@ -0,0 +1,128 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+## Table of Contents
+
+| # | File | Words |
+|---|------|-------|
+| 1 | README.md | 21 |
+| 2 | cdata-break.md | 25 |
+| 3 | deep/nested/path/doc.md | 27 |
+| 4 | empty.md | 0 |
+| 5 | guide.rst | 24 |
+| 6 | journal.org | 24 |
+| 7 | manual.adoc | 29 |
+| 8 | no-newline.md | 9 |
+| 9 | notes.txt | 22 |
+| 10 | paper.tex | 15 |
+| **Total** | **10 files** | **196** |
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/docs-md.golden b/test/golden/expected/docs-md.golden
new file mode 100644
index 0000000..da8c26a
--- /dev/null
+++ b/test/golden/expected/docs-md.golden
@@ -0,0 +1,111 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/docs-text.golden b/test/golden/expected/docs-text.golden
new file mode 100644
index 0000000..3dbb84c
--- /dev/null
+++ b/test/golden/expected/docs-text.golden
@@ -0,0 +1,112 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: README.md
+============================================================
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+============================================================
+File: journal.org
+============================================================
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+This file has no trailing newline at the end.
+
+
+============================================================
+File: notes.txt
+============================================================
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+============================================================
+File: paper.tex
+============================================================
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/docs-xml.golden b/test/golden/expected/docs-xml.golden
new file mode 100644
index 0000000..87bb112
--- /dev/null
+++ b/test/golden/expected/docs-xml.golden
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+ which breaks CDATA sections.
+The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/golden/expected/dry-run.golden b/test/golden/expected/dry-run.golden
new file mode 100644
index 0000000..8fa90a5
--- /dev/null
+++ b/test/golden/expected/dry-run.golden
@@ -0,0 +1,20 @@
+
+Dry run — 10 file(s) matched in golden-repo
+
+ • README.md 21 words
+ • cdata-break.md 25 words
+ • deep/nested/path/doc.md 27 words
+ • empty.md 0 words
+ • guide.rst 24 words
+ • journal.org 24 words
+ • manual.adoc 29 words
+ • no-newline.md 9 words
+ • notes.txt 22 words
+ • paper.tex 15 words
+
+ Files : 10
+ Words : 196
+ Tokens: ~254
+ Chunks: ~1
+
+Run without --dry-run to generate output.
diff --git a/test/golden/expected/exclude-deep-md.golden b/test/golden/expected/exclude-deep-md.golden
new file mode 100644
index 0000000..e86fff3
--- /dev/null
+++ b/test/golden/expected/exclude-deep-md.golden
@@ -0,0 +1,100 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/include-hidden-md.golden b/test/golden/expected/include-hidden-md.golden
new file mode 100644
index 0000000..670d59f
--- /dev/null
+++ b/test/golden/expected/include-hidden-md.golden
@@ -0,0 +1,239 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: .env.example
+---
+
+DATABASE_URL=postgres://localhost:5432/mydb
+SECRET_KEY=your-secret-key-here
+DEBUG=false
+
+
+
+---
+### File: .github/ci.yml
+---
+
+name: CI
+on: [push, pull_request]
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - run: echo "Golden fixture CI workflow"
+
+
+
+---
+### File: .gitignore
+---
+
+OUTPUT_DIR/
+
+
+
+---
+### File: Makefile
+---
+
+.PHONY: all clean
+
+all:
+ @echo "Golden fixture Makefile"
+
+clean:
+ @echo "Nothing to clean"
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: index.js
+---
+
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: main.go
+---
+
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
+
+
+
+---
+### File: src/lib.rs
+---
+
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/golden/expected/include-json-md.golden b/test/golden/expected/include-json-md.golden
new file mode 100644
index 0000000..0c08645
--- /dev/null
+++ b/test/golden/expected/include-json-md.golden
@@ -0,0 +1,123 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/json.golden b/test/golden/expected/json.golden
new file mode 100644
index 0000000..93fe33d
--- /dev/null
+++ b/test/golden/expected/json.golden
@@ -0,0 +1,13 @@
+{
+ "repo": "golden-repo",
+ "output_dir": "OUTPUT_DIR",
+ "files_processed": 10,
+ "total_words": 255,
+ "estimated_tokens": 331,
+ "verified": true,
+ "secrets_excluded": [],
+ "chunks": [
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md", "words": 255}
+ ],
+ "exit_code": 0
+}
diff --git a/test/golden/expected/only-py-md.golden b/test/golden/expected/only-py-md.golden
new file mode 100644
index 0000000..bc3d1ae
--- /dev/null
+++ b/test/golden/expected/only-py-md.golden
@@ -0,0 +1,20 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
diff --git a/test/golden/expected/quiet.golden b/test/golden/expected/quiet.golden
new file mode 100644
index 0000000..3b55acd
--- /dev/null
+++ b/test/golden/expected/quiet.golden
@@ -0,0 +1 @@
+OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md
diff --git a/test/smoosh_golden.bats b/test/smoosh_golden.bats
new file mode 100644
index 0000000..f51f2ee
--- /dev/null
+++ b/test/smoosh_golden.bats
@@ -0,0 +1,266 @@
+#!/usr/bin/env bats
+# Golden file acceptance tests — verify smoosh output is byte-for-byte correct
+# across all modes, formats, and feature flag combinations.
+#
+# Usage:
+# bats test/smoosh_golden.bats # run all golden tests
+# UPDATE_GOLDEN=1 bats test/smoosh_golden.bats # regenerate all golden files
+#
+# shellcheck disable=SC2154,SC2034 # SC2154: bats vars; SC2034: globals used by sourced smoosh.
+
+load 'test_helper/common-setup'
+
+# Paths (set at load time, before setup_file).
+GOLDEN_SRC="${BATS_TEST_DIRNAME}/fixtures/golden-repo"
+GOLDEN_DIR="${BATS_TEST_DIRNAME}/golden/expected"
+
+setup_file() {
+ export GOLDEN_REPO GOLDEN_OUT
+ GOLDEN_REPO="$(mktemp -d)"
+ GOLDEN_OUT="$(mktemp -d)"
+
+ # Create a real git repo from the static fixture files.
+ # The fixture files in GOLDEN_SRC are plain source files (no .git/);
+ # we create the git repo here at test time.
+ cp -r "${GOLDEN_SRC}/." "${GOLDEN_REPO}/"
+ git -C "${GOLDEN_REPO}" init -q
+ git -C "${GOLDEN_REPO}" config user.email "test@example.com"
+ git -C "${GOLDEN_REPO}" config user.name "Test"
+ git -C "${GOLDEN_REPO}" add -A
+ git -C "${GOLDEN_REPO}" commit -q -m "init"
+}
+
+teardown_file() {
+ [[ -d "${GOLDEN_REPO-}" ]] && rm -rf "${GOLDEN_REPO}"
+ [[ -d "${GOLDEN_OUT-}" ]] && rm -rf "${GOLDEN_OUT}"
+}
+
+setup() {
+ # Clear output dir between tests so each test starts with a clean slate.
+ rm -rf "${GOLDEN_OUT:?}/"*
+}
+
+# ---------------------------------------------------------------------------
+# Normalisation — strips non-deterministic content before comparison.
+# ---------------------------------------------------------------------------
+
+# normalise CONTENT — print normalised version to stdout.
+#
+# Replaces:
+# - temp dir paths (GOLDEN_REPO, GOLDEN_OUT) with fixed placeholders
+# - random mktemp dir name in chunk headers and filenames → "golden-repo"
+# - timestamps in all three format headers (md text, XML attribute)
+# - timestamp prefixes in output filenames
+# - JSON fields that contain absolute paths or timestamps
+normalise() {
+ local content="${1}"
+ local repo_basename
+ repo_basename="$(basename "${GOLDEN_REPO}")"
+ printf '%s' "${content}" | sed \
+ -e "s|${GOLDEN_REPO}|REPO_ROOT|g" \
+ -e "s|${GOLDEN_OUT}|OUTPUT_DIR|g" \
+ -e "s|${repo_basename}|golden-repo|g" \
+ -e 's/Generated: [0-9-]* [0-9:]*/Generated: TIMESTAMP/g' \
+ -e 's/generated="[^"]*"/generated="TIMESTAMP"/g' \
+ -e 's/[0-9_]*_golden-repo_part/TIMESTAMP_golden-repo_part/g' \
+ -e 's|"generated":"[^"]*"|"generated":"TIMESTAMP"|g' \
+ -e 's|"output_dir":"[^"]*"|"output_dir":"OUTPUT_DIR"|g' \
+ -e 's|"path":"[^"]*TIMESTAMP_golden-repo_part|"path":"OUTPUT_DIR/TIMESTAMP_golden-repo_part|g'
+}
+
+# golden_compare GOLDEN_NAME ACTUAL
+#
+# If UPDATE_GOLDEN=1: write ACTUAL to the golden file and skip the test.
+# Otherwise: diff ACTUAL against the golden file and fail on any difference.
+golden_compare() {
+ local golden_name="${1}" actual="${2}"
+ if [[ "${UPDATE_GOLDEN:-}" == "1" ]]; then
+ printf '%s\n' "${actual}" >"${GOLDEN_DIR}/${golden_name}"
+ skip "Golden file updated: ${golden_name}"
+ fi
+ if [[ ! -f "${GOLDEN_DIR}/${golden_name}" ]]; then
+ fail "Golden file missing: ${golden_name}. Run UPDATE_GOLDEN=1 bats test/smoosh_golden.bats to generate."
+ fi
+ local expected
+ expected="$(cat "${GOLDEN_DIR}/${golden_name}")"
+ if [[ "${actual}" != "${expected}" ]]; then
+ diff <(printf '%s\n' "${expected}") <(printf '%s\n' "${actual}") >&2
+ fail "Output differs from ${golden_name}. Run UPDATE_GOLDEN=1 bats test/smoosh_golden.bats to regenerate."
+ fi
+}
+
+# ---------------------------------------------------------------------------
+# Docs mode — all three output formats
+# ---------------------------------------------------------------------------
+
+@test "golden: docs-md" {
+ smoosh --docs --no-interactive --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "docs-md.golden" "${actual}"
+}
+
+@test "golden: docs-text" {
+ smoosh --docs --no-interactive --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.txt)")"
+ golden_compare "docs-text.golden" "${actual}"
+}
+
+@test "golden: docs-xml" {
+ smoosh --docs --no-interactive --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.xml)")"
+ golden_compare "docs-xml.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Docs mode — feature flags: TOC, line numbers, combined
+# ---------------------------------------------------------------------------
+
+@test "golden: docs-md-toc" {
+ smoosh --docs --no-interactive --toc --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "docs-md-toc.golden" "${actual}"
+}
+
+@test "golden: docs-md-line-numbers" {
+ smoosh --docs --no-interactive --line-numbers --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "docs-md-line-numbers.golden" "${actual}"
+}
+
+@test "golden: docs-md-toc-line-numbers" {
+ smoosh --docs --no-interactive --toc --line-numbers --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "docs-md-toc-line-numbers.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Code mode — markdown and XML+TOC
+# ---------------------------------------------------------------------------
+
+@test "golden: code-md" {
+ # aws-creds.py is a .py file in code mode — secrets detection excludes it.
+ smoosh --code --no-interactive --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "code-md.golden" "${actual}"
+}
+
+@test "golden: code-xml-toc" {
+ smoosh --code --no-interactive --toc --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.xml)")"
+ golden_compare "code-xml-toc.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# All mode
+# ---------------------------------------------------------------------------
+
+@test "golden: all-md" {
+ smoosh --all --no-interactive --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "all-md.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Filter flags: --only, --exclude, --include
+# ---------------------------------------------------------------------------
+
+@test "golden: only-py-md" {
+ # app.py included; aws-creds.py excluded by secrets detection.
+ smoosh --only "*.py" --no-interactive --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "only-py-md.golden" "${actual}"
+}
+
+@test "golden: exclude-deep-md" {
+ # deep/nested/path/doc.md excluded; all other docs present.
+ smoosh --docs --no-interactive --exclude "deep/*" --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "exclude-deep-md.golden" "${actual}"
+}
+
+@test "golden: include-json-md" {
+ # package.json added to docs mode via --include.
+ smoosh --docs --no-interactive --include "*.json" --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "include-json-md.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Chunking: --max-words 100 splits docs mode into exactly 2 chunks
+# ---------------------------------------------------------------------------
+
+@test "golden: chunked-md" {
+ smoosh --docs --no-interactive --max-words 100 --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ # Concatenate chunks in sorted order with a boundary marker.
+ local actual="" first=true chunk_file
+ while IFS= read -r chunk_file; do
+ if [[ "${first}" == "true" ]]; then
+ first=false
+ else
+ actual="${actual}
+--- CHUNK BOUNDARY ---
+"
+ fi
+ actual="${actual}$(cat "${chunk_file}")"
+ done < <(find "${GOLDEN_OUT}" -maxdepth 1 -name '*.md' | LC_ALL=C sort)
+ actual="$(normalise "${actual}")"
+ golden_compare "chunked-md.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Hidden files: --include-hidden
+# ---------------------------------------------------------------------------
+
+@test "golden: include-hidden-md" {
+ # .github/ci.yml and .env.example included alongside all tracked files.
+ smoosh --all --no-interactive --include-hidden --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "include-hidden-md.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Stdout / stderr output tests
+# ---------------------------------------------------------------------------
+
+@test "golden: dry-run" {
+ # --dry-run writes its file listing to stderr; nothing is written to disk.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --dry-run "${GOLDEN_REPO}" 2>&1 >/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "dry-run.golden" "${actual}"
+}
+
+@test "golden: json" {
+ # --json writes structured JSON to stdout; all progress goes to stderr.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --json --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "json.golden" "${actual}"
+}
+
+@test "golden: quiet" {
+ # --quiet writes output file paths to stdout, one per line.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --quiet --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "quiet.golden" "${actual}"
+}
From 909027565724bb5472bb97b0b2bce79ff7925ccb Mon Sep 17 00:00:00 2001
From: K1-R1 <77465250+K1-R1@users.noreply.github.com>
Date: Sun, 15 Mar 2026 13:11:05 +0000
Subject: [PATCH 2/3] test: close all deterministic golden coverage gaps
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add 13 new golden tests (30 total) and 3 new fixture files to achieve
complete byte-level coverage of every deterministic smoosh code path.
Format × modifier matrix — fill every cell:
- docs-text-toc, docs-text-line-numbers, docs-text-toc-line-numbers
- docs-xml-line-numbers, docs-xml-toc-line-numbers
Output channel / special mode gaps:
- json-dry-run: distinct JSON structure (dry_run:true, files[], no chunks)
- code-json: secrets_excluded array populated (aws-creds.py flagged)
- no-check-secrets-code-md: aws-creds.py appears when scan is disabled
- chunked-text, chunked-xml: header/footer cycling in non-md formats
- chunked-quiet: multi-chunk quiet mode outputs one path per chunk
- chunked-json: chunks[] array with multiple entries
Filter edge case:
- exclude-multi-md: comma-separated --exclude patterns
New fixture files exercising edge cases:
- it's-fine.md: apostrophe in filename (BSD xargs regression guard)
- my notes.md: space in filename (path handling through pipeline)
- logo.png: 8-byte PNG header (MIME filter rejects in --all mode)
- Symlink (link-to-readme) created in setup_file() to test -L exclusion
All existing golden files regenerated to include the new fixture content.
228 tests, all passing.
Signed-off-by: K1-R1 <77465250+K1-R1@users.noreply.github.com>
---
README.md | 2 +-
test/ACCEPTANCE.md | 2 +-
test/fixtures/golden-repo/it's-fine.md | 4 +
test/fixtures/golden-repo/logo.png | 2 +
test/fixtures/golden-repo/my notes.md | 3 +
test/golden/expected/all-md.golden | 21 ++
test/golden/expected/chunked-json.golden | 15 ++
test/golden/expected/chunked-md.golden | 25 ++
test/golden/expected/chunked-quiet.golden | 3 +
test/golden/expected/chunked-text.golden | 142 +++++++++++
test/golden/expected/chunked-xml.golden | 151 ++++++++++++
test/golden/expected/code-json.golden | 13 +
test/golden/expected/code-md.golden | 21 ++
test/golden/expected/code-xml-toc.golden | 42 +++-
.../expected/docs-md-line-numbers.golden | 21 ++
.../expected/docs-md-toc-line-numbers.golden | 35 ++-
test/golden/expected/docs-md-toc.golden | 35 ++-
test/golden/expected/docs-md.golden | 21 ++
.../expected/docs-text-line-numbers.golden | 133 +++++++++++
.../docs-text-toc-line-numbers.golden | 152 ++++++++++++
test/golden/expected/docs-text-toc.golden | 152 ++++++++++++
test/golden/expected/docs-text.golden | 21 ++
.../expected/docs-xml-line-numbers.golden | 97 ++++++++
.../expected/docs-xml-toc-line-numbers.golden | 112 +++++++++
test/golden/expected/docs-xml.golden | 22 ++
test/golden/expected/dry-run.golden | 10 +-
test/golden/expected/exclude-deep-md.golden | 21 ++
test/golden/expected/exclude-multi-md.golden | 110 +++++++++
test/golden/expected/include-hidden-md.golden | 21 ++
test/golden/expected/include-json-md.golden | 21 ++
test/golden/expected/json-dry-run.golden | 21 ++
test/golden/expected/json.golden | 8 +-
.../expected/no-check-secrets-code-md.golden | 224 ++++++++++++++++++
test/smoosh_golden.bats | 151 ++++++++++--
34 files changed, 1788 insertions(+), 46 deletions(-)
create mode 100644 test/fixtures/golden-repo/it's-fine.md
create mode 100644 test/fixtures/golden-repo/logo.png
create mode 100644 test/fixtures/golden-repo/my notes.md
create mode 100644 test/golden/expected/chunked-json.golden
create mode 100644 test/golden/expected/chunked-quiet.golden
create mode 100644 test/golden/expected/chunked-text.golden
create mode 100644 test/golden/expected/chunked-xml.golden
create mode 100644 test/golden/expected/code-json.golden
create mode 100644 test/golden/expected/docs-text-line-numbers.golden
create mode 100644 test/golden/expected/docs-text-toc-line-numbers.golden
create mode 100644 test/golden/expected/docs-text-toc.golden
create mode 100644 test/golden/expected/docs-xml-line-numbers.golden
create mode 100644 test/golden/expected/docs-xml-toc-line-numbers.golden
create mode 100644 test/golden/expected/exclude-multi-md.golden
create mode 100644 test/golden/expected/json-dry-run.golden
create mode 100644 test/golden/expected/no-check-secrets-code-md.golden
diff --git a/README.md b/README.md
index edbe230..bc28528 100644
--- a/README.md
+++ b/README.md
@@ -323,7 +323,7 @@ smoosh counts words using `wc -w`, which splits on whitespace. Code files
with dense syntax (JSON, minified JS) count differently than prose.
**Is it overengineered for a shell script?**
-Absolutely. 215 tests, 100% file inclusion verification, CDATA escaping for
+Absolutely. 228 tests, 100% file inclusion verification, CDATA escaping for
XML output, and a box-drawing letter logo. But your codebase deserves to be
smooshed properly.
diff --git a/test/ACCEPTANCE.md b/test/ACCEPTANCE.md
index 67b3908..0cd070f 100644
--- a/test/ACCEPTANCE.md
+++ b/test/ACCEPTANCE.md
@@ -237,7 +237,7 @@ files. Run them to confirm no regressions:
bats test/smoosh_golden.bats
-All 17 tests should pass.
+All 30 tests should pass.
If you intentionally change smoosh's output format (for example, adding a
new header field), regenerate the golden files:
diff --git a/test/fixtures/golden-repo/it's-fine.md b/test/fixtures/golden-repo/it's-fine.md
new file mode 100644
index 0000000..265c4d3
--- /dev/null
+++ b/test/fixtures/golden-repo/it's-fine.md
@@ -0,0 +1,4 @@
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
diff --git a/test/fixtures/golden-repo/logo.png b/test/fixtures/golden-repo/logo.png
new file mode 100644
index 0000000..0dd1608
--- /dev/null
+++ b/test/fixtures/golden-repo/logo.png
@@ -0,0 +1,2 @@
+‰PNG
+
diff --git a/test/fixtures/golden-repo/my notes.md b/test/fixtures/golden-repo/my notes.md
new file mode 100644
index 0000000..8486737
--- /dev/null
+++ b/test/fixtures/golden-repo/my notes.md
@@ -0,0 +1,3 @@
+# My Notes
+
+This file name contains a space to test path handling.
diff --git a/test/golden/expected/all-md.golden b/test/golden/expected/all-md.golden
index dc6acad..9a50298 100644
--- a/test/golden/expected/all-md.golden
+++ b/test/golden/expected/all-md.golden
@@ -103,6 +103,17 @@ module.exports = { VERSION, greet };
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -148,6 +159,16 @@ Refer to the guide for usage instructions and the readme for an overview.
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
diff --git a/test/golden/expected/chunked-json.golden b/test/golden/expected/chunked-json.golden
new file mode 100644
index 0000000..216a1ef
--- /dev/null
+++ b/test/golden/expected/chunked-json.golden
@@ -0,0 +1,15 @@
+{
+ "repo": "golden-repo",
+ "output_dir": "OUTPUT_DIR",
+ "files_processed": 12,
+ "total_words": 313,
+ "estimated_tokens": 406,
+ "verified": true,
+ "secrets_excluded": [],
+ "chunks": [
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md", "words": 131},
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part2.md", "words": 126},
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part3.md", "words": 56}
+ ],
+ "exit_code": 0
+}
diff --git a/test/golden/expected/chunked-md.golden b/test/golden/expected/chunked-md.golden
index 1ce6b87..4c185e2 100644
--- a/test/golden/expected/chunked-md.golden
+++ b/test/golden/expected/chunked-md.golden
@@ -58,6 +58,17 @@ Generated: TIMESTAMP
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -84,11 +95,25 @@ Refer to the guide for usage instructions and the readme for an overview.
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
This file has no trailing newline at the end.
+--- CHUNK BOUNDARY ---
+# Repository Compilation: golden-repo (Part 3)
+Generated: TIMESTAMP
+
---
diff --git a/test/golden/expected/chunked-quiet.golden b/test/golden/expected/chunked-quiet.golden
new file mode 100644
index 0000000..338c01f
--- /dev/null
+++ b/test/golden/expected/chunked-quiet.golden
@@ -0,0 +1,3 @@
+OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md
+OUTPUT_DIR/TIMESTAMP_golden-repo_part2.md
+OUTPUT_DIR/TIMESTAMP_golden-repo_part3.md
diff --git a/test/golden/expected/chunked-text.golden b/test/golden/expected/chunked-text.golden
new file mode 100644
index 0000000..c1eb733
--- /dev/null
+++ b/test/golden/expected/chunked-text.golden
@@ -0,0 +1,142 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: README.md
+============================================================
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+--- CHUNK BOUNDARY ---
+Repository Compilation: golden-repo (Part 2)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: it's-fine.md
+============================================================
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+============================================================
+File: journal.org
+============================================================
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+============================================================
+File: my notes.md
+============================================================
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+This file has no trailing newline at the end.
+--- CHUNK BOUNDARY ---
+Repository Compilation: golden-repo (Part 3)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: notes.txt
+============================================================
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+============================================================
+File: paper.tex
+============================================================
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/chunked-xml.golden b/test/golden/expected/chunked-xml.golden
new file mode 100644
index 0000000..18f0672
--- /dev/null
+++ b/test/golden/expected/chunked-xml.golden
@@ -0,0 +1,151 @@
+
+
+
+
+
+
+ which breaks CDATA sections.
+The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+--- CHUNK BOUNDARY ---
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+--- CHUNK BOUNDARY ---
+
+
+
+
+
+
+
+
+
diff --git a/test/golden/expected/code-json.golden b/test/golden/expected/code-json.golden
new file mode 100644
index 0000000..6d444c4
--- /dev/null
+++ b/test/golden/expected/code-json.golden
@@ -0,0 +1,13 @@
+{
+ "repo": "golden-repo",
+ "output_dir": "OUTPUT_DIR",
+ "files_processed": 17,
+ "total_words": 437,
+ "estimated_tokens": 568,
+ "verified": true,
+ "secrets_excluded": ["aws-creds.py"],
+ "chunks": [
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md", "words": 437}
+ ],
+ "exit_code": 0
+}
diff --git a/test/golden/expected/code-md.golden b/test/golden/expected/code-md.golden
index 232ff7a..3847d86 100644
--- a/test/golden/expected/code-md.golden
+++ b/test/golden/expected/code-md.golden
@@ -89,6 +89,17 @@ module.exports = { VERSION, greet };
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -134,6 +145,16 @@ Refer to the guide for usage instructions and the readme for an overview.
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
diff --git a/test/golden/expected/code-xml-toc.golden b/test/golden/expected/code-xml-toc.golden
index d497217..1387e7d 100644
--- a/test/golden/expected/code-xml-toc.golden
+++ b/test/golden/expected/code-xml-toc.golden
@@ -8,15 +8,17 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -178,6 +192,16 @@ Refer to the guide for usage instructions and the readme for an overview.
This manual describes the technical details of the golden fixture project.
Refer to the guide for usage instructions and the readme for an overview.
+]]>
+
+
+
diff --git a/test/golden/expected/docs-md-line-numbers.golden b/test/golden/expected/docs-md-line-numbers.golden
index 5d15b57..98fe04b 100644
--- a/test/golden/expected/docs-md-line-numbers.golden
+++ b/test/golden/expected/docs-md-line-numbers.golden
@@ -55,6 +55,17 @@ Generated: TIMESTAMP
+---
+### File: it's-fine.md
+---
+
+0001 | # It's Fine
+0002 |
+0003 | This file's name contains an apostrophe.
+0004 | It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -81,6 +92,16 @@ Generated: TIMESTAMP
+---
+### File: my notes.md
+---
+
+0001 | # My Notes
+0002 |
+0003 | This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
diff --git a/test/golden/expected/docs-md-toc-line-numbers.golden b/test/golden/expected/docs-md-toc-line-numbers.golden
index 9845599..7bc1ff8 100644
--- a/test/golden/expected/docs-md-toc-line-numbers.golden
+++ b/test/golden/expected/docs-md-toc-line-numbers.golden
@@ -11,12 +11,14 @@ Generated: TIMESTAMP
| 3 | deep/nested/path/doc.md | 27 |
| 4 | empty.md | 0 |
| 5 | guide.rst | 24 |
-| 6 | journal.org | 24 |
-| 7 | manual.adoc | 29 |
-| 8 | no-newline.md | 9 |
-| 9 | notes.txt | 22 |
-| 10 | paper.tex | 15 |
-| **Total** | **10 files** | **196** |
+| 6 | it's-fine.md | 16 |
+| 7 | journal.org | 24 |
+| 8 | manual.adoc | 29 |
+| 9 | my notes.md | 13 |
+| 10 | no-newline.md | 9 |
+| 11 | notes.txt | 22 |
+| 12 | paper.tex | 15 |
+| **Total** | **12 files** | **225** |
@@ -72,6 +74,17 @@ Generated: TIMESTAMP
+---
+### File: it's-fine.md
+---
+
+0001 | # It's Fine
+0002 |
+0003 | This file's name contains an apostrophe.
+0004 | It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -98,6 +111,16 @@ Generated: TIMESTAMP
+---
+### File: my notes.md
+---
+
+0001 | # My Notes
+0002 |
+0003 | This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
diff --git a/test/golden/expected/docs-md-toc.golden b/test/golden/expected/docs-md-toc.golden
index a32a814..a923251 100644
--- a/test/golden/expected/docs-md-toc.golden
+++ b/test/golden/expected/docs-md-toc.golden
@@ -11,12 +11,14 @@ Generated: TIMESTAMP
| 3 | deep/nested/path/doc.md | 27 |
| 4 | empty.md | 0 |
| 5 | guide.rst | 24 |
-| 6 | journal.org | 24 |
-| 7 | manual.adoc | 29 |
-| 8 | no-newline.md | 9 |
-| 9 | notes.txt | 22 |
-| 10 | paper.tex | 15 |
-| **Total** | **10 files** | **196** |
+| 6 | it's-fine.md | 16 |
+| 7 | journal.org | 24 |
+| 8 | manual.adoc | 29 |
+| 9 | my notes.md | 13 |
+| 10 | no-newline.md | 9 |
+| 11 | notes.txt | 22 |
+| 12 | paper.tex | 15 |
+| **Total** | **12 files** | **225** |
@@ -72,6 +74,17 @@ See the readme for an overview of the project structure.
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -98,6 +111,16 @@ Refer to the guide for usage instructions and the readme for an overview.
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
diff --git a/test/golden/expected/docs-md.golden b/test/golden/expected/docs-md.golden
index da8c26a..406476f 100644
--- a/test/golden/expected/docs-md.golden
+++ b/test/golden/expected/docs-md.golden
@@ -55,6 +55,17 @@ See the readme for an overview of the project structure.
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -81,6 +92,16 @@ Refer to the guide for usage instructions and the readme for an overview.
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
diff --git a/test/golden/expected/docs-text-line-numbers.golden b/test/golden/expected/docs-text-line-numbers.golden
new file mode 100644
index 0000000..15d1e92
--- /dev/null
+++ b/test/golden/expected/docs-text-line-numbers.golden
@@ -0,0 +1,133 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: README.md
+============================================================
+
+0001 | # Golden Repo
+0002 |
+0003 | This is the readme for the golden test fixture repository.
+0004 | It contains files that exercise every smoosh capability.
+
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+0001 | # CDATA Edge Case
+0002 |
+0003 | This file contains the sequence ]]> which breaks CDATA sections.
+0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+0001 | # Deeply Nested Document
+0002 |
+0003 | This document lives at a deeply nested path to test path handling.
+0004 | smoosh should include this file with its full relative path preserved.
+
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+0001 | User Guide
+0002 | ==========
+0003 |
+0004 | This guide covers the basic usage of the golden fixture project.
+0005 | See the readme for an overview of the project structure.
+
+
+
+============================================================
+File: it's-fine.md
+============================================================
+
+0001 | # It's Fine
+0002 |
+0003 | This file's name contains an apostrophe.
+0004 | It tests filename quoting in shell pipelines.
+
+
+
+============================================================
+File: journal.org
+============================================================
+
+0001 | #+TITLE: Project Journal
+0002 | #+DATE: 2026-01-01
+0003 |
+0004 | * Overview
+0005 |
+0006 | This org file documents the golden fixture project history.
+0007 | Each entry records a notable event during development.
+
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+0001 | = Technical Manual
+0002 | :doctype: article
+0003 |
+0004 | This manual describes the technical details of the golden fixture project.
+0005 | Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+============================================================
+File: my notes.md
+============================================================
+
+0001 | # My Notes
+0002 |
+0003 | This file name contains a space to test path handling.
+
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+0001 | This file has no trailing newline at the end.
+
+
+============================================================
+File: notes.txt
+============================================================
+
+0001 | Release notes for golden fixture project.
+0002 |
+0003 | Version one introduces the initial set of fixture files.
+0004 | These files exercise smoosh output format correctness.
+
+
+
+============================================================
+File: paper.tex
+============================================================
+
+0001 | \documentclass{article}
+0002 | \title{Golden Fixture Paper}
+0003 | \begin{document}
+0004 | \maketitle
+0005 | This paper describes the golden fixture test repository.
+0006 | \end{document}
diff --git a/test/golden/expected/docs-text-toc-line-numbers.golden b/test/golden/expected/docs-text-toc-line-numbers.golden
new file mode 100644
index 0000000..88e759d
--- /dev/null
+++ b/test/golden/expected/docs-text-toc-line-numbers.golden
@@ -0,0 +1,152 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+Table of Contents
+------------------------------------------------------------
+
+ 1 README.md 21 words
+ 2 cdata-break.md 25 words
+ 3 deep/nested/path/doc.md 27 words
+ 4 empty.md 0 words
+ 5 guide.rst 24 words
+ 6 it's-fine.md 16 words
+ 7 journal.org 24 words
+ 8 manual.adoc 29 words
+ 9 my notes.md 13 words
+ 10 no-newline.md 9 words
+ 11 notes.txt 22 words
+ 12 paper.tex 15 words
+
+ Total: 12 files, 225 words
+
+
+
+============================================================
+File: README.md
+============================================================
+
+0001 | # Golden Repo
+0002 |
+0003 | This is the readme for the golden test fixture repository.
+0004 | It contains files that exercise every smoosh capability.
+
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+0001 | # CDATA Edge Case
+0002 |
+0003 | This file contains the sequence ]]> which breaks CDATA sections.
+0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+0001 | # Deeply Nested Document
+0002 |
+0003 | This document lives at a deeply nested path to test path handling.
+0004 | smoosh should include this file with its full relative path preserved.
+
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+0001 | User Guide
+0002 | ==========
+0003 |
+0004 | This guide covers the basic usage of the golden fixture project.
+0005 | See the readme for an overview of the project structure.
+
+
+
+============================================================
+File: it's-fine.md
+============================================================
+
+0001 | # It's Fine
+0002 |
+0003 | This file's name contains an apostrophe.
+0004 | It tests filename quoting in shell pipelines.
+
+
+
+============================================================
+File: journal.org
+============================================================
+
+0001 | #+TITLE: Project Journal
+0002 | #+DATE: 2026-01-01
+0003 |
+0004 | * Overview
+0005 |
+0006 | This org file documents the golden fixture project history.
+0007 | Each entry records a notable event during development.
+
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+0001 | = Technical Manual
+0002 | :doctype: article
+0003 |
+0004 | This manual describes the technical details of the golden fixture project.
+0005 | Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+============================================================
+File: my notes.md
+============================================================
+
+0001 | # My Notes
+0002 |
+0003 | This file name contains a space to test path handling.
+
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+0001 | This file has no trailing newline at the end.
+
+
+============================================================
+File: notes.txt
+============================================================
+
+0001 | Release notes for golden fixture project.
+0002 |
+0003 | Version one introduces the initial set of fixture files.
+0004 | These files exercise smoosh output format correctness.
+
+
+
+============================================================
+File: paper.tex
+============================================================
+
+0001 | \documentclass{article}
+0002 | \title{Golden Fixture Paper}
+0003 | \begin{document}
+0004 | \maketitle
+0005 | This paper describes the golden fixture test repository.
+0006 | \end{document}
diff --git a/test/golden/expected/docs-text-toc.golden b/test/golden/expected/docs-text-toc.golden
new file mode 100644
index 0000000..ef9a904
--- /dev/null
+++ b/test/golden/expected/docs-text-toc.golden
@@ -0,0 +1,152 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+Table of Contents
+------------------------------------------------------------
+
+ 1 README.md 21 words
+ 2 cdata-break.md 25 words
+ 3 deep/nested/path/doc.md 27 words
+ 4 empty.md 0 words
+ 5 guide.rst 24 words
+ 6 it's-fine.md 16 words
+ 7 journal.org 24 words
+ 8 manual.adoc 29 words
+ 9 my notes.md 13 words
+ 10 no-newline.md 9 words
+ 11 notes.txt 22 words
+ 12 paper.tex 15 words
+
+ Total: 12 files, 225 words
+
+
+
+============================================================
+File: README.md
+============================================================
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+============================================================
+File: it's-fine.md
+============================================================
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+============================================================
+File: journal.org
+============================================================
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+============================================================
+File: my notes.md
+============================================================
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+This file has no trailing newline at the end.
+
+
+============================================================
+File: notes.txt
+============================================================
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+============================================================
+File: paper.tex
+============================================================
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/docs-text.golden b/test/golden/expected/docs-text.golden
index 3dbb84c..3a98a02 100644
--- a/test/golden/expected/docs-text.golden
+++ b/test/golden/expected/docs-text.golden
@@ -56,6 +56,17 @@ See the readme for an overview of the project structure.
+============================================================
+File: it's-fine.md
+============================================================
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
============================================================
File: journal.org
============================================================
@@ -82,6 +93,16 @@ Refer to the guide for usage instructions and the readme for an overview.
+============================================================
+File: my notes.md
+============================================================
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
============================================================
File: no-newline.md
============================================================
diff --git a/test/golden/expected/docs-xml-line-numbers.golden b/test/golden/expected/docs-xml-line-numbers.golden
new file mode 100644
index 0000000..a017d16
--- /dev/null
+++ b/test/golden/expected/docs-xml-line-numbers.golden
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+ which breaks CDATA sections.
+0004 | The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/golden/expected/docs-xml-toc-line-numbers.golden b/test/golden/expected/docs-xml-toc-line-numbers.golden
new file mode 100644
index 0000000..dbf54b6
--- /dev/null
+++ b/test/golden/expected/docs-xml-toc-line-numbers.golden
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ which breaks CDATA sections.
+0004 | The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/golden/expected/docs-xml.golden b/test/golden/expected/docs-xml.golden
index 87bb112..f3a1a04 100644
--- a/test/golden/expected/docs-xml.golden
+++ b/test/golden/expected/docs-xml.golden
@@ -52,6 +52,18 @@ User Guide
This guide covers the basic usage of the golden fixture project.
See the readme for an overview of the project structure.
+]]>
+
+
+
@@ -84,6 +96,16 @@ Refer to the guide for usage instructions and the readme for an overview.
This manual describes the technical details of the golden fixture project.
Refer to the guide for usage instructions and the readme for an overview.
+]]>
+
+
+
diff --git a/test/golden/expected/dry-run.golden b/test/golden/expected/dry-run.golden
index 8fa90a5..be84ee6 100644
--- a/test/golden/expected/dry-run.golden
+++ b/test/golden/expected/dry-run.golden
@@ -1,20 +1,22 @@
-Dry run — 10 file(s) matched in golden-repo
+Dry run — 12 file(s) matched in golden-repo
• README.md 21 words
• cdata-break.md 25 words
• deep/nested/path/doc.md 27 words
• empty.md 0 words
• guide.rst 24 words
+ • it's-fine.md 16 words
• journal.org 24 words
• manual.adoc 29 words
+ • my notes.md 13 words
• no-newline.md 9 words
• notes.txt 22 words
• paper.tex 15 words
- Files : 10
- Words : 196
- Tokens: ~254
+ Files : 12
+ Words : 225
+ Tokens: ~292
Chunks: ~1
Run without --dry-run to generate output.
diff --git a/test/golden/expected/exclude-deep-md.golden b/test/golden/expected/exclude-deep-md.golden
index e86fff3..b2ed332 100644
--- a/test/golden/expected/exclude-deep-md.golden
+++ b/test/golden/expected/exclude-deep-md.golden
@@ -44,6 +44,17 @@ See the readme for an overview of the project structure.
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -70,6 +81,16 @@ Refer to the guide for usage instructions and the readme for an overview.
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
diff --git a/test/golden/expected/exclude-multi-md.golden b/test/golden/expected/exclude-multi-md.golden
new file mode 100644
index 0000000..adb3d39
--- /dev/null
+++ b/test/golden/expected/exclude-multi-md.golden
@@ -0,0 +1,110 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/include-hidden-md.golden b/test/golden/expected/include-hidden-md.golden
index 670d59f..9ce57ac 100644
--- a/test/golden/expected/include-hidden-md.golden
+++ b/test/golden/expected/include-hidden-md.golden
@@ -136,6 +136,17 @@ module.exports = { VERSION, greet };
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -181,6 +192,16 @@ Refer to the guide for usage instructions and the readme for an overview.
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
diff --git a/test/golden/expected/include-json-md.golden b/test/golden/expected/include-json-md.golden
index 0c08645..a802410 100644
--- a/test/golden/expected/include-json-md.golden
+++ b/test/golden/expected/include-json-md.golden
@@ -55,6 +55,17 @@ See the readme for an overview of the project structure.
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
---
### File: journal.org
---
@@ -81,6 +92,16 @@ Refer to the guide for usage instructions and the readme for an overview.
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
---
### File: no-newline.md
---
diff --git a/test/golden/expected/json-dry-run.golden b/test/golden/expected/json-dry-run.golden
new file mode 100644
index 0000000..4e4ca9a
--- /dev/null
+++ b/test/golden/expected/json-dry-run.golden
@@ -0,0 +1,21 @@
+{
+ "dry_run": true,
+ "repo": "golden-repo",
+ "files": [
+ {"path": "README.md", "words": 21, "chunk": 1},
+ {"path": "cdata-break.md", "words": 25, "chunk": 1},
+ {"path": "deep/nested/path/doc.md", "words": 27, "chunk": 1},
+ {"path": "empty.md", "words": 0, "chunk": 1},
+ {"path": "guide.rst", "words": 24, "chunk": 1},
+ {"path": "it's-fine.md", "words": 16, "chunk": 1},
+ {"path": "journal.org", "words": 24, "chunk": 1},
+ {"path": "manual.adoc", "words": 29, "chunk": 1},
+ {"path": "my notes.md", "words": 13, "chunk": 1},
+ {"path": "no-newline.md", "words": 9, "chunk": 1},
+ {"path": "notes.txt", "words": 22, "chunk": 1},
+ {"path": "paper.tex", "words": 15, "chunk": 1}
+ ],
+ "total_words": 225,
+ "estimated_tokens": 292,
+ "estimated_chunks": 1
+}
diff --git a/test/golden/expected/json.golden b/test/golden/expected/json.golden
index 93fe33d..bcffe15 100644
--- a/test/golden/expected/json.golden
+++ b/test/golden/expected/json.golden
@@ -1,13 +1,13 @@
{
"repo": "golden-repo",
"output_dir": "OUTPUT_DIR",
- "files_processed": 10,
- "total_words": 255,
- "estimated_tokens": 331,
+ "files_processed": 12,
+ "total_words": 295,
+ "estimated_tokens": 383,
"verified": true,
"secrets_excluded": [],
"chunks": [
- {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md", "words": 255}
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md", "words": 295}
],
"exit_code": 0
}
diff --git a/test/golden/expected/no-check-secrets-code-md.golden b/test/golden/expected/no-check-secrets-code-md.golden
new file mode 100644
index 0000000..e9612d3
--- /dev/null
+++ b/test/golden/expected/no-check-secrets-code-md.golden
@@ -0,0 +1,224 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
+
+
+
+---
+### File: aws-creds.py
+---
+
+# Golden fixture secrets file.
+# This file contains a fake AWS key for secrets detection testing.
+AWS_ACCESS_KEY_ID = "AKIAIOSFODNN7EXAMPLE"
+AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: index.js
+---
+
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: main.go
+---
+
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
+
+
+
+---
+### File: src/lib.rs
+---
+
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/smoosh_golden.bats b/test/smoosh_golden.bats
index f51f2ee..6a8255e 100644
--- a/test/smoosh_golden.bats
+++ b/test/smoosh_golden.bats
@@ -23,6 +23,12 @@ setup_file() {
# The fixture files in GOLDEN_SRC are plain source files (no .git/);
# we create the git repo here at test time.
cp -r "${GOLDEN_SRC}/." "${GOLDEN_REPO}/"
+
+ # Create a symlink to exercise the symlink exclusion code path (line 642
+ # in smoosh). Created at test time rather than in the fixture directory
+ # because git's core.symlinks setting varies across platforms.
+ ln -s README.md "${GOLDEN_REPO}/link-to-readme"
+
git -C "${GOLDEN_REPO}" init -q
git -C "${GOLDEN_REPO}" config user.email "test@example.com"
git -C "${GOLDEN_REPO}" config user.name "Test"
@@ -89,6 +95,24 @@ golden_compare() {
fi
}
+# _concat_chunks EXT — concatenate chunk files with boundary markers.
+# Bash 3.2-compatible: uses find + while loop instead of mapfile.
+_concat_chunks() {
+ local ext="${1}"
+ local result="" first=true chunk_file
+ while IFS= read -r chunk_file; do
+ if [[ "${first}" == "true" ]]; then
+ first=false
+ else
+ result="${result}
+--- CHUNK BOUNDARY ---
+"
+ fi
+ result="${result}$(cat "${chunk_file}")"
+ done < <(find "${GOLDEN_OUT}" -maxdepth 1 -name "*.${ext}" | LC_ALL=C sort)
+ printf '%s' "${result}"
+}
+
# ---------------------------------------------------------------------------
# Docs mode — all three output formats
# ---------------------------------------------------------------------------
@@ -115,7 +139,7 @@ golden_compare() {
}
# ---------------------------------------------------------------------------
-# Docs mode — feature flags: TOC, line numbers, combined
+# Docs mode — feature flags: TOC, line numbers, combined (all 3 formats)
# ---------------------------------------------------------------------------
@test "golden: docs-md-toc" {
@@ -139,6 +163,41 @@ golden_compare() {
golden_compare "docs-md-toc-line-numbers.golden" "${actual}"
}
+@test "golden: docs-text-toc" {
+ smoosh --docs --no-interactive --toc --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.txt)")"
+ golden_compare "docs-text-toc.golden" "${actual}"
+}
+
+@test "golden: docs-text-line-numbers" {
+ smoosh --docs --no-interactive --line-numbers --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.txt)")"
+ golden_compare "docs-text-line-numbers.golden" "${actual}"
+}
+
+@test "golden: docs-text-toc-line-numbers" {
+ smoosh --docs --no-interactive --toc --line-numbers --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.txt)")"
+ golden_compare "docs-text-toc-line-numbers.golden" "${actual}"
+}
+
+@test "golden: docs-xml-line-numbers" {
+ smoosh --docs --no-interactive --line-numbers --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.xml)")"
+ golden_compare "docs-xml-line-numbers.golden" "${actual}"
+}
+
+@test "golden: docs-xml-toc-line-numbers" {
+ smoosh --docs --no-interactive --toc --line-numbers --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.xml)")"
+ golden_compare "docs-xml-toc-line-numbers.golden" "${actual}"
+}
+
# ---------------------------------------------------------------------------
# Code mode — markdown and XML+TOC
# ---------------------------------------------------------------------------
@@ -158,6 +217,17 @@ golden_compare() {
golden_compare "code-xml-toc.golden" "${actual}"
}
+# ---------------------------------------------------------------------------
+# Code mode — secrets variant: --no-check-secrets includes aws-creds.py
+# ---------------------------------------------------------------------------
+
+@test "golden: no-check-secrets-code-md" {
+ smoosh --code --no-interactive --no-check-secrets --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "no-check-secrets-code-md.golden" "${actual}"
+}
+
# ---------------------------------------------------------------------------
# All mode
# ---------------------------------------------------------------------------
@@ -189,6 +259,14 @@ golden_compare() {
golden_compare "exclude-deep-md.golden" "${actual}"
}
+@test "golden: exclude-multi-md" {
+ # Comma-separated excludes: deep paths and .txt files both excluded.
+ smoosh --docs --no-interactive --exclude "deep/*,*.txt" --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "exclude-multi-md.golden" "${actual}"
+}
+
@test "golden: include-json-md" {
# package.json added to docs mode via --include.
smoosh --docs --no-interactive --include "*.json" --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
@@ -198,27 +276,30 @@ golden_compare() {
}
# ---------------------------------------------------------------------------
-# Chunking: --max-words 100 splits docs mode into exactly 2 chunks
+# Chunking: --max-words 100 across all three formats
# ---------------------------------------------------------------------------
@test "golden: chunked-md" {
smoosh --docs --no-interactive --max-words 100 --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
- # Concatenate chunks in sorted order with a boundary marker.
- local actual="" first=true chunk_file
- while IFS= read -r chunk_file; do
- if [[ "${first}" == "true" ]]; then
- first=false
- else
- actual="${actual}
---- CHUNK BOUNDARY ---
-"
- fi
- actual="${actual}$(cat "${chunk_file}")"
- done < <(find "${GOLDEN_OUT}" -maxdepth 1 -name '*.md' | LC_ALL=C sort)
- actual="$(normalise "${actual}")"
+ local actual
+ actual="$(normalise "$(_concat_chunks md)")"
golden_compare "chunked-md.golden" "${actual}"
}
+@test "golden: chunked-text" {
+ smoosh --docs --no-interactive --max-words 100 --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(_concat_chunks txt)")"
+ golden_compare "chunked-text.golden" "${actual}"
+}
+
+@test "golden: chunked-xml" {
+ smoosh --docs --no-interactive --max-words 100 --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(_concat_chunks xml)")"
+ golden_compare "chunked-xml.golden" "${actual}"
+}
+
# ---------------------------------------------------------------------------
# Hidden files: --include-hidden
# ---------------------------------------------------------------------------
@@ -255,6 +336,26 @@ golden_compare() {
golden_compare "json.golden" "${actual}"
}
+@test "golden: json-dry-run" {
+ # --json --dry-run: different JSON structure (file list, no chunks).
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --json --dry-run "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "json-dry-run.golden" "${actual}"
+}
+
+@test "golden: code-json" {
+ # --code --json: secrets_excluded array is populated (aws-creds.py flagged).
+ local actual exit_code
+ actual="$(smoosh --code --no-interactive --json --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "code-json.golden" "${actual}"
+}
+
@test "golden: quiet" {
# --quiet writes output file paths to stdout, one per line.
local actual exit_code
@@ -264,3 +365,23 @@ golden_compare() {
actual="$(normalise "${actual}")"
golden_compare "quiet.golden" "${actual}"
}
+
+@test "golden: chunked-quiet" {
+ # --quiet with chunking: outputs one path per chunk.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --quiet --max-words 100 --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "chunked-quiet.golden" "${actual}"
+}
+
+@test "golden: chunked-json" {
+ # --json with chunking: chunks[] array has multiple entries.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --json --max-words 100 --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "chunked-json.golden" "${actual}"
+}
From 273427d2f0c263a0fae78902979fcf3e04a9df46 Mon Sep 17 00:00:00 2001
From: K1-R1 <77465250+K1-R1@users.noreply.github.com>
Date: Sun, 15 Mar 2026 13:58:25 +0000
Subject: [PATCH 3/3] fix: cross-platform bugs in XML output and line-numbered
output
Two BSD-vs-GNU portability bugs caused golden file tests to fail on
Linux while passing on macOS:
1. BSD sed does not support -- as end-of-options. It treats -- as a
literal filename, fails to open it, then processes the real file.
The || fallback then also runs, doubling file content in XML CDATA
sections. GNU sed supports -- correctly but the doubled-content
golden files (generated on macOS) mismatched. Fix: pipe through
sed via cat instead of using sed -- file.
2. GNU nl adds a trailing newline to files without one; BSD nl does
not. Combined with the unconditional printf '\n' in
write_file_entry, this produced an extra blank line on Linux for
files like no-newline.md. Fix: capture nl output via $() (which
strips trailing newlines) and output with printf '%s', letting the
caller's printf '\n' add exactly one.
Regenerated all 9 affected golden files.
Signed-off-by: K1-R1 <77465250+K1-R1@users.noreply.github.com>
---
smoosh | 14 ++-
test/golden/expected/chunked-xml.golden | 48 +---------
test/golden/expected/code-xml-toc.golden | 94 +------------------
.../expected/docs-md-line-numbers.golden | 9 --
.../expected/docs-md-toc-line-numbers.golden | 9 --
.../expected/docs-text-line-numbers.golden | 9 --
.../docs-text-toc-line-numbers.golden | 9 --
.../expected/docs-xml-line-numbers.golden | 10 --
.../expected/docs-xml-toc-line-numbers.golden | 10 --
test/golden/expected/docs-xml.golden | 48 +---------
10 files changed, 13 insertions(+), 247 deletions(-)
diff --git a/smoosh b/smoosh
index 9bfc078..eea56f9 100755
--- a/smoosh
+++ b/smoosh
@@ -898,8 +898,13 @@ write_chunk_footer() {
# add_line_numbers FILE
# Print file content to stdout with right-aligned line numbers.
+# Captures via $() to strip trailing newlines — GNU nl adds one for files
+# that lack it; BSD nl preserves the original. printf '%s' ensures consistent
+# output on both, and the caller's printf '\n' adds exactly one.
add_line_numbers() {
- nl -ba -nrz -w4 -s' | ' -- "${1}" 2>/dev/null || cat -- "${1}"
+ local numbered
+ numbered="$(nl -ba -nrz -w4 -s' | ' -- "${1}" 2>/dev/null || cat -- "${1}")"
+ printf '%s' "${numbered}"
}
# write_file_entry FD REL_PATH
@@ -929,9 +934,10 @@ write_file_entry() {
add_line_numbers "${abs_path}" |
sed 's/]]>/]]]]>/g' >&"${fd}"
else
- # Group sed+fallback so only one redirect is applied to the combined stdout.
- { sed 's/]]>/]]]]>/g' -- "${abs_path}" 2>/dev/null ||
- cat -- "${abs_path}"; } >&"${fd}"
+ # Pipe through sed rather than sed -- file: BSD sed does not support --
+ # as end-of-options (it treats it as a literal filename, causing doubled
+ # output via the || fallback).
+ cat -- "${abs_path}" | sed 's/]]>/]]]]>/g' >&"${fd}"
fi
elif [[ "${LINE_NUMBERS}" == "true" ]]; then
add_line_numbers "${abs_path}" >&"${fd}"
diff --git a/test/golden/expected/chunked-xml.golden b/test/golden/expected/chunked-xml.golden
index 18f0672..f001e23 100644
--- a/test/golden/expected/chunked-xml.golden
+++ b/test/golden/expected/chunked-xml.golden
@@ -3,10 +3,6 @@
which breaks CDATA sections.
The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
-# CDATA Edge Case
-
-This file contains the sequence ]]> which breaks CDATA sections.
-The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
]]>
-
@@ -123,10 +87,6 @@ This file name contains a space to test path handling.
diff --git a/test/golden/expected/code-xml-toc.golden b/test/golden/expected/code-xml-toc.golden
index 1387e7d..a10f548 100644
--- a/test/golden/expected/code-xml-toc.golden
+++ b/test/golden/expected/code-xml-toc.golden
@@ -23,10 +23,6 @@
which breaks CDATA sections.
The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
-# CDATA Edge Case
-
-This file contains the sequence ]]> which breaks CDATA sections.
-The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
]]>
@@ -125,10 +88,6 @@ module.exports = { VERSION, greet };
-
@@ -241,12 +164,6 @@ These files exercise smoosh output format correctness.
\maketitle
This paper describes the golden fixture test repository.
\end{document}
-\documentclass{article}
-\title{Golden Fixture Paper}
-\begin{document}
-\maketitle
-This paper describes the golden fixture test repository.
-\end{document}
]]>
@@ -257,15 +174,6 @@ pub fn greet(name: &str) -> String {
format!("Hello, {}!", name)
}
-pub fn add(a: i32, b: i32) -> i32 {
- a + b
-}
-// Golden fixture Rust library.
-
-pub fn greet(name: &str) -> String {
- format!("Hello, {}!", name)
-}
-
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
diff --git a/test/golden/expected/docs-md-line-numbers.golden b/test/golden/expected/docs-md-line-numbers.golden
index 98fe04b..54cb4e1 100644
--- a/test/golden/expected/docs-md-line-numbers.golden
+++ b/test/golden/expected/docs-md-line-numbers.golden
@@ -13,7 +13,6 @@ Generated: TIMESTAMP
0004 | It contains files that exercise every smoosh capability.
-
---
### File: cdata-break.md
---
@@ -24,7 +23,6 @@ Generated: TIMESTAMP
0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
-
---
### File: deep/nested/path/doc.md
---
@@ -35,7 +33,6 @@ Generated: TIMESTAMP
0004 | smoosh should include this file with its full relative path preserved.
-
---
### File: empty.md
---
@@ -54,7 +51,6 @@ Generated: TIMESTAMP
0005 | See the readme for an overview of the project structure.
-
---
### File: it's-fine.md
---
@@ -65,7 +61,6 @@ Generated: TIMESTAMP
0004 | It tests filename quoting in shell pipelines.
-
---
### File: journal.org
---
@@ -79,7 +74,6 @@ Generated: TIMESTAMP
0007 | Each entry records a notable event during development.
-
---
### File: manual.adoc
---
@@ -91,7 +85,6 @@ Generated: TIMESTAMP
0005 | Refer to the guide for usage instructions and the readme for an overview.
-
---
### File: my notes.md
---
@@ -101,7 +94,6 @@ Generated: TIMESTAMP
0003 | This file name contains a space to test path handling.
-
---
### File: no-newline.md
---
@@ -119,7 +111,6 @@ Generated: TIMESTAMP
0004 | These files exercise smoosh output format correctness.
-
---
### File: paper.tex
---
diff --git a/test/golden/expected/docs-md-toc-line-numbers.golden b/test/golden/expected/docs-md-toc-line-numbers.golden
index 7bc1ff8..e9972e0 100644
--- a/test/golden/expected/docs-md-toc-line-numbers.golden
+++ b/test/golden/expected/docs-md-toc-line-numbers.golden
@@ -32,7 +32,6 @@ Generated: TIMESTAMP
0004 | It contains files that exercise every smoosh capability.
-
---
### File: cdata-break.md
---
@@ -43,7 +42,6 @@ Generated: TIMESTAMP
0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
-
---
### File: deep/nested/path/doc.md
---
@@ -54,7 +52,6 @@ Generated: TIMESTAMP
0004 | smoosh should include this file with its full relative path preserved.
-
---
### File: empty.md
---
@@ -73,7 +70,6 @@ Generated: TIMESTAMP
0005 | See the readme for an overview of the project structure.
-
---
### File: it's-fine.md
---
@@ -84,7 +80,6 @@ Generated: TIMESTAMP
0004 | It tests filename quoting in shell pipelines.
-
---
### File: journal.org
---
@@ -98,7 +93,6 @@ Generated: TIMESTAMP
0007 | Each entry records a notable event during development.
-
---
### File: manual.adoc
---
@@ -110,7 +104,6 @@ Generated: TIMESTAMP
0005 | Refer to the guide for usage instructions and the readme for an overview.
-
---
### File: my notes.md
---
@@ -120,7 +113,6 @@ Generated: TIMESTAMP
0003 | This file name contains a space to test path handling.
-
---
### File: no-newline.md
---
@@ -138,7 +130,6 @@ Generated: TIMESTAMP
0004 | These files exercise smoosh output format correctness.
-
---
### File: paper.tex
---
diff --git a/test/golden/expected/docs-text-line-numbers.golden b/test/golden/expected/docs-text-line-numbers.golden
index 15d1e92..640cfb7 100644
--- a/test/golden/expected/docs-text-line-numbers.golden
+++ b/test/golden/expected/docs-text-line-numbers.golden
@@ -14,7 +14,6 @@ File: README.md
0004 | It contains files that exercise every smoosh capability.
-
============================================================
File: cdata-break.md
============================================================
@@ -25,7 +24,6 @@ File: cdata-break.md
0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
-
============================================================
File: deep/nested/path/doc.md
============================================================
@@ -36,7 +34,6 @@ File: deep/nested/path/doc.md
0004 | smoosh should include this file with its full relative path preserved.
-
============================================================
File: empty.md
============================================================
@@ -55,7 +52,6 @@ File: guide.rst
0005 | See the readme for an overview of the project structure.
-
============================================================
File: it's-fine.md
============================================================
@@ -66,7 +62,6 @@ File: it's-fine.md
0004 | It tests filename quoting in shell pipelines.
-
============================================================
File: journal.org
============================================================
@@ -80,7 +75,6 @@ File: journal.org
0007 | Each entry records a notable event during development.
-
============================================================
File: manual.adoc
============================================================
@@ -92,7 +86,6 @@ File: manual.adoc
0005 | Refer to the guide for usage instructions and the readme for an overview.
-
============================================================
File: my notes.md
============================================================
@@ -102,7 +95,6 @@ File: my notes.md
0003 | This file name contains a space to test path handling.
-
============================================================
File: no-newline.md
============================================================
@@ -120,7 +112,6 @@ File: notes.txt
0004 | These files exercise smoosh output format correctness.
-
============================================================
File: paper.tex
============================================================
diff --git a/test/golden/expected/docs-text-toc-line-numbers.golden b/test/golden/expected/docs-text-toc-line-numbers.golden
index 88e759d..d34d84a 100644
--- a/test/golden/expected/docs-text-toc-line-numbers.golden
+++ b/test/golden/expected/docs-text-toc-line-numbers.golden
@@ -33,7 +33,6 @@ File: README.md
0004 | It contains files that exercise every smoosh capability.
-
============================================================
File: cdata-break.md
============================================================
@@ -44,7 +43,6 @@ File: cdata-break.md
0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
-
============================================================
File: deep/nested/path/doc.md
============================================================
@@ -55,7 +53,6 @@ File: deep/nested/path/doc.md
0004 | smoosh should include this file with its full relative path preserved.
-
============================================================
File: empty.md
============================================================
@@ -74,7 +71,6 @@ File: guide.rst
0005 | See the readme for an overview of the project structure.
-
============================================================
File: it's-fine.md
============================================================
@@ -85,7 +81,6 @@ File: it's-fine.md
0004 | It tests filename quoting in shell pipelines.
-
============================================================
File: journal.org
============================================================
@@ -99,7 +94,6 @@ File: journal.org
0007 | Each entry records a notable event during development.
-
============================================================
File: manual.adoc
============================================================
@@ -111,7 +105,6 @@ File: manual.adoc
0005 | Refer to the guide for usage instructions and the readme for an overview.
-
============================================================
File: my notes.md
============================================================
@@ -121,7 +114,6 @@ File: my notes.md
0003 | This file name contains a space to test path handling.
-
============================================================
File: no-newline.md
============================================================
@@ -139,7 +131,6 @@ File: notes.txt
0004 | These files exercise smoosh output format correctness.
-
============================================================
File: paper.tex
============================================================
diff --git a/test/golden/expected/docs-xml-line-numbers.golden b/test/golden/expected/docs-xml-line-numbers.golden
index a017d16..b1539cd 100644
--- a/test/golden/expected/docs-xml-line-numbers.golden
+++ b/test/golden/expected/docs-xml-line-numbers.golden
@@ -5,7 +5,6 @@
0002 |
0003 | This is the readme for the golden test fixture repository.
0004 | It contains files that exercise every smoosh capability.
-
]]>
@@ -13,7 +12,6 @@
0002 |
0003 | This file contains the sequence ]]]]> which breaks CDATA sections.
0004 | The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
-
]]>
@@ -21,7 +19,6 @@
0002 |
0003 | This document lives at a deeply nested path to test path handling.
0004 | smoosh should include this file with its full relative path preserved.
-
]]>
@@ -34,7 +31,6 @@
0003 |
0004 | This guide covers the basic usage of the golden fixture project.
0005 | See the readme for an overview of the project structure.
-
]]>
@@ -42,7 +38,6 @@
0002 |
0003 | This file's name contains an apostrophe.
0004 | It tests filename quoting in shell pipelines.
-
]]>
@@ -53,7 +48,6 @@
0005 |
0006 | This org file documents the golden fixture project history.
0007 | Each entry records a notable event during development.
-
]]>
@@ -62,14 +56,12 @@
0003 |
0004 | This manual describes the technical details of the golden fixture project.
0005 | Refer to the guide for usage instructions and the readme for an overview.
-
]]>
@@ -81,7 +73,6 @@
0002 |
0003 | Version one introduces the initial set of fixture files.
0004 | These files exercise smoosh output format correctness.
-
]]>
@@ -91,7 +82,6 @@
0004 | \maketitle
0005 | This paper describes the golden fixture test repository.
0006 | \end{document}
-
]]>
diff --git a/test/golden/expected/docs-xml-toc-line-numbers.golden b/test/golden/expected/docs-xml-toc-line-numbers.golden
index dbf54b6..e759c68 100644
--- a/test/golden/expected/docs-xml-toc-line-numbers.golden
+++ b/test/golden/expected/docs-xml-toc-line-numbers.golden
@@ -20,7 +20,6 @@
0002 |
0003 | This is the readme for the golden test fixture repository.
0004 | It contains files that exercise every smoosh capability.
-
]]>
@@ -28,7 +27,6 @@
0002 |
0003 | This file contains the sequence ]]]]> which breaks CDATA sections.
0004 | The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
-
]]>
@@ -36,7 +34,6 @@
0002 |
0003 | This document lives at a deeply nested path to test path handling.
0004 | smoosh should include this file with its full relative path preserved.
-
]]>
@@ -49,7 +46,6 @@
0003 |
0004 | This guide covers the basic usage of the golden fixture project.
0005 | See the readme for an overview of the project structure.
-
]]>
@@ -57,7 +53,6 @@
0002 |
0003 | This file's name contains an apostrophe.
0004 | It tests filename quoting in shell pipelines.
-
]]>
@@ -68,7 +63,6 @@
0005 |
0006 | This org file documents the golden fixture project history.
0007 | Each entry records a notable event during development.
-
]]>
@@ -77,14 +71,12 @@
0003 |
0004 | This manual describes the technical details of the golden fixture project.
0005 | Refer to the guide for usage instructions and the readme for an overview.
-
]]>
@@ -96,7 +88,6 @@
0002 |
0003 | Version one introduces the initial set of fixture files.
0004 | These files exercise smoosh output format correctness.
-
]]>
@@ -106,7 +97,6 @@
0004 | \maketitle
0005 | This paper describes the golden fixture test repository.
0006 | \end{document}
-
]]>
diff --git a/test/golden/expected/docs-xml.golden b/test/golden/expected/docs-xml.golden
index f3a1a04..08b1e1b 100644
--- a/test/golden/expected/docs-xml.golden
+++ b/test/golden/expected/docs-xml.golden
@@ -3,10 +3,6 @@
which breaks CDATA sections.
The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
-# CDATA Edge Case
-
-This file contains the sequence ]]> which breaks CDATA sections.
-The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
]]>
-