aboutsummaryrefslogtreecommitdiff
path: root/test/js/node
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-06-01 17:37:35 -0400
committerGravatar GitHub <noreply@github.com> 2023-06-01 14:37:35 -0700
commit4378ef8e97839f950ddfa180e466d0a8db187681 (patch)
tree2d99f2bbdd7cd38c0194fe4034f02945e37afb65 /test/js/node
parent2c1694f63bc4eb279aa708f216037d2e6204eaf1 (diff)
downloadbun-4378ef8e97839f950ddfa180e466d0a8db187681.tar.gz
bun-4378ef8e97839f950ddfa180e466d0a8db187681.tar.zst
bun-4378ef8e97839f950ddfa180e466d0a8db187681.zip
mark currently known test fails as `.todo` (#3052)
* start this * commit * mark all failing tests as todo * fasdfad * bundler tests * tests * adjust failing tests to todo * comment out some more tests * png as test
Diffstat (limited to 'test/js/node')
-rw-r--r--test/js/node/child_process/child_process-node.test.js78
-rw-r--r--test/js/node/child_process/child_process.test.ts58
-rw-r--r--test/js/node/process/process.test.js2
3 files changed, 49 insertions, 89 deletions
diff --git a/test/js/node/child_process/child_process-node.test.js b/test/js/node/child_process/child_process-node.test.js
index b845beb1e..1d354b702 100644
--- a/test/js/node/child_process/child_process-node.test.js
+++ b/test/js/node/child_process/child_process-node.test.js
@@ -165,61 +165,59 @@ describe("ChildProcess spawn bad stdio", () => {
// Monkey patch spawn() to create a child process normally, but destroy the
// stdout and stderr streams. This replicates the conditions where the streams
// cannot be properly created.
- function createChild(options, callback, done, target) {
- var __originalSpawn = ChildProcess.prototype.spawn;
- ChildProcess.prototype.spawn = function () {
- const err = __originalSpawn.apply(this, arguments);
-
- this.stdout.destroy();
- this.stderr.destroy();
-
- return err;
- };
-
- const { mustCall } = createCallCheckCtx(done);
- let cmd = `${bunExe()} ${import.meta.dir}/spawned-child.js`;
- if (target) cmd += " " + target;
- const child = exec(cmd, options, mustCall(callback));
- ChildProcess.prototype.spawn = __originalSpawn;
- return child;
+ function createChild(options, callback, target) {
+ return new Promise((resolve, reject) => {
+ var __originalSpawn = ChildProcess.prototype.spawn;
+ ChildProcess.prototype.spawn = function () {
+ const err = __originalSpawn.apply(this, arguments);
+
+ this.stdout.destroy();
+ this.stderr.destroy();
+
+ return err;
+ };
+
+ let cmd = `${bunExe()} ${import.meta.dir}/spawned-child.js`;
+ if (target) cmd += " " + target;
+ const child = exec(cmd, options, async (err, stdout, stderr) => {
+ try {
+ await callback(err, stdout, stderr);
+ resolve();
+ } catch (e) {
+ reject(e);
+ }
+ });
+ ChildProcess.prototype.spawn = __originalSpawn;
+ });
}
- it.skip("should handle normal execution of child process", done => {
- createChild(
- {},
- (err, stdout, stderr) => {
- strictEqual(err, null);
- strictEqual(stdout, "");
- strictEqual(stderr, "");
- },
- done,
- );
+ it("should handle normal execution of child process", async () => {
+ await createChild({}, (err, stdout, stderr) => {
+ strictEqual(err, null);
+ strictEqual(stdout, "");
+ strictEqual(stderr, "");
+ });
});
- it.skip("should handle error event of child process", done => {
+ it.todo("should handle error event of child process", async () => {
const error = new Error(`Command failed: bun ${import.meta.dir}/spawned-child.js ERROR`);
- createChild(
+ await createChild(
{},
(err, stdout, stderr) => {
strictEqual(stdout, "");
strictEqual(stderr, "");
strictEqual(err?.message, error.message);
},
- done,
"ERROR",
);
});
- it.skip("should handle killed process", done => {
- createChild(
- { timeout: 1 },
- (err, stdout, stderr) => {
- strictEqual(err.killed, true);
- strictEqual(stdout, "");
- strictEqual(stderr, "");
- },
- done,
- );
+ it("should handle killed process", async () => {
+ await createChild({ timeout: 1 }, (err, stdout, stderr) => {
+ strictEqual(err.killed, true);
+ strictEqual(stdout, "");
+ strictEqual(stderr, "");
+ });
});
});
diff --git a/test/js/node/child_process/child_process.test.ts b/test/js/node/child_process/child_process.test.ts
index f4e08ac74..d6fe065ca 100644
--- a/test/js/node/child_process/child_process.test.ts
+++ b/test/js/node/child_process/child_process.test.ts
@@ -1,45 +1,8 @@
-import { describe, it as it_, expect as expect_ } from "bun:test";
-import { gcTick } from "harness";
+import { describe, it, expect } from "bun:test";
import { ChildProcess, spawn, execFile, exec, fork, spawnSync, execFileSync, execSync } from "node:child_process";
import { tmpdir } from "node:os";
import { promisify } from "node:util";
-const expect = ((actual: unknown) => {
- gcTick();
- const ret = expect_(actual);
- gcTick();
- return ret;
-}) as typeof expect_;
-
-const it = ((label, fn) => {
- const hasDone = fn.length === 1;
- if (fn.constructor.name === "AsyncFunction" && hasDone) {
- return it_(label, async done => {
- gcTick();
- await fn(done);
- gcTick();
- });
- } else if (hasDone) {
- return it_(label, done => {
- gcTick();
- fn(done);
- gcTick();
- });
- } else if (fn.constructor.name === "AsyncFunction") {
- return it_(label, async () => {
- gcTick();
- await fn(() => {});
- gcTick();
- });
- } else {
- return it_(label, () => {
- gcTick();
- fn(() => {});
- gcTick();
- });
- }
-}) as typeof it_;
-
const debug = process.env.DEBUG ? console.log : () => {};
const platformTmpDir = require("fs").realpathSync(tmpdir());
@@ -95,7 +58,7 @@ describe("spawn()", () => {
expect(!!child2).toBe(false);
});
- it("should allow stdout to be read via Node stream.Readable `data` events", async () => {
+ it.todo("should allow stdout to be read via Node stream.Readable `data` events", async () => {
const child = spawn("bun", ["-v"]);
const result: string = await new Promise(resolve => {
child.stdout.on("error", e => {
@@ -112,12 +75,12 @@ describe("spawn()", () => {
expect(SEMVER_REGEX.test(result.trim())).toBe(true);
});
- it("should allow stdout to be read via .read() API", async done => {
+ it.todo("should allow stdout to be read via .read() API", async () => {
const child = spawn("bun", ["-v"]);
- const result: string = await new Promise(resolve => {
+ const result: string = await new Promise((resolve, reject) => {
let finalData = "";
child.stdout.on("error", e => {
- done(e);
+ reject(e);
});
child.stdout.on("readable", () => {
let data;
@@ -129,7 +92,6 @@ describe("spawn()", () => {
});
});
expect(SEMVER_REGEX.test(result.trim())).toBe(true);
- done();
});
it("should accept stdio option with 'ignore' for no stdio fds", async () => {
@@ -241,7 +203,7 @@ describe("spawn()", () => {
});
describe("execFile()", () => {
- it("should execute a file", async () => {
+ it.todo("should execute a file", async () => {
const result: Buffer = await new Promise((resolve, reject) => {
execFile("bun", ["-v"], { encoding: "buffer" }, (error, stdout, stderr) => {
if (error) {
@@ -255,7 +217,7 @@ describe("execFile()", () => {
});
describe("exec()", () => {
- it("should execute a command in a shell", async () => {
+ it.todo("should execute a command in a shell", async () => {
const result: Buffer = await new Promise((resolve, reject) => {
exec("bun -v", { encoding: "buffer" }, (error, stdout, stderr) => {
if (error) {
@@ -267,7 +229,7 @@ describe("exec()", () => {
expect(SEMVER_REGEX.test(result.toString().trim())).toBe(true);
});
- it("should return an object w/ stdout and stderr when promisified", async () => {
+ it.todo("should return an object w/ stdout and stderr when promisified", async () => {
const result = await promisify(exec)("bun -v");
expect(typeof result).toBe("object");
expect(typeof result.stdout).toBe("string");
@@ -299,7 +261,7 @@ describe("spawnSync()", () => {
});
describe("execFileSync()", () => {
- it("should execute a file synchronously", () => {
+ it.todo("should execute a file synchronously", () => {
const result = execFileSync("bun", ["-v"], { encoding: "utf8" });
expect(SEMVER_REGEX.test(result.trim())).toBe(true);
});
@@ -314,7 +276,7 @@ describe("execFileSync()", () => {
});
describe("execSync()", () => {
- it("should execute a command in the shell synchronously", () => {
+ it.todo("should execute a command in the shell synchronously", () => {
const result = execSync("bun -v", { encoding: "utf8" });
expect(SEMVER_REGEX.test(result.trim())).toBe(true);
});
diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js
index c9f92362c..f701be1b3 100644
--- a/test/js/node/process/process.test.js
+++ b/test/js/node/process/process.test.js
@@ -124,7 +124,7 @@ it("process.version starts with v", () => {
expect(process.version.startsWith("v")).toBeTruthy();
});
-it("process.argv0", () => {
+it.todo("process.argv0", () => {
expect(basename(process.argv0)).toBe(basename(process.argv[0]));
});