Skip to content

Commit

Permalink
Disable ram optimization in debug test
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtrKovalenko committed Apr 29, 2024
1 parent e0e216b commit 490faad
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
6 changes: 2 additions & 4 deletions bin/Main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion bin/node-bindings/odiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function optionsToArgs(options) {
break;

case "reduceRamUsage":
setFlag("reduceRamUsage", value);
setFlag("reduce-ram-usage", value);
break;

case "ignoreRegions": {
Expand Down
44 changes: 26 additions & 18 deletions test/node-binding.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
);

Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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,
Expand All @@ -83,7 +96,6 @@ test("Correctly parses ignore regions", async (t) => {
y2: 1334,
},
],
__binaryPath: BINARY_PATH,
}
);

Expand All @@ -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");
Expand All @@ -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);
Expand All @@ -125,7 +133,7 @@ test("Correctly outputs diff lines", async (t) => {
path.join(IMAGES_PATH, "diff.png"),
{
captureDiffLines: true,
__binaryPath: BINARY_PATH,
...options
}
);

Expand All @@ -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,
}
);

Expand Down

0 comments on commit 490faad

Please sign in to comment.