Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cmd/lx/golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func TestGolden(t *testing.T) {
}},
{name: "101_stdin_null_terminated", args: []string{"-0"}, stdin: "main.go\x00README.md\x00spaces/file with spaces.txt\x00"},
{name: "102_walk_nested_respects_root_ignore", args: []string{"parent_ignore_test/level1/level2"}},
{name: "103_complex_ignore_exceptions", args: []string{"ignore_exception_test"}},
}

runGoldenTests(t, cases, pkgDir, workDir, canonicalWorkDir)
Expand Down Expand Up @@ -446,6 +447,26 @@ func setupComplexFixture(t *testing.T) string {
create("parent_ignore_test/level1/level2/ignore_me.tmp", "ignore", 0644)
create("parent_ignore_test/level1/level2/keep_me.go", "package level2", 0644)

// --- Complex Ignore Exceptions Test ---
ignoreContent := "*\n!/src/**\n!/migrations/**\n!/assets/**\n!/data/**/*.data.xlsx\n!/data/**/index.json\n!langgraph.json\n!pyproject.toml\n!uv.lock\n"
create("ignore_exception_test/.gitignore", ignoreContent, 0644)

// Files that SHOULD BE KEPT (un-ignored)
create("ignore_exception_test/src/main.go", "package main", 0644)
create("ignore_exception_test/migrations/001_init.sql", "SELECT 1;", 0644)
create("ignore_exception_test/assets/logo.png", "image_data", 0644)
create("ignore_exception_test/data/nested/deep/my.data.xlsx", "excel_data", 0644)
create("ignore_exception_test/data/index.json", "{}", 0644)
create("ignore_exception_test/langgraph.json", "{}", 0644)
create("ignore_exception_test/pyproject.toml", "[tool]", 0644)
create("ignore_exception_test/uv.lock", "lock_data", 0644)

// Files that SHOULD BE IGNORED
create("ignore_exception_test/should_ignore.txt", "ignore me", 0644)
create("ignore_exception_test/data/secret.csv", "1,2,3", 0644)
create("ignore_exception_test/data/nested/deep/ignore.xlsx", "ignore", 0644)
create("ignore_exception_test/other_dir/file.go", "package other", 0644)

// Image test asset
create("assets/logo.png", "\x89PNG\r\n\x1a\n\x00\x00\x00\x0D", 0644)

Expand Down
92 changes: 68 additions & 24 deletions cmd/lx/testdata/golden/001_walk_default.golden
Original file line number Diff line number Diff line change
@@ -1,132 +1,176 @@
--- STDOUT ---
[1/24] README.md (2 rows)
[1/32] README.md (2 rows)
---
```markdown
# Project
Documentation here.
```

[2/24] assets/logo.png - binary file skipped (12 B)
[2/32] assets/logo.png - binary file skipped (12 B)

[3/24] configs/custom_sections.yaml (1 rows)
[3/32] configs/custom_sections.yaml (1 rows)
---
```yaml
section_header_template: "*** {{ .Body }} ***\n"
```

[4/24] configs/custom_template.yaml (1 rows)
[4/32] configs/custom_template.yaml (1 rows)
---
```yaml
file_content_template: "File: {{ .Path }}\nContent:\n{{ .Content }}"
```

[5/24] configs/follow.yaml (1 rows)
[5/32] configs/follow.yaml (1 rows)
---
```yaml
follow_symlinks: true
```

[6/24] configs/hidden.yaml (1 rows)
[6/32] configs/hidden.yaml (1 rows)
---
```yaml
show_hidden: true
```

[7/24] configs/no_links.yaml (1 rows)
[7/32] configs/no_links.yaml (1 rows)
---
```yaml
no_file_links: true
```

[8/24] doc/notes.txt (1 rows)
[8/32] doc/notes.txt (1 rows)
---
```text
some notes
```

[9/24] ignore_test/foo.go (1 rows)
[9/32] ignore_exception_test/assets/logo.png - binary file skipped (10 B)

[10/32] ignore_exception_test/data/index.json (1 rows)
---
```json
{}
```

[11/32] ignore_exception_test/data/nested/deep/my.data.xlsx (1 rows)
---
```
excel_data
```

[12/32] ignore_exception_test/langgraph.json (1 rows)
---
```json
{}
```

[13/32] ignore_exception_test/migrations/001_init.sql (1 rows)
---
```sql
SELECT 1;
```

[14/32] ignore_exception_test/pyproject.toml (1 rows)
---
```toml
[tool]
```

[15/32] ignore_exception_test/src/main.go (1 rows)
---
```go
package main
```

[16/32] ignore_exception_test/uv.lock (1 rows)
---
```
lock_data
```

[17/32] ignore_test/foo.go (1 rows)
---
```go
package foo
```

[10/24] langs/Dockerfile (1 rows)
[18/32] langs/Dockerfile (1 rows)
---
```dockerfile
FROM scratch
```

[11/24] langs/main.rs (1 rows)
[19/32] langs/main.rs (1 rows)
---
```rust
fn main() {}
```

[12/24] langs/script_no_ext (2 rows)
[20/32] langs/script_no_ext (2 rows)
---
```bash
#!/bin/bash
echo hi
```

[13/24] links/cycle_a/visible.txt (1 rows)
[21/32] links/cycle_a/visible.txt (1 rows)
---
```text
a
```

[14/24] links/cycle_b/visible.txt (1 rows)
[22/32] links/cycle_b/visible.txt (1 rows)
---
```text
b
```

[15/24] links/link_to_main.go (~1 rows)
[23/32] links/link_to_main.go (~1 rows)
---
```go
package main
func main() {}
```

[16/24] links/safe_target/recursion.txt (1 rows)
[24/32] links/safe_target/recursion.txt (1 rows)
---
```text
I am safe
```

[17/24] main.go (2 rows)
[25/32] main.go (2 rows)
---
```go
package main
func main() {}
```

[18/24] main_test.go (2 rows)
[26/32] main_test.go (2 rows)
---
```go
package main
import "testing"
```

[19/24] parent_ignore_test/level1/level2/keep_me.go (1 rows)
[27/32] parent_ignore_test/level1/level2/keep_me.go (1 rows)
---
```go
package level2
```

[20/24] pkg/util.go (1 rows)
[28/32] pkg/util.go (1 rows)
---
```go
package pkg
```

[21/24] spaces/file with spaces.txt (1 rows)
[29/32] spaces/file with spaces.txt (1 rows)
---
```text
content with spaces
```

[22/24] src/large.txt (100 rows)
[30/32] src/large.txt (100 rows)
---
```text
Line xxxxxxxxxx
Expand Down Expand Up @@ -231,13 +275,13 @@ Line xxxxxxxxxx
Line xxxxxxxxxx
```

[23/24] src/script.py (1 rows)
[31/32] src/script.py (1 rows)
---
```python
print('hello')
```

[24/24] /ROOT/content/links/broken_link - error: open /ROOT/content/links/broken_link: FILE_NOT_FOUND
[32/32] /ROOT/content/links/broken_link - error: open /ROOT/content/links/broken_link: FILE_NOT_FOUND


--- STDERR ---
Expand Down
56 changes: 32 additions & 24 deletions cmd/lx/testdata/golden/002_walk_compact.golden
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
--- STDOUT ---
[1/24] README.md (2 rows)
[2/24] assets/logo.png - binary file skipped (12 B)
[3/24] configs/custom_sections.yaml (1 rows)
[4/24] configs/custom_template.yaml (1 rows)
[5/24] configs/follow.yaml (1 rows)
[6/24] configs/hidden.yaml (1 rows)
[7/24] configs/no_links.yaml (1 rows)
[8/24] doc/notes.txt (1 rows)
[9/24] ignore_test/foo.go (1 rows)
[10/24] langs/Dockerfile (1 rows)
[11/24] langs/main.rs (1 rows)
[12/24] langs/script_no_ext (2 rows)
[13/24] links/cycle_a/visible.txt (1 rows)
[14/24] links/cycle_b/visible.txt (1 rows)
[15/24] links/link_to_main.go (~1 rows)
[16/24] links/safe_target/recursion.txt (1 rows)
[17/24] main.go (2 rows)
[18/24] main_test.go (2 rows)
[19/24] parent_ignore_test/level1/level2/keep_me.go (1 rows)
[20/24] pkg/util.go (1 rows)
[21/24] spaces/file with spaces.txt (1 rows)
[22/24] src/large.txt (100 rows)
[23/24] src/script.py (1 rows)
[1/32] README.md (2 rows)
[2/32] assets/logo.png - binary file skipped (12 B)
[3/32] configs/custom_sections.yaml (1 rows)
[4/32] configs/custom_template.yaml (1 rows)
[5/32] configs/follow.yaml (1 rows)
[6/32] configs/hidden.yaml (1 rows)
[7/32] configs/no_links.yaml (1 rows)
[8/32] doc/notes.txt (1 rows)
[9/32] ignore_exception_test/assets/logo.png - binary file skipped (10 B)
[10/32] ignore_exception_test/data/index.json (1 rows)
[11/32] ignore_exception_test/data/nested/deep/my.data.xlsx (1 rows)
[12/32] ignore_exception_test/langgraph.json (1 rows)
[13/32] ignore_exception_test/migrations/001_init.sql (1 rows)
[14/32] ignore_exception_test/pyproject.toml (1 rows)
[15/32] ignore_exception_test/src/main.go (1 rows)
[16/32] ignore_exception_test/uv.lock (1 rows)
[17/32] ignore_test/foo.go (1 rows)
[18/32] langs/Dockerfile (1 rows)
[19/32] langs/main.rs (1 rows)
[20/32] langs/script_no_ext (2 rows)
[21/32] links/cycle_a/visible.txt (1 rows)
[22/32] links/cycle_b/visible.txt (1 rows)
[23/32] links/link_to_main.go (~1 rows)
[24/32] links/safe_target/recursion.txt (1 rows)
[25/32] main.go (2 rows)
[26/32] main_test.go (2 rows)
[27/32] parent_ignore_test/level1/level2/keep_me.go (1 rows)
[28/32] pkg/util.go (1 rows)
[29/32] spaces/file with spaces.txt (1 rows)
[30/32] src/large.txt (100 rows)
[31/32] src/script.py (1 rows)

[24/24] /ROOT/content/links/broken_link - error: open /ROOT/content/links/broken_link: FILE_NOT_FOUND
[32/32] /ROOT/content/links/broken_link - error: open /ROOT/content/links/broken_link: FILE_NOT_FOUND


--- STDERR ---
Expand Down
Loading
Loading