Skip to content

Commit 40eb344

Browse files
author
Token Goat Test
committed
test: add built-bundle e2e coverage for the Rust macro_definition fix
Codex review of b4295fa flagged that its regression test only exercised parseFile() via Vitest, never the shipped dist/token-goat.mjs bundle -- missing the exact tree-shaking failure mode this repo's indexer has hit before (mod_item/foreign_mod_item/macro_definition were each added to RUST_KIND_BY_TYPE in isolation, none proven against the real bundle).
1 parent b4295fa commit 40eb344

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/worker_index_e2e.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ beforeAll(() => {
103103
'',
104104
].join('\n'),
105105
)
106+
// A `macro_rules!` definition, so a Rust extractor addition that only ever gets exercised
107+
// against source (never the tree-shaken bundle) is caught here (regression: the same class
108+
// of bug that dropped mod_item/foreign_mod_item/macro_definition from RUST_KIND_BY_TYPE could
109+
// just as easily be a bundling gap instead of a missing map entry).
110+
fs.writeFileSync(
111+
path.join(repo, 'macro_fixture.rs'),
112+
['#[macro_export]', 'macro_rules! bundleMacroSymbol {', ' () => {};', '}', ''].join('\n'),
113+
)
106114
// `git ls-files` lists staged files, so init + add is enough — no commit (avoids user config and any global commit hooks firing in the test).
107115
const git = (args: string[]): void => {
108116
execFileSync('git', args, { cwd: repo, stdio: 'ignore' })
@@ -136,6 +144,16 @@ describe('built bundle end-to-end indexing', () => {
136144
expect(sym.stdout).toContain('knownBundleSymbol')
137145
}, 60000)
138146

147+
it('index then symbol resolves a Rust macro_rules! definition from the built bundle', () => {
148+
const idx = runBundle(['index', repo])
149+
expect(idx.status).toBe(0)
150+
151+
const sym = runBundle(['symbol', 'bundleMacroSymbol'])
152+
expect(sym.status).toBe(0)
153+
expect(sym.stdout).toContain('bundleMacroSymbol')
154+
expect(sym.stdout).toContain('macro_fixture.rs')
155+
}, 60000)
156+
139157
// Ref extraction must survive bundling too: a build that tree-shakes the ref walker out would leave the refs table empty and this would return exit 1.
140158
it('refs --callers resolves a caller from the built bundle', () => {
141159
const idx = runBundle(['index', repo])

0 commit comments

Comments
 (0)