Skip to content
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

GitHub Actions: npm test is failing Windows tests on M1 Macs #3011

Merged
merged 3 commits into from Apr 11, 2024

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Apr 5, 2024

Why are Windows tests running on Macs?

Fixes #2993

npm test is running and failing Windows find-visualstudio tests on an M1 Mac!!!

These tests are either not being run or are not failing on Intel Macs.

GitHub Actions blog:

Over the next 12 weeks, jobs using the macos-latest runner label will migrate from macOS 12 (Monterey) to macOS 14 (Sonoma).

https://github.blog/changelog/2024-04-01-macos-14-sonoma-is-generally-available-and-the-latest-macos-runner-image

Discovered by @GeoffreyPlitt in:

Checklist
  • npm install && npm run lint && npm test passes
  • tests are included
  • documentation is changed or added
  • commit message follows commit guidelines
Description of change

@jarig

`npm test` is running and failing Windows `find-visualstudio` tests on an M1 Mac!!!

These tests are not being run or not failing on Intel Macs.
@GeoffreyPlitt
Copy link

Nice!

@StefanStojanovic
Copy link
Contributor

@cclauss a quick question - Is the goal of this PR to add the failing configuration, or to address the issue on M1 Mac as well?

@cclauss
Copy link
Contributor Author

cclauss commented Apr 8, 2024

The goal of this pull request is to encourage someone to fix Windows-specific npm tests to only run on Windows or to pass on all operating systems. To me, running Windows tests only on Windows makes sense.

This should be done before GitHub Actions migrates all macOS jobs off of Intel and onto ARM.

@StefanStojanovic
Copy link
Contributor

Understood. I made a branch from this one. If skipping VS tests outside Windows is wanted, this commit should be enough.

Feel free to cherry-pick it, or apply an inline patch file

From ddbf1beb7a97645146e621982c09a002f62d90ff Mon Sep 17 00:00:00 2001
From: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Date: Mon, 8 Apr 2024 11:42:20 +0200
Subject: [PATCH 1/1] test: run find visual studio tests only on windows

---
 test/test-find-visualstudio.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/test/test-find-visualstudio.js b/test/test-find-visualstudio.js
index 2c3f4e1..80cd564 100644
--- a/test/test-find-visualstudio.js
+++ b/test/test-find-visualstudio.js
@@ -21,6 +21,11 @@ class TestVisualStudioFinder extends VisualStudioFinder {
   }
 }
 
+// Only run "Find Visual Studio" tests on Windows.
+if  (process.platform !== 'win32') {
+  return
+}
+
 describe('find-visualstudio', function () {
   this.beforeAll(function () {
     // Condition to skip the test suite
-- 
2.44.0.windows.1

@StefanStojanovic
Copy link
Contributor

From d09beefea668bcf98dee60973d0d4aa9d2596d62 Mon Sep 17 00:00:00 2001
From: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Date: Mon, 8 Apr 2024 12:22:53 +0200
Subject: [PATCH 1/1] test: run find visual studio tests only on windows

---
 test/test-find-visualstudio.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/test/test-find-visualstudio.js b/test/test-find-visualstudio.js
index 80cd564..bea0bd9 100644
--- a/test/test-find-visualstudio.js
+++ b/test/test-find-visualstudio.js
@@ -22,11 +22,13 @@ class TestVisualStudioFinder extends VisualStudioFinder {
 }
 
 // Only run "Find Visual Studio" tests on Windows.
-if  (process.platform !== 'win32') {
-  return
-}
+const shouldSkip = process.platform !== 'win32'
 
 describe('find-visualstudio', function () {
+  if (shouldSkip) {
+    return
+  }
+
   this.beforeAll(function () {
     // Condition to skip the test suite
     if (process.env.SystemRoot === undefined) {
-- 
2.44.0.windows.1

This should satisfy the linter.

Co-authored-by: Christian Clauss <cclauss@me.com>
Copy link
Contributor

@StefanStojanovic StefanStojanovic left a comment

Choose a reason for hiding this comment

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

LGTM

@richardlau
Copy link
Member

FWIW, without commenting on whether skipping the test on macOS is the correct thing to do (I trust @StefanStojanovic's judgement here) -- the test failure that was occurring looks to be a mismatch between the test and code:

await verifyVSSetupData('VSSetup_VS_2019_Professional_workload.txt', 'Professional', 2019,
'10.0.19041.0', 'v142', '16.11.34407.143', 'Program Files (x86)')
})

loads test/fixtures/VSSetup_VS_2019_Professional_workload.txt, which contains:
"Id": "Microsoft.VisualStudio.VC.MSBuild.Base",

In lib/find-visualstudio.js, this matches this conditional:

const pkg = 'Microsoft.VisualStudio.VC.MSBuild.Base'
const msbuildPath = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
const msbuildPathArm64 = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'arm64', 'MSBuild.exe')
if (info.packages.indexOf(pkg) !== -1) {
this.log.silly('- found VC.MSBuild.Base')
if (versionYear === 2017) {
return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe')
}
if (versionYear === 2019) {
return msbuildPath
}
}

However the test seems to be adding arm64 to the expected MSBuild path:

const msBuildPath = process.arch === 'arm64'
? `C:\\${expectedProgramFilesPath}\\Microsoft Visual Studio\\${vsYear}\\` +
`${vsType}\\MSBuild\\Current\\Bin\\arm64\\MSBuild.exe`
: `C:\\${expectedProgramFilesPath}\\Microsoft Visual Studio\\${vsYear}\\` +
`${vsType}\\MSBuild\\Current\\Bin\\MSBuild.exe`
which looks like it's meant to match:
/**
* Visual Studio 2022 doesn't have the MSBuild package.
* Support for compiling _on_ ARM64 was added in MSVC 14.32.31326,
* so let's leverage it if the user has an ARM64 device.
*/
if (process.arch === 'arm64' && this.msBuildPathExists(msbuildPathArm64)) {
return msbuildPathArm64
} else if (this.msBuildPathExists(msbuildPath)) {
return msbuildPath
}
but we don't hit that code in the failing test because it returns earlier from the function due to the presences of Microsoft.VisualStudio.VC.MSBuild.Base.

I suspect the test will fail on Windows on ARM64 (which I don't think is being tested in GitHub Actions).

@StefanStojanovic
Copy link
Contributor

I'm not 100% sure, but I also think this is more likely to fail on ARM64 Windows than not. @richardlau thanks for the analysis, we (@huseyinacacak-janea or me) can fix it in a follow-up PR to handle the ARM64 case correctly. Although it is not tested in GH actions, we have access to ARM64 Windows machines where we could develop the change. Once we have it, we can revert b113c39 in order to start testing ARM64 VS detection correctly. Disabling tests now seems like a better approach, as I do not know if we'll get to fixing this before the GitHub Actions migration for macOS.

@cclauss cclauss merged commit 0bab6a0 into main Apr 11, 2024
36 checks passed
@cclauss cclauss deleted the cclauss-patch-1 branch April 11, 2024 15:34
cclauss added a commit to nodejs/gyp-next that referenced this pull request Apr 11, 2024
GitHub Actions blog:
> Over the next 12 weeks, jobs using the `macos-latest` runner label will migrate from macOS 12 (Monterey) to macOS 14 (Sonoma).

https://github.blog/changelog/2024-04-01-macos-14-sonoma-is-generally-available-and-the-latest-macos-runner-image

* nodejs/node-gyp#3011
legendecas pushed a commit to nodejs/gyp-next that referenced this pull request Apr 22, 2024
* GitHub Actions test on macOS on ARM

GitHub Actions blog:
> Over the next 12 weeks, jobs using the `macos-latest` runner label will migrate from macOS 12 (Monterey) to macOS 14 (Sonoma).

https://github.blog/changelog/2024-04-01-macos-14-sonoma-is-generally-available-and-the-latest-macos-runner-image

* nodejs/node-gyp#3011

* exclude: os: macos-14, python-version: [3.8, 3.9]

* Also the node-gyp integration tests
@cclauss
Copy link
Contributor Author

cclauss commented Apr 23, 2024

A huge hats off to @GeoffreyPlitt for

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

Successfully merging this pull request may close these issues.

None yet

4 participants