From e8f24d6ba0c4228d0a773b49be6c3841aab6bf81 Mon Sep 17 00:00:00 2001 From: Arr00 <13561405+arr00@users.noreply.github.com> Date: Thu, 19 Dec 2024 05:13:55 -0500 Subject: [PATCH] Set max old space size on coverage and test (#5382) Co-authored-by: Hadrien Croubois --- package.json | 2 +- scripts/checks/coverage.sh | 2 ++ scripts/set-max-old-space-size.sh | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 scripts/set-max-old-space-size.sh diff --git a/package.json b/package.json index d616c5583cd..afdd5e6c10a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "prepack": "scripts/prepack.sh", "generate": "scripts/generate/run.js", "version": "scripts/release/version.sh", - "test": "hardhat test", + "test": "scripts/set-max-old-space-size.sh && hardhat test", "test:generation": "scripts/checks/generation.sh", "test:inheritance": "scripts/checks/inheritance-ordering.js artifacts/build-info/*", "test:pragma": "scripts/checks/pragma-consistency.js artifacts/build-info/*", diff --git a/scripts/checks/coverage.sh b/scripts/checks/coverage.sh index a591069c493..e3b8ffc56b0 100755 --- a/scripts/checks/coverage.sh +++ b/scripts/checks/coverage.sh @@ -5,6 +5,8 @@ set -euo pipefail export COVERAGE=true export FOUNDRY_FUZZ_RUNS=10 +scripts/set-max-old-space-size.sh + # Hardhat coverage hardhat coverage diff --git a/scripts/set-max-old-space-size.sh b/scripts/set-max-old-space-size.sh new file mode 100755 index 00000000000..525c6786418 --- /dev/null +++ b/scripts/set-max-old-space-size.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# This script sets the node `--max-old-space-size` to 8192 if it is not set already. +# All existing `NODE_OPTIONS` are retained as is. + +export NODE_OPTIONS="${NODE_OPTIONS:-}" + +if [[ $NODE_OPTIONS != *"--max-old-space-size"* ]]; then + export NODE_OPTIONS="${NODE_OPTIONS} --max-old-space-size=8192" +fi