Skip to content

Commit e2a6eef

Browse files
committed
Expand test for GCC Apple -arch and version flag
1 parent bfdf3d5 commit e2a6eef

File tree

1 file changed

+77
-8
lines changed

1 file changed

+77
-8
lines changed

tests/test.rs

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,28 +524,97 @@ fn asm_flags() {
524524
}
525525

526526
#[test]
527-
fn gnu_apple_darwin() {
528-
for (arch, ld64_arch, version) in &[("x86_64", "x86_64", "10.7"), ("aarch64", "arm64", "11.0")]
529-
{
530-
let target = format!("{}-apple-darwin", arch);
527+
fn gnu_apple_sysroot() {
528+
let targets = ["aarch64-apple-darwin", "x86_64-apple-darwin"];
529+
530+
for target in targets {
531531
let test = Test::gnu();
532532
test.shim("fake-gcc")
533533
.gcc()
534534
.compiler("fake-gcc")
535535
.target(&target)
536536
.host(&target)
537-
// Avoid test maintenance when minimum supported OSes change.
538-
.__set_env("MACOSX_DEPLOYMENT_TARGET", version)
539537
.file("foo.c")
540538
.compile("foo");
541539

542540
let cmd = test.cmd(0);
543-
cmd.must_have_in_order("-arch", ld64_arch);
544-
cmd.must_have(format!("-mmacosx-version-min={version}"));
545541
cmd.must_not_have("-isysroot");
546542
}
547543
}
548544

545+
#[test]
546+
fn gnu_apple_arch() {
547+
let cases = [
548+
("x86_64-apple-darwin", "x86_64"),
549+
("x86_64h-apple-darwin", "x86_64h"),
550+
("aarch64-apple-darwin", "arm64"),
551+
("arm64e-apple-darwin", "arm64e"),
552+
("i686-apple-darwin", "i386"),
553+
("aarch64-apple-ios", "arm64"),
554+
("armv7s-apple-ios", "armv7s"),
555+
("arm64_32-apple-watchos", "arm64_32"),
556+
("armv7k-apple-watchos", "armv7k"),
557+
];
558+
559+
for (target, arch) in cases {
560+
let test = Test::gnu();
561+
test.shim("fake-gcc")
562+
.gcc()
563+
.compiler("fake-gcc")
564+
.target(&target)
565+
.host(&"aarch64-apple-darwin")
566+
.file("foo.c")
567+
.compile("foo");
568+
569+
let cmd = test.cmd(0);
570+
cmd.must_have_in_order("-arch", arch);
571+
}
572+
}
573+
574+
#[test]
575+
fn gnu_apple_deployment_target() {
576+
let cases = [
577+
("x86_64-apple-darwin", "-mmacosx-version-min=10.12"),
578+
("aarch64-apple-darwin", "-mmacosx-version-min=10.12"),
579+
("aarch64-apple-ios", "-miphoneos-version-min=10.0"),
580+
("aarch64-apple-ios-sim", "-mios-simulator-version-min=10.0"),
581+
("x86_64-apple-ios", "-mios-simulator-version-min=10.0"),
582+
("aarch64-apple-ios-macabi", "-mtargetos=ios10.0-macabi"),
583+
("aarch64-apple-tvos", "-mappletvos-version-min=10.0"),
584+
(
585+
"aarch64-apple-tvos-sim",
586+
"-mappletvsimulator-version-min=10.0",
587+
),
588+
("aarch64-apple-watchos", "-mwatchos-version-min=5.0"),
589+
(
590+
"aarch64-apple-watchos-sim",
591+
"-mwatchsimulator-version-min=5.0",
592+
),
593+
("aarch64-apple-visionos", "-mtargetos=xros1.0"),
594+
("aarch64-apple-visionos-sim", "-mtargetos=xros1.0-simulator"),
595+
];
596+
597+
for (target, os_version_flag) in cases {
598+
let test = Test::gnu();
599+
test.shim("fake-gcc")
600+
.gcc()
601+
.compiler("fake-gcc")
602+
.target(&target)
603+
.host(&"aarch64-apple-darwin")
604+
// Avoid dependency on environment in test.
605+
.__set_env("MACOSX_DEPLOYMENT_TARGET", "10.12")
606+
.__set_env("IPHONEOS_DEPLOYMENT_TARGET", "10.0")
607+
.__set_env("TVOS_DEPLOYMENT_TARGET", "10.0")
608+
.__set_env("WATCHOS_DEPLOYMENT_TARGET", "5.0")
609+
.__set_env("XROS_DEPLOYMENT_TARGET", "1.0")
610+
.file("foo.c")
611+
.compile("foo");
612+
613+
let cmd = test.cmd(0);
614+
cmd.must_have(os_version_flag);
615+
}
616+
}
617+
549618
#[cfg(target_os = "macos")]
550619
#[test]
551620
fn macos_cpp_minimums() {

0 commit comments

Comments
 (0)