Skip to content

Commit

Permalink
Fix multi arch test compilation
Browse files Browse the repository at this point in the history
From: https://github.com/heroku/buildpacks-ruby/pull/284/files#r1603946649. The tests currently fail locally on a Mac (arm64/aarch64) because tests are always being compiled for amd64/x86. This change is a workaround to force compilation to the current target architecture.
  • Loading branch information
schneems committed May 17, 2024
1 parent aa74c14 commit a392d20
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion buildpacks/ruby/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ fn test_default_app_ubuntu22() {
#[test]
#[ignore = "integration test"]
fn test_default_app_latest_distro() {
let config = amd_arm_builder_config("heroku/builder:24", "tests/fixtures/default_ruby");

TestRunner::default().build(
BuildConfig::new("heroku/builder:24", "tests/fixtures/default_ruby"),
config,
|context| {
println!("{}", context.pack_stdout);
assert_contains!(context.pack_stdout, "# Heroku Ruby Buildpack");
Expand Down Expand Up @@ -279,3 +281,17 @@ fn frac_seconds(seconds: f64) -> Duration {
}

const TEST_PORT: u16 = 1234;

// TODO: Once Pack build supports `--platform` and libcnb-test adjusted accordingly, change this
// to allow configuring the target arch independently of the builder name (eg via env var).
fn amd_arm_builder_config(builder_name: &str, app_dir: &str) -> BuildConfig {
let mut builder = BuildConfig::new(builder_name, app_dir);

match builder_name {
"heroku/builder:24" if cfg!(target_arch = "aarch64") => {
builder.target_triple("aarch64-unknown-linux-musl")
}
_ => builder.target_triple("x86_64-unknown-linux-musl"),
};
builder
}

0 comments on commit a392d20

Please sign in to comment.