From 7695542423b36a84e6be56935648e325e366d313 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Wed, 29 May 2024 22:23:55 -0700 Subject: [PATCH] Test262: fixed flaky fs tests. Previously, two tests running in parallel could occasionally generate identical file names because Math.random() was used for part of the file name, leading to one of the tests failing. The fix is to use a single global counter to generate file names, ensuring deterministic and unique file names for each test. --- test/fs/methods.t.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/fs/methods.t.js b/test/fs/methods.t.js index cc840c6c..8077c0c0 100644 --- a/test/fs/methods.t.js +++ b/test/fs/methods.t.js @@ -3,6 +3,8 @@ includes: [compatFs.js, compatBuffer.js, runTsuite.js] flags: [async] ---*/ +let unique = 0; + function p(args, default_opts) { let params = Object.assign({}, default_opts, args); @@ -10,7 +12,7 @@ function p(args, default_opts) { let fname = params.args[0]; if (fname[0] == '@') { - let gen = `${test_dir}/fs_test_${Math.round(Math.random() * 1000000)}`; + let gen = `${test_dir}/fs_test_${unique++}`; params.args = params.args.map(v => v); params.args[0] = gen + fname.slice(1); } -- 2.47.3