mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { expect, test } from "bun:test";
|
||
import { mkdirSync, realpathSync } from "fs";
|
||
import { bunEnv, bunExe, bunRun } from "harness";
|
||
import { tmpdir } from "os";
|
||
import { join } from "path";
|
||
|
||
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');");
|
||
let { stdout } = Bun.spawnSync({
|
||
cmd: [bunExe(), join(dir, troll + ".js")],
|
||
cwd: dir,
|
||
env: bunEnv,
|
||
stdio: ["ignore", "pipe", "inherit"],
|
||
});
|
||
expect(stdout.toString("utf8")).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,
|
||
}`);
|
||
});
|