Skip to content

Commit

Permalink
feat: allow checkPlatform to override execution libc
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Sep 18, 2023
1 parent 4fc835c commit ed831b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const checkPlatform = (target, force = false, environment = {}) => {
let libcFamily = null
if (target.libc) {
// libc checks only work in linux, any value is a failure if we aren't
if (platform !== 'linux') {
if (environment.libc) {
libcOk = checkList(environment.libc, target.libc)
} else if (platform !== 'linux') {
libcOk = false
} else {
const report = process.report.getReport()
Expand Down
18 changes: 18 additions & 0 deletions test/check-platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ t.test('nothing wrong with overridden cpu', async t =>
cpu: 'enten-cpu',
}))

t.test('nothing wrong with overridden libc', async t =>
checkPlatform({
cpu: 'enten-cpu',
libc: 'enten-libc',
}, false, {
cpu: 'enten-cpu',
libc: 'enten-libc',
}))

t.test('wrong os with overridden os', async t =>
t.throws(() => checkPlatform({
cpu: 'any',
Expand All @@ -75,6 +84,15 @@ t.test('wrong cpu with overridden cpu', async t =>
cpu: 'another-cpu',
}), { code: 'EBADPLATFORM' }))

t.test('wrong libc with overridden libc', async t =>
t.throws(() => checkPlatform({
cpu: 'enten-cpu',
os: 'any',
libc: 'enten-libc',
}, false, {
libc: 'another-libc',
}), { code: 'EBADPLATFORM' }))

t.test('libc', (t) => {
let PLATFORM = ''

Expand Down

0 comments on commit ed831b9

Please sign in to comment.