test(btrfs): skip cli driver tests if no loop devices are available
All checks were successful
CI / ci (pull_request) Successful in 20s
All checks were successful
CI / ci (pull_request) Successful in 20s
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
createBtrfsTestVolume,
|
||||
destroyBtrfsTestVolume,
|
||||
disableQuota,
|
||||
hasLoopDevices,
|
||||
resetBtrfsTestVolume,
|
||||
} from '../utils/test_volume.ts';
|
||||
|
||||
@@ -44,6 +45,11 @@ await configure({
|
||||
],
|
||||
});
|
||||
|
||||
if (!(await hasLoopDevices())) {
|
||||
console.warn('Skipping BtrfsCliDriver tests: No loop devices available');
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
describe('BtrfsCliDriver', () => {
|
||||
beforeAll(async () => {
|
||||
vol = await createBtrfsTestVolume(512);
|
||||
|
||||
@@ -4,6 +4,7 @@ export {
|
||||
createBtrfsTestVolume,
|
||||
destroyBtrfsTestVolume,
|
||||
disableQuota,
|
||||
hasLoopDevices,
|
||||
resetBtrfsTestVolume,
|
||||
} from './test_volume.ts';
|
||||
export type { BtrfsTestVolume } from './test_volume.ts';
|
||||
|
||||
@@ -113,3 +113,14 @@ export async function disableQuota(mountPoint: string): Promise<void> {
|
||||
await run('sudo', ['btrfs', 'quota', 'disable', mountPoint]);
|
||||
log.info(`[BTRFS] Quota disabled`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current system has loop devices available.
|
||||
* Used to skip tests when running in environments without /dev/loop-control.
|
||||
*/
|
||||
export async function hasLoopDevices(): Promise<boolean> {
|
||||
const { code } = await new Deno.Command('sh', {
|
||||
args: ['-c', 'test -e /dev/loop-control && exit 0 || exit 1'],
|
||||
}).output();
|
||||
return code === 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user