From: Dmitry Volyntsev Date: Thu, 30 May 2024 05:23:55 +0000 (-0700) Subject: Test262: fixed flaky fs tests. X-Git-Tag: 0.8.5~12 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=7695542423b36a84e6be56935648e325e366d313;p=njs.git 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. --- 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); }