diff --git a/bin/Main.ml b/bin/Main.ml index 31109495..59bf290f 100644 --- a/bin/Main.ml +++ b/bin/Main.ml @@ -26,7 +26,7 @@ let main img1Path img2Path diffPath threshold outputDiffMask failOnLayoutChange Gc.set { (Gc.get ()) with - Gc.minor_heap_size = 32_000_000; + Gc.minor_heap_size = 64_000_000; Gc.stack_limit = 2_048_000; Gc.window_size = 25; }; @@ -60,7 +60,5 @@ let main img1Path img2Path diffPath threshold outputDiffMask failOnLayoutChange | Some output when outputDiffMask -> IO1.freeImage output | _ -> ()); - Gc.print_stat stdout; - flush stdout; - Unix.sleep 40; + (*Gc.print_stat stdout;*) exit exitCode diff --git a/bin/node-bindings/odiff.js b/bin/node-bindings/odiff.js index b78815f7..4efe3706 100644 --- a/bin/node-bindings/odiff.js +++ b/bin/node-bindings/odiff.js @@ -51,7 +51,7 @@ function optionsToArgs(options) { break; case "reduceRamUsage": - setFlag("reduceRamUsage", value); + setFlag("reduce-ram-usage", value); break; case "ignoreRegions": { diff --git a/test/node-binding.test.cjs b/test/node-binding.test.cjs index d3ef5425..9ae2a839 100644 --- a/test/node-binding.test.cjs +++ b/test/node-binding.test.cjs @@ -16,13 +16,31 @@ const BINARY_PATH = path.resolve( console.log(`Testing binary ${BINARY_PATH}`); +const options = { + __binaryPath: BINARY_PATH, +} + test("Outputs correct parsed result when images different", async (t) => { + const { reason, diffCount, diffPercentage } = await compare( + path.join(IMAGES_PATH, "donkey.png"), + path.join(IMAGES_PATH, "donkey-2.png"), + path.join(IMAGES_PATH, "diff.png"), + options + ); + + t.is(reason, "pixel-diff"); + t.is(diffCount, 109861); + t.is(diffPercentage, 2.85952484323); +}) + +test("Correctly works with reduceRamUsage", async (t) => { const { reason, diffCount, diffPercentage } = await compare( path.join(IMAGES_PATH, "donkey.png"), path.join(IMAGES_PATH, "donkey-2.png"), path.join(IMAGES_PATH, "diff.png"), { - __binaryPath: BINARY_PATH, + ...options, + reduceRamUsage: true, } ); @@ -36,10 +54,7 @@ test("Correctly parses threshold", async (t) => { path.join(IMAGES_PATH, "donkey.png"), path.join(IMAGES_PATH, "donkey-2.png"), path.join(IMAGES_PATH, "diff.png"), - { - threshold: 0.6, - __binaryPath: BINARY_PATH, - } + options ); t.is(reason, "pixel-diff"); @@ -52,10 +67,7 @@ test("Correctly parses antialiasing", async (t) => { path.join(IMAGES_PATH, "donkey.png"), path.join(IMAGES_PATH, "donkey-2.png"), path.join(IMAGES_PATH, "diff.png"), - { - antialiasing: true, - __binaryPath: BINARY_PATH, - } + options ); t.is(reason, "pixel-diff"); @@ -69,6 +81,7 @@ test("Correctly parses ignore regions", async (t) => { path.join(IMAGES_PATH, "donkey-2.png"), path.join(IMAGES_PATH, "diff.png"), { + ...options, ignoreRegions: [ { x1: 749, @@ -83,7 +96,6 @@ test("Correctly parses ignore regions", async (t) => { y2: 1334, }, ], - __binaryPath: BINARY_PATH, } ); @@ -95,9 +107,7 @@ test("Outputs correct parsed result when images different for cypress image", as path.join(IMAGES_PATH, "www.cypress.io.png"), path.join(IMAGES_PATH, "www.cypress.io-1.png"), path.join(IMAGES_PATH, "diff.png"), - { - __binaryPath: BINARY_PATH, - } + options ); t.is(reason, "pixel-diff"); @@ -110,9 +120,7 @@ test("Correctly handles same images", async (t) => { path.join(IMAGES_PATH, "donkey.png"), path.join(IMAGES_PATH, "donkey.png"), path.join(IMAGES_PATH, "diff.png"), - { - __binaryPath: BINARY_PATH, - } + options ); t.is(match, true); @@ -125,7 +133,7 @@ test("Correctly outputs diff lines", async (t) => { path.join(IMAGES_PATH, "diff.png"), { captureDiffLines: true, - __binaryPath: BINARY_PATH, + ...options } ); @@ -139,8 +147,8 @@ test("Returns meaningful error if file does not exist and noFailOnFsErrors", asy path.join(IMAGES_PATH, "not-existing.png"), path.join(IMAGES_PATH, "diff.png"), { + ...options, noFailOnFsErrors: true, - __binaryPath: BINARY_PATH, } );