-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Macro segmentation faults (#6756)
* Fix for seg faults when using macros * Update src/js_ast.zig to reflect review suggestions Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> * add test for checking non-zero exitcodes under macros. regression, issue 3830 --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
- Loading branch information
1 parent
2972cfa
commit cbc5ca7
Showing
3 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// test/regression/issue/03830.test.ts | ||
|
||
import { it, expect } from "bun:test"; | ||
import { bunEnv, bunExe } from "harness"; | ||
import { mkdirSync, rmSync, writeFileSync, readFileSync, mkdtempSync } from "fs"; | ||
import { tmpdir } from "os"; | ||
import { join } from "path"; | ||
|
||
it("macros should not lead to seg faults under any given input", async () => { | ||
// this test code follows the same structure as and | ||
// is based on the code for testing issue 4893 | ||
|
||
const testDir = mkdtempSync(join(tmpdir(), "issue3830-")); | ||
|
||
// Clean up from prior runs if necessary | ||
rmSync(testDir, { recursive: true, force: true }); | ||
|
||
// Create a directory with our test file | ||
mkdirSync(testDir, { recursive: true }); | ||
writeFileSync(join(testDir, "macro.ts"), 'export function fn(str) { return str; }'); | ||
writeFileSync(join(testDir, "index.ts"), "import { fn } from './macro' assert { type: 'macro' };\nfn(`©${''}`);"); | ||
|
||
const { stdout, exitCode } = Bun.spawnSync({ | ||
cmd: [bunExe(), "build", join(testDir, "index.ts")], | ||
env: bunEnv, | ||
stderr: "inherit", | ||
}); | ||
|
||
expect(exitCode).toBe(0); | ||
}); |