diff options
author | 2023-04-03 18:12:51 -0700 | |
---|---|---|
committer | 2023-04-03 18:12:51 -0700 | |
commit | f3ab445c3fcae6a5177eb89e710e47f83cd7db42 (patch) | |
tree | 8b42e97149d1ee1ff1e0888d61241760617a950b | |
parent | ae849528b85cb2531432b5e265ae4e6d9179f624 (diff) | |
download | bun-f3ab445c3fcae6a5177eb89e710e47f83cd7db42.tar.gz bun-f3ab445c3fcae6a5177eb89e710e47f83cd7db42.tar.zst bun-f3ab445c3fcae6a5177eb89e710e47f83cd7db42.zip |
Use absolute paths morebun-v0.5.9
-rw-r--r-- | test/cli/install/bun-install-pathname-trailing-slash.test.ts | 3 | ||||
-rw-r--r-- | test/cli/install/dummy.registry.ts | 14 |
2 files changed, 11 insertions, 6 deletions
diff --git a/test/cli/install/bun-install-pathname-trailing-slash.test.ts b/test/cli/install/bun-install-pathname-trailing-slash.test.ts index dc01a4690..fc62a3822 100644 --- a/test/cli/install/bun-install-pathname-trailing-slash.test.ts +++ b/test/cli/install/bun-install-pathname-trailing-slash.test.ts @@ -3,11 +3,12 @@ import { mkdtempSync, realpathSync, rmSync } from "fs"; import { bunEnv, bunExe } from "harness"; import { tmpdir } from "os"; import { join } from "path"; +import { tmpdirSync } from "./dummy.registry"; let package_dir: string; beforeEach(() => { - package_dir = mkdtempSync(join(realpathSync(tmpdir()), "bun-install-path")); + package_dir = tmpdirSync("bun-install-path"); }); afterEach(() => { diff --git a/test/cli/install/dummy.registry.ts b/test/cli/install/dummy.registry.ts index a54fdb812..d4436ab73 100644 --- a/test/cli/install/dummy.registry.ts +++ b/test/cli/install/dummy.registry.ts @@ -4,6 +4,7 @@ * PACKAGE_DIR_TO_USE=(realpath .) bun test/cli/install/dummy.registry.ts */ import { file, Server } from "bun"; +import { mkdtempSync, realpathSync } from "fs"; let expect: typeof import("bun:test")["expect"]; @@ -11,6 +12,10 @@ import { mkdtemp, readdir, realpath, rm, writeFile } from "fs/promises"; import { tmpdir } from "os"; import { basename, join } from "path"; +export function tmpdirSync(pattern: string) { + return mkdtempSync(join(realpathSync(tmpdir()), pattern)); +} + type Handler = (req: Request) => Response | Promise<Response>; type Pkg = { name: string; @@ -94,14 +99,13 @@ export function dummyAfterAll() { server.stop(); } -let packageDirGetter: () => Promise<string> = async () => { - return await mkdtemp(join(await realpath(tmpdir()), "bun-install-test-" + testCounter++ + "--")); +let packageDirGetter: () => string = () => { + return tmpdirSync("bun-install-test-" + testCounter++ + "--"); }; export async function dummyBeforeEach() { resetHandler(); requested = 0; - package_dir = await packageDirGetter(); - + package_dir = packageDirGetter(); await writeFile( join(package_dir, "bunfig.toml"), ` @@ -129,7 +133,7 @@ if (Bun.main === import.meta.path) { }; }; if (process.env.PACKAGE_DIR_TO_USE) { - packageDirGetter = () => Promise.resolve(process.env.PACKAGE_DIR_TO_USE!); + packageDirGetter = () => process.env.PACKAGE_DIR_TO_USE!; } await dummyBeforeAll(); |