Skip to content

Commit

Permalink
test: skip test-sqlite-extensions when it is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jan 3, 2025
1 parent bf3bc4e commit 93f933a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions test/sqlite/test-sqlite-extensions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ if (process.config.variables.node_shared_sqlite) {
common.skip('Missing libsqlite_extension binary');
}

// Lib extension binary is named differently on different platforms
function resolveBuiltBinary(binary) {
const targetFile = fs.readdirSync(path.dirname(process.execPath)).find((file) => file.startsWith(binary));
return path.join(path.dirname(process.execPath), targetFile);
const binDir = path.dirname(process.execPath);
let binary;
for await (const { name } of await fs.promises.opendir(binDir)) {
// Lib extension binary is named differently on different platforms
if (name.startsWith('libsqlite_extension')) {
binary = path.join(binDir, name);
break;
}
}

const binary = resolveBuiltBinary('libsqlite_extension');
if (binary == null) {
common.skip('Missing libsqlite_extension binary');
}

test('should load extension successfully', () => {
const db = new sqlite.DatabaseSync(':memory:', {
Expand Down

0 comments on commit 93f933a

Please sign in to comment.