Skip to content

fix(os): return 'arm64' from os.machine() on Windows ARM64 (fix #62232)#62235

Closed
zakiscoding wants to merge 2 commits intonodejs:mainfrom
zakiscoding:fix/issue-62232-os-machine-arm64
Closed

fix(os): return 'arm64' from os.machine() on Windows ARM64 (fix #62232)#62235
zakiscoding wants to merge 2 commits intonodejs:mainfrom
zakiscoding:fix/issue-62232-os-machine-arm64

Conversation

@zakiscoding
Copy link

Fixes #62232

On Windows ARM64, \os.machine()\ was returning 'unknown' instead of 'arm64'.

The issue is that libuv's \uv_os_uname()\ doesn't properly detect ARM64 on Windows. This fix adds Windows-specific code to use the Windows API (\GetSystemInfo) to detect ARM64 processor architecture when \os.machine()\ would otherwise return 'unknown'.

The fix maps Windows processor architecture code 12 (PROCESSOR_ARCHITECTURE_ARM64) to the 'arm64' machine string, matching the behavior on other platforms like macOS where ARM64 Macs correctly return 'arm64' from \os.machine().

Fixes: nodejs#60884
Refs: nodejs#52655

When running tests with both the dot reporter and coverage reports,
if a coverage report fails (e.g., line coverage threshold not met),
there was no visible output indicating the failure. The process would
exit with a failure code, but only dots would be printed with no
explanation.

This commit adds collection and display of coverage threshold failure
diagnostics in the dot reporter. When coverage threshold checks fail,
error diagnostic messages are now displayed at the end of the test
output, similar to how failed tests are displayed.

The coverage error messages are collected from test:diagnostic events
with level='error' that are emitted by the test runner when coverage
thresholds are not met.
Copilot AI review requested due to automatic review settings March 12, 2026 19:25
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. os Issues and PRs related to the os subsystem. test_runner Issues and PRs related to the test runner subsystem. labels Mar 12, 2026
@zakiscoding zakiscoding force-pushed the fix/issue-62232-os-machine-arm64 branch from 0f647e4 to 5e8dfc3 Compare March 12, 2026 19:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes os.machine() reporting on Windows ARM64 by overriding libuv’s "unknown" machine value, and additionally updates the dot test reporter to surface diagnostic errors.

Changes:

  • Add Windows-specific ARM64 detection in src/node_os.cc to return "arm64" when libuv reports "unknown".
  • Update the dot reporter to collect and print test:diagnostic events with level: 'error' at the end of the run.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/node_os.cc Detect Windows ARM64 via GetSystemInfo() when uv_os_uname() reports machine === "unknown".
lib/internal/test_runner/reporter/dot.js Collect error-level diagnostics and print them after the main dot output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +100 to +103

// Map Windows processor architecture to machine designations
// PROCESSOR_ARCHITECTURE_ARM64 = 12
if (sys_info.wProcessorArchitecture == 12) {
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using the raw numeric value 12 for the Windows processor architecture. Prefer PROCESSOR_ARCHITECTURE_ARM64 when available, and (if necessary for older SDKs) add a small fallback #ifndef PROCESSOR_ARCHITECTURE_ARM64 definition so the intent is explicit and the code is easier to maintain.

Suggested change
// Map Windows processor architecture to machine designations
// PROCESSOR_ARCHITECTURE_ARM64 = 12
if (sys_info.wProcessorArchitecture == 12) {
// Map Windows processor architecture to machine designations.
// Prefer the SDK constant when available; fall back to the known value
// for older SDKs that may not define PROCESSOR_ARCHITECTURE_ARM64.
#ifndef PROCESSOR_ARCHITECTURE_ARM64
# define PROCESSOR_ARCHITECTURE_ARM64 12
#endif
if (sys_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64) {

Copilot uses AI. Check for mistakes.
if (strcmp(info.machine, "unknown") == 0) {
SYSTEM_INFO sys_info;
GetSystemInfo(&sys_info);

Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace on this blank line; please remove it to keep diffs clean and avoid lint/style checks failing on whitespace-only changes.

Suggested change

Copilot uses AI. Check for mistakes.
// Map Windows processor architecture to machine designations
// PROCESSOR_ARCHITECTURE_ARM64 = 12
if (sys_info.wProcessorArchitecture == 12) {
snprintf(info.machine, sizeof(info.machine), "arm64");
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes os.machine() for Windows ARM64, but there is no regression test guarding against returning "unknown" on that platform. Consider adding a conditional test that asserts os.machine() === 'arm64' when running on Windows ARM64 (e.g., common.isWindows && process.arch === 'arm64').

Copilot uses AI. Check for mistakes.
Comment on lines 12 to 14
const failedTests = [];
const coverageErrors = [];
for await (const { type, data } of source) {
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description is about fixing os.machine() on Windows ARM64, but this change modifies the test runner dot reporter output. If this is intentional, the PR description (or PR scope) should be updated; otherwise this looks like an unrelated change that should be moved to a separate PR.

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +25
if (type === 'test:diagnostic' && data.level === 'error') {
// Collect coverage errors (coverage threshold failures)
ArrayPrototypePush(coverageErrors, data.message);
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coverageErrors collects all test:diagnostic events with data.level === 'error', but the output label hard-codes "Coverage errors". Either filter specifically for coverage-threshold diagnostics (e.g., by message pattern), or rename the variable/heading to something accurate like "Diagnostic errors".

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +46
yield `\n${colors.red}Coverage errors:${colors.white}\n\n`;
for (const error of coverageErrors) {
yield `${colors.red}${error}${colors.white}\n`;
}
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces new observable output for the dot reporter (printing diagnostic errors at the end), but there is no test/snapshot coverage for the new behavior. Please add a test that runs --test-reporter=dot with failing coverage thresholds and asserts the emitted diagnostics are included in the output.

Copilot uses AI. Check for mistakes.
// This test will pass on all Windows systems. The fix ensures that on ARM64 systems,
// os.machine() no longer returns 'unknown', but instead returns 'arm64'
assert.ok(machine.length > 0);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this test matches the intent in the comments

Copy link
Member

@Renegade334 Renegade334 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 9.09091% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.66%. Comparing base (66a687f) to head (5e8dfc3).

Files with missing lines Patch % Lines
lib/internal/test_runner/reporter/dot.js 9.09% 9 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #62235   +/-   ##
=======================================
  Coverage   89.66%   89.66%           
=======================================
  Files         676      676           
  Lines      206462   206473   +11     
  Branches    39533    39537    +4     
=======================================
+ Hits       185128   185139   +11     
- Misses      13461    13462    +1     
+ Partials     7873     7872    -1     
Files with missing lines Coverage Δ
src/node_os.cc 79.71% <ø> (+0.35%) ⬆️
lib/internal/test_runner/reporter/dot.js 80.39% <9.09%> (-19.61%) ⬇️

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zakiscoding
Copy link
Author

Closing this as superseded by #61829 per maintainer guidance. Thanks all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. os Issues and PRs related to the os subsystem. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On Windows arm64 os.machine() returns unknown

5 participants