From 3a3bc8f0d8fd3b8a870e39165f24cbebe5b618a9 Mon Sep 17 00:00:00 2001 From: Ben Grant Date: Thu, 6 Mar 2025 11:43:05 -0800 Subject: [PATCH] test: increase change_in_bytes for napi_adjust_external_memory test JavaScriptCore ignores small deltas in its interface for reporting external memory: https://github.com/WebKit/WebKit/blob/8bbba2aa777cf326e24a4e5c63b1f51bd52315ff/Source/JavaScriptCore/heap/HeapInlines.h#L213-L229 More broadly, it seem reasonable for any other JS engine to do the same. Passing a large change ensures that the change is actually applied and the new adjusted value will be greater than zero (otherwise, the test relies on some external memory previously being reported as allocated). In turn, this makes the test more applicable to non-V8 implementations of Node-API. --- test/js-native-api/test_general/test_general.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/js-native-api/test_general/test_general.c b/test/js-native-api/test_general/test_general.c index 0cd1c54ee142f1..761b9cafa3a220 100644 --- a/test/js-native-api/test_general/test_general.c +++ b/test/js-native-api/test_general/test_general.c @@ -215,7 +215,8 @@ static napi_value testAdjustExternalMemory(napi_env env, napi_callback_info info napi_value result; int64_t adjustedValue; - NODE_API_CALL(env, napi_adjust_external_memory(env, 1, &adjustedValue)); + // Some JavaScript engines may ignore small increments passed to napi_adjust_external_memory + NODE_API_CALL(env, napi_adjust_external_memory(env, 10000, &adjustedValue)); NODE_API_CALL(env, napi_create_double(env, (double)adjustedValue, &result)); return result;