Skip to content

Commit 9317d5c

Browse files
Add a regression test for the .scm preload loader
Per review on #1286: nothing asserted the loader behavior itself. This imports the go tree-sitter query .scm directly and asserts it arrives as a non-empty string with capture syntax intact. Without the preload the file fails to load at all (verified: running it without the cli/bunfig preload fails), so a future refactor cannot silently regress the loader. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 7b21505 commit 9317d5c

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { describe, expect, test } from 'bun:test'
2+
3+
import goQuery from '../../../packages/code-map/src/tree-sitter-queries/tree-sitter-go-tags.scm'
4+
5+
/**
6+
* Guards test/setup-scm-loader.ts (registered as a preload in
7+
* cli/bunfig.toml). Without it, importing any module that reaches
8+
* @codebuff/sdk — which re-exports code-map, which imports .scm
9+
* tree-sitter query files — dies at import time with "Unknown file type",
10+
* which bun reports as an unhandled error between tests rather than a
11+
* failure (see docs/testing.md). This file imports a .scm directly: if the
12+
* preload is missing or regresses, the whole file fails to load instead of
13+
* passing vacuously.
14+
*/
15+
describe('setup-scm-loader preload', () => {
16+
test('loads .scm imports as strings', () => {
17+
expect(typeof goQuery).toBe('string')
18+
expect(goQuery.length).toBeGreaterThan(0)
19+
// Tree-sitter queries capture nodes with @capture names; the go tags
20+
// query is nontrivial, so this also proves the content came through
21+
// intact rather than as an empty stub.
22+
expect(goQuery).toContain('@')
23+
})
24+
})

0 commit comments

Comments
 (0)