improve test (#3731)

- minor build diffs
This commit is contained in:
Alex Lam S.L
2023-07-22 02:42:30 +03:00
committed by GitHub
parent c4f062dbf4
commit 311dffc690
5 changed files with 13 additions and 15 deletions

View File

@@ -188,7 +188,7 @@ function spawnSync(file, args, options) {
else if (typeof input === "string")
bunStdio[0] = Buffer.from(input, encoding || "utf8");
else
throw new ERR_INVALID_ARG_TYPE(`options.stdio[0]`, ["Buffer", "TypedArray", "DataView", "string"], input);
throw new ERR_INVALID_ARG_TYPE("options.stdio[0]", ["Buffer", "TypedArray", "DataView", "string"], input);
const { stdout, stderr, success, exitCode } = Bun.spawnSync({
cmd: options.args,
env: options.env || void 0,

View File

@@ -26,7 +26,7 @@ var isIPv4 = function(s) {
self.emit("listening");
}, createServer = function(options, connectionListener) {
return new Server(options, connectionListener);
}, v4Seg = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])", v4Str = `(${v4Seg}[.]){3}${v4Seg}`, IPv4Reg = new RegExp(`^${v4Str}$`), v6Seg = "(?:[0-9a-fA-F]{1,4})", IPv6Reg = new RegExp("^(" + `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` + `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` + `(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|` + `(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|` + `(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|` + `(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` + `(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` + `(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` + ")(%[0-9a-zA-Z-.:]{1,})?$"), { Bun, createFIFO, Object } = globalThis[Symbol.for("Bun.lazy")]("primordials"), { connect: bunConnect } = Bun, { setTimeout } = globalThis, bunTlsSymbol = Symbol.for("::buntls::"), bunSocketServerHandlers = Symbol.for("::bunsocket_serverhandlers::"), bunSocketServerConnections = Symbol.for("::bunnetserverconnections::"), bunSocketServerOptions = Symbol.for("::bunnetserveroptions::"), bunSocketInternal = Symbol.for("::bunnetsocketinternal::"), bunTLSConnectOptions = Symbol.for("::buntlsconnectoptions::"), SocketClass, Socket = function(InternalSocket) {
}, v4Seg = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])", v4Str = `(${v4Seg}[.]){3}${v4Seg}`, IPv4Reg = new RegExp(`^${v4Str}\$`), v6Seg = "(?:[0-9a-fA-F]{1,4})", IPv6Reg = new RegExp("^(" + `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` + `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` + `(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|` + `(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|` + `(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|` + `(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` + `(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` + `(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` + ")(%[0-9a-zA-Z-.:]{1,})?$"), { Bun, createFIFO, Object } = globalThis[Symbol.for("Bun.lazy")]("primordials"), { connect: bunConnect } = Bun, { setTimeout } = globalThis, bunTlsSymbol = Symbol.for("::buntls::"), bunSocketServerHandlers = Symbol.for("::bunsocket_serverhandlers::"), bunSocketServerConnections = Symbol.for("::bunnetserverconnections::"), bunSocketServerOptions = Symbol.for("::bunnetserveroptions::"), bunSocketInternal = Symbol.for("::bunnetsocketinternal::"), bunTLSConnectOptions = Symbol.for("::buntlsconnectoptions::"), SocketClass, Socket = function(InternalSocket) {
return SocketClass = InternalSocket, Object.defineProperty(SocketClass.prototype, Symbol.toStringTag, {
value: "Socket",
enumerable: !1

Binary file not shown.

View File

@@ -609,12 +609,16 @@ it("should run beforeAll() & afterAll() even without tests", async () => {
await writeFile(
join(test_dir, "empty.test.js"),
`
beforeAll(() => console.log("???BEFORE ALL???"));
afterAll(() => console.log("!!!AFTER ALL!!!"));
beforeAll(() => console.log("before all"));
beforeEach(() => console.log("before each"));
afterEach(() => console.log("after each"));
afterAll(() => console.log("after all"));
describe("empty", () => {
beforeAll(() => console.log(">>>BEFORE ALL>>>"));
afterAll(() => console.log("<<<AFTER ALL<<<"));
beforeAll(() => console.log("before all scoped"));
beforeEach(() => console.log("before each scoped"));
afterEach(() => console.log("after each scoped"));
afterAll(() => console.log("after all scoped"));
});
`,
);
@@ -632,13 +636,7 @@ describe("empty", () => {
expect(err).toContain("0 fail");
expect(stdout).toBeDefined();
const out = await new Response(stdout).text();
expect(out.split(/\r?\n/)).toEqual([
"???BEFORE ALL???",
">>>BEFORE ALL>>>",
"<<<AFTER ALL<<<",
"!!!AFTER ALL!!!",
"",
]);
expect(out.split(/\r?\n/)).toEqual(["before all", "before all scoped", "after all scoped", "after all", ""]);
expect(await exited).toBe(0);
} finally {
await rm(test_dir, { force: true, recursive: true });

View File

@@ -11,6 +11,7 @@
"@types/supertest": "2.0.12",
"bktree-fast": "0.0.7",
"body-parser": "1.20.2",
"comlink": "4.4.1",
"dedent": "0.7.0",
"esbuild": "0.18.6",
"express": "4.18.2",
@@ -30,8 +31,7 @@
"undici": "5.20.0",
"vitest": "0.32.2",
"webpack": "5.88.0",
"webpack-cli": "4.7.2",
"comlink": "4.4.1"
"webpack-cli": "4.7.2"
},
"private": true,
"scripts": {