Skip to content

Commit 1f4585a

Browse files
chriskrychorwjblue
andcommitted
Correctly (locally) test Node architecture fallback
Previously, since we were testing against a version spec of `1.2.3`, we were failing on local Apple Silicon builds because our test expectations looked for the correct (`arm64`) string, but the version check we use to avoid incorrectly trying to install non-Apple Silicon-compatible Node versions without Rosetta meant we ended up in the fallback path. Update the existing tests to use versions which will get `arm64` when run on an Apple Silicon machine, and add additional tests behind a `#[cfg(...)]` check for `macos-aarch64` to confirm the fallback works correctly. Note that these new tests will *only* run locally at present, since we do not yet have Apple Silicon runners on GitHub, but if/when we can add those, they will run automatically there. This path should also become less important over time as more and more of the mac ecosystem moves to Apple Silicon, but is valuable for as long as we support Intel Macs. Co-authored-by: Rob Jackson <[email protected]>
1 parent 370f7a0 commit 1f4585a

File tree

1 file changed

+27
-3
lines changed
  • crates/volta-core/src/tool/node

1 file changed

+27
-3
lines changed

crates/volta-core/src/tool/node/mod.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,18 +259,42 @@ mod tests {
259259
#[test]
260260
fn test_node_archive_basename() {
261261
assert_eq!(
262-
Node::archive_basename(&Version::parse("1.2.3").unwrap()),
263-
format!("node-v1.2.3-{}-{}", NODE_DISTRO_OS, NODE_DISTRO_ARCH)
262+
Node::archive_basename(&Version::parse("16.2.3").unwrap()),
263+
format!("node-v16.2.3-{}-{}", NODE_DISTRO_OS, NODE_DISTRO_ARCH)
264264
);
265265
}
266266

267267
#[test]
268268
fn test_node_archive_filename() {
269+
assert_eq!(
270+
Node::archive_filename(&Version::parse("16.2.3").unwrap()),
271+
format!(
272+
"node-v16.2.3-{}-{}.{}",
273+
NODE_DISTRO_OS, NODE_DISTRO_ARCH, NODE_DISTRO_EXTENSION
274+
)
275+
);
276+
}
277+
278+
#[test]
279+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
280+
fn test_fallback_node_archive_basename() {
281+
assert_eq!(
282+
Node::archive_basename(&Version::parse("1.2.3").unwrap()),
283+
format!(
284+
"node-v1.2.3-{}-{}",
285+
NODE_DISTRO_OS, NODE_DISTRO_ARCH_FALLBACK
286+
)
287+
);
288+
}
289+
290+
#[test]
291+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
292+
fn test_fallback_node_archive_filename() {
269293
assert_eq!(
270294
Node::archive_filename(&Version::parse("1.2.3").unwrap()),
271295
format!(
272296
"node-v1.2.3-{}-{}.{}",
273-
NODE_DISTRO_OS, NODE_DISTRO_ARCH, NODE_DISTRO_EXTENSION
297+
NODE_DISTRO_OS, NODE_DISTRO_ARCH_FALLBACK, NODE_DISTRO_EXTENSION
274298
)
275299
);
276300
}

0 commit comments

Comments
 (0)