Files
bun.sh/test/cli/run/log-test.test.ts
Jarred Sumner e848c3f226 Get Bun.write tests to pass on Windows and bun:sqlite tests to pass (#8393)
* Move ReadFile and WriteFile to separate file

* Use libuv for Bun.write()

* Update windows_event_loop.zig

* build

* Get bun-write tests to pass. Implement Bun.write with two files.

* UPdate

* Update

* Update failing test list

* update

* More

* More

* More

* More

* Mark the rest

* ok

* oops

* Update bun-write.test.js

* Update blob.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dave Caruso <me@paperdave.net>
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
2024-01-23 20:03:56 -08:00

54 lines
1.3 KiB
TypeScript

import { it, expect } from "bun:test";
import { basename, dirname, join } from "path";
import * as fs from "fs";
import { readableStreamToText, spawnSync } from "bun";
import { bunExe, bunEnv } from "harness";
it("should not log .env when quiet", async () => {
writeDirectoryTree("/tmp/log-test-silent", {
".env": "FOO=bar",
"bunfig.toml": `logLevel = "error"`,
"index.ts": "export default console.log('Here');",
});
const { stderr } = spawnSync({
cmd: [bunExe(), "index.ts"],
cwd: "/tmp/log-test-silent",
env: bunEnv,
});
expect(stderr!.toString()).toBe("");
});
it("should log .env by default", async () => {
writeDirectoryTree("/tmp/log-test-silent", {
".env": "FOO=bar",
"bunfig.toml": ``,
"index.ts": "export default console.log('Here');",
});
const { stderr } = spawnSync({
cmd: [bunExe(), "index.ts"],
cwd: "/tmp/log-test-silent",
env: bunEnv,
});
expect(stderr?.toString().includes(".env")).toBe(false);
});
function writeDirectoryTree(base: string, paths: Record<string, any>) {
for (const path of Object.keys(paths)) {
const content = paths[path];
const joined = join(base, path);
try {
fs.mkdirSync(join(base, dirname(path)), { recursive: true });
} catch (e) {}
try {
fs.unlinkSync(joined);
} catch (e) {}
fs.writeFileSync(joined, content);
}
}