From 2ba81d55f8b37b9dc0b726710d7cf80bba41df53 Mon Sep 17 00:00:00 2001 From: Florent BEAUCHAMP Date: Thu, 28 Sep 2023 16:49:00 +0200 Subject: [PATCH] fix(vhd-lib/test): collision during tests (#7062) multiple tests use the same temporary files --- CHANGELOG.unreleased.md | 1 + packages/vhd-lib/tests/utils.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 062ddb712..b2e9c5250 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -32,6 +32,7 @@ - @xen-orchestra/xapi minor +- vhd-lib patch - xo-server-backup-reports patch - xo-server patch - xo-web patch diff --git a/packages/vhd-lib/tests/utils.js b/packages/vhd-lib/tests/utils.js index 7a06ab75c..aab85baa6 100644 --- a/packages/vhd-lib/tests/utils.js +++ b/packages/vhd-lib/tests/utils.js @@ -25,8 +25,16 @@ async function checkFile(vhdName) { // Since the qemu-img check command isn't compatible with vhd format, we use // the convert command to do a check by conversion. Indeed, the conversion will // fail if the source file isn't a proper vhd format. - await execa('qemu-img', ['convert', '-fvpc', '-Oqcow2', vhdName, 'outputFile.qcow2']) - await fsPromise.unlink('./outputFile.qcow2') + const target = vhdName + '.qcow2' + try { + await execa('qemu-img', ['convert', '-fvpc', '-Oqcow2', vhdName, target]) + } finally { + try { + await fsPromise.unlink(target) + } catch (err) { + console.warn(err) + } + } } exports.checkFile = checkFile