-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix FreeBSD runtime issues found by running the test suite #38242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
22d8a41
70f1c18
22a1ad6
4ef665e
2b2d71d
ff432e1
3abfc1e
510e842
476f523
6f1173e
550ef34
e74a602
77be87c
523170f
816246d
67e160f
517e033
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,8 +21,11 @@ import { normalize as normalizeWindows } from "node:path/win32"; | |
|
|
||
| export const isWindows = process.platform === "win32"; | ||
| export const isMacOS = process.platform === "darwin"; | ||
| export const isLinux = process.platform === "linux"; | ||
| export const isPosix = isMacOS || isLinux; | ||
| // Node built for Termux/bionic reports "android"; CI models that as linux + abi=android. | ||
| export const isAndroid = process.platform === "android"; | ||
| export const isLinux = process.platform === "linux" || isAndroid; | ||
| export const isFreeBSD = process.platform === "freebsd"; | ||
| export const isPosix = isMacOS || isLinux || isFreeBSD; | ||
|
|
||
| export const isArm64 = process.arch === "arm64"; | ||
| export const isX64 = process.arch === "x64"; | ||
|
|
@@ -1538,23 +1541,26 @@ export function parseNumber(value) { | |
|
|
||
| /** | ||
| * @param {string} string | ||
| * @returns {"darwin" | "linux" | "windows"} | ||
| * @returns {"darwin" | "linux" | "windows" | "freebsd"} | ||
| */ | ||
| export function parseOs(string) { | ||
| if (/darwin|apple|mac/i.test(string)) { | ||
| return "darwin"; | ||
| } | ||
| if (/linux/i.test(string)) { | ||
| if (/linux|android/i.test(string)) { | ||
| return "linux"; | ||
| } | ||
| if (/freebsd/i.test(string)) { | ||
| return "freebsd"; | ||
| } | ||
| if (/win/i.test(string)) { | ||
| return "windows"; | ||
| } | ||
| throw new Error(`Unsupported operating system: ${string}`); | ||
| } | ||
|
Comment on lines
+1544
to
1560
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 6 '\b(parseOs|getAbi|isAndroid|isFreeBSD|libcPathForDlopen)\b' scripts testRepository: oven-sh/bun Length of output: 40795 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- candidate tests and utility references ---'
git ls-files | rg '(^|/)(scripts|test)/.*(utils|platform|machine|runner|agent).*\.(m?js|ts)$' | head -200
printf '%s\n' '--- direct parseOs/getAbi test references ---'
rg -n -C 8 '\b(parseOs|getAbi|getOs|getAbiVersion)\b' --glob '*.{js,mjs,ts,tsx}' --glob '!scripts/utils.mjs' .
printf '%s\n' '--- utility exports and nearby test-oriented sections ---'
ast-grep outline scripts/utils.mjs --lang javascript | rg -n 'parseOs|getOs|getAbi|getAbiVersion|parseTarget|parseArch'
printf '%s\n' '--- repository review guidance ---'
if [ -f REVIEW.md ]; then sed -n '1,220p' REVIEW.md; else printf '%s\n' 'REVIEW.md not present'; fiRepository: oven-sh/bun Length of output: 50367 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- all tests under scripts and nearby test directories ---'
git ls-files 'scripts/**' 'test/**' | rg '(^|/)(test|tests|__tests__)/|\.test\.(m?js|ts)$|\.spec\.(m?js|ts)$' | head -300
printf '%s\n' '--- exact implementation context ---'
sed -n '1528,1635p' scripts/utils.mjs
printf '%s\n' '--- package and test command definitions ---'
rg -n -C 4 '"test"|bun bd test|scripts/utils|utils\.mjs' package.json scripts test --glob 'package.json' --glob '*.mjs' --glob '*.ts' --glob '*.js' | head -300Repository: oven-sh/bun Length of output: 18414 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- changed files ---'
git diff --name-status -- scripts/utils.mjs test scripts package.json .github 2>/dev/null || true
printf '%s\n' '--- references to the module itself ---'
rg -n -C 3 'scripts/utils\.mjs|from ["'\''](\.\./)*scripts/utils|import\(["'\''][^"'\'']*utils\.mjs' . --glob '!scripts/utils.mjs' --glob '!test/napi/node-napi-tests/**'
printf '%s\n' '--- test-like files that import scripts utilities ---'
python3 - <<'PY'
import pathlib, re
for p in pathlib.Path('.').rglob('*'):
if not p.is_file() or any(part in {'.git', 'node_modules', 'build', 'dist'} for part in p.parts):
continue
if p.suffix not in {'.js', '.mjs', '.ts', '.tsx'}:
continue
text = p.read_text(errors='ignore')
if re.search(r'(scripts/utils\.mjs|parseOs|getAbi|getOs|getAbiVersion)', text) and ('test' in p.parts or 'spec' in p.name):
print(p)
PY
printf '%s\n' '--- focused diff for the implementation and any nearby tests ---'
git diff -- scripts/utils.mjs 'test/**' 'scripts/**' | sed -n '1,260p'Repository: oven-sh/bun Length of output: 3202 Add regression coverage for No test files directly cover these functions. Add cases for FreeBSD parsing, Android-to- 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| /** | ||
| * @returns {"darwin" | "linux" | "windows"} | ||
| * @returns {"darwin" | "linux" | "windows" | "freebsd"} | ||
| */ | ||
| export function getOs() { | ||
| return parseOs(process.platform); | ||
|
|
@@ -1604,13 +1610,17 @@ export function getKernel() { | |
| } | ||
|
|
||
| /** | ||
| * @returns {"musl" | "gnu" | undefined} | ||
| * @returns {"musl" | "gnu" | "android" | undefined} | ||
| */ | ||
| export function getAbi() { | ||
| if (!isLinux) { | ||
| return; | ||
| } | ||
|
|
||
| if (isAndroid || existsSync("/system/bin/linker64")) { | ||
| return "android"; | ||
| } | ||
|
|
||
| if (existsSync("/etc/alpine-release")) { | ||
| return "musl"; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.