From 8717303a80668e4043a9ae1586ff1d4d3b12ff00 Mon Sep 17 00:00:00 2001 From: Yash Sharma Date: Wed, 9 Aug 2023 10:43:04 -0700 Subject: Add support for `bun --revision` (#4027) Co-authored-by: Yash Sharma --- test/cli/bun.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test') diff --git a/test/cli/bun.test.ts b/test/cli/bun.test.ts index 97ea52ecd..8bb3ca744 100644 --- a/test/cli/bun.test.ts +++ b/test/cli/bun.test.ts @@ -32,4 +32,31 @@ describe("bun", () => { }); } }); + + describe("revision", () => { + test("revision generates version numbers correctly", () => { + var { stdout, exitCode } = Bun.spawnSync({ + cmd: [bunExe(), "--version"], + env: {}, + stderr: "inherit", + }); + var version = stdout.toString().trim(); + + var { stdout, exitCode } = Bun.spawnSync({ + cmd: [bunExe(), "--revision"], + env: {}, + stderr: "inherit", + }); + var revision = stdout.toString().trim(); + + expect(exitCode).toBe(0); + expect(revision).toStartWith(version); + // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string + expect(revision).toMatch( + new RegExp( + "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$", + ), + ); + }); + }); }); -- cgit v1.2.3