From 2c4c97f109c3dbb7db0249ac0c1ef37c517938f7 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Fri, 10 Feb 2023 12:40:17 +0000 Subject: [PATCH] feat: add test to check that nargo has been built from a clean commit --- test/6_array.test.js | 5 ----- test/version.test.js | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 test/version.test.js diff --git a/test/6_array.test.js b/test/6_array.test.js index 15de3d4..68f9d5b 100644 --- a/test/6_array.test.js +++ b/test/6_array.test.js @@ -32,11 +32,6 @@ test("promise resolved", async () => { promiseResolved = true; }); -test("prints version", async () => { - const processOutput = (await $`${nargoBin} --version`).toString(); - assert.match(processOutput, /nargo\s\d{1,2}.\d{1,2}/); -}); - test("nargo builds noir/test/test_data/6_array sucessfully", async () => { await within(async () => { cd("./noir/crates/nargo/tests/test_data/6_array"); diff --git a/test/version.test.js b/test/version.test.js new file mode 100644 index 0000000..dfab60a --- /dev/null +++ b/test/version.test.js @@ -0,0 +1,45 @@ +import { suite } from "uvu"; +import * as assert from "uvu/assert"; +import { cd } from "zx"; +import "zx/globals"; + +const test = suite("nargo"); + +const nargoBinPath = path.join(process.cwd(), "noir/dist/"); +const nargoBin = path.join(nargoBinPath, "nargo"); + +if (process.platform == "win32") { + $.shell = "powershell"; +} + +$.quote = (arg) => { + return arg; +}; + +$.verbose = true; + +// Helps detect unresolved ProcessPromise. +let promiseResolved = false; +process.on("exit", () => { + if (!promiseResolved) { + console.error("Error: ProcessPromise never resolved."); + process.exitCode = 1; + } +}); + +test("promise resolved", async () => { + await $`echo PromiseHelper`; + promiseResolved = true; +}); + +test("prints version", async () => { + const processOutput = (await $`${nargoBin} --version`).toString(); + assert.match(processOutput, /nargo\s\d{1,2}.\d{1,2}/); +}); + +test("reports a clean commit", async () => { + const processOutput = (await $`${nargoBin} --version`).toString(); + assert.not.match(processOutput, /modified/) +}); + +test.run();