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.
flags: [async]
---*/
+let unique = 0;
+
function p(args, default_opts) {
let params = Object.assign({}, default_opts, args);
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);
}