mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
## Summary - Refactor 16 test files to use async `Bun.spawn` instead of `Bun.spawnSync` - Wrap tests in `describe.concurrent` blocks for parallel execution - Use `await using` for automatic resource cleanup ## Performance Improvement | Test File | Before | After | Improvement | |-----------|--------|-------|-------------| | `node-module-module.test.js` (28 tests) | ~325ms | ~185ms | **43% faster** | | `non-english-import.test.js` (3 tests) | ~238ms | ~157ms | **34% faster** | ## Files Changed - `test/cli/run/commonjs-invalid.test.ts` - `test/cli/run/commonjs-no-export.test.ts` - `test/cli/run/empty-file.test.ts` - `test/cli/run/jsx-symbol-collision.test.ts` - `test/cli/run/run-cjs.test.ts` - `test/cli/run/run-extensionless.test.ts` - `test/cli/run/run-shell.test.ts` - `test/cli/run/run-unicode.test.ts` - `test/js/bun/resolve/non-english-import.test.js` - `test/js/node/module/node-module-module.test.js` - `test/regression/issue/00631.test.ts` - `test/regression/issue/03216.test.ts` - `test/regression/issue/03830.test.ts` - `test/regression/issue/04011.test.ts` - `test/regression/issue/04893.test.ts` - `test/regression/issue/hashbang-still-works.test.ts` ## Test plan - [x] All refactored tests pass with `USE_SYSTEM_BUN=1 bun test <file>` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
||
import { mkdirSync, realpathSync } from "fs";
|
||
import { bunEnv, bunExe, bunRun } from "harness";
|
||
import { tmpdir } from "os";
|
||
import { join } from "path";
|
||
|
||
describe.concurrent("run-unicode", () => {
|
||
test("running a weird filename works", async () => {
|
||
const troll = process.platform == "win32" ? "💥'\\" : "💥'\"\n";
|
||
const dir = join(realpathSync(tmpdir()), "bun-run-test" + troll);
|
||
mkdirSync(dir, { recursive: true });
|
||
console.log("dir", dir);
|
||
// i this it's possible that the filesystem rejects the path
|
||
await Bun.write(join(dir, troll + ".js"), "console.log('hello world');");
|
||
await using proc = Bun.spawn({
|
||
cmd: [bunExe(), join(dir, troll + ".js")],
|
||
cwd: dir,
|
||
env: bunEnv,
|
||
stdin: "ignore",
|
||
stdout: "pipe",
|
||
stderr: "inherit",
|
||
});
|
||
const stdout = await proc.stdout.text();
|
||
expect(stdout).toEqual("hello world\n");
|
||
});
|
||
|
||
test("ts enum with utf16 works", () => {
|
||
const result = bunRun(join(import.meta.dir, "ts-enum-fixture.ts"));
|
||
expect(result.stdout).toBe(`{
|
||
"1": "aaaa\u5FEB\u00E9\u00E9",
|
||
"123": "bbb",
|
||
"\u5B89\u5168\u4E32\u884C": "\u5B89\u5168\u4E32\u884C",
|
||
aaa: "\u5E73\u8861\u4E32\u884C",
|
||
"aa\u90ED": "\u5FEB\u901F\u4E32\u884C",
|
||
"\u5B89\u5168\u5E76\u884C": "\u5B89\u5168\u5E76\u884C",
|
||
"\u5E73\u8861\u5E76\u884C": "\u5E73\u8861\u5E76\u884C",
|
||
"\u5FEB\u901F\u5E76\u884C": "\u5FEB\u901F\u5E76\u884C",
|
||
"aaaa\u5FEB\u00E9\u00E9": 1,
|
||
"Fran\u00E7ais": 123,
|
||
bbb: 123,
|
||
}`);
|
||
});
|
||
});
|