]> git.proxmox.com Git - cargo.git/commitdiff
Add test with cargo configuration file
authorChris Field <chris@fieldrndservices.com>
Mon, 22 Feb 2021 00:58:19 +0000 (19:58 -0500)
committerChris Field <chris@fieldrndservices.com>
Mon, 22 Feb 2021 00:58:19 +0000 (19:58 -0500)
A `.cargo/config.toml` file is used to add the "crt-static" target
feature and test printing the compiler target configuration contains the
`target_feature="crt-static"` line.

tests/testsuite/rustc.rs

index 1a2bd9e8b1abe11c9aae11b4531d9f901012ca03..5eddb3c89d164c31517051a062cac5b2083a94df 100644 (file)
@@ -619,3 +619,53 @@ windows
         )
         .run();
 }
+
+#[cargo_test]
+fn rustc_with_print_cfg_config_toml() {
+    let p = project()
+        .file("Cargo.toml", &basic_bin_manifest("foo"))
+        .file(".cargo/config.toml", r#"
+[target.x86_64-pc-windows-msvc]
+rustflags = ["-C", "target-feature=+crt-static"]
+"#)
+        .file("src/main.rs", r#"fn main() {} "#)
+        .build();
+
+    p.cargo("rustc -Z unstable-options --target x86_64-pc-windows-msvc --print cfg")
+     .masquerade_as_nightly_cargo()
+        .env("RUSTFLAGS", "-C target-feature=+crt-static")
+        .with_stdout_contains(
+            "\
+debug_assertions
+target_arch=\"x86_64\"
+target_endian=\"little\"
+target_env=\"msvc\"
+target_family=\"windows\"
+target_feature=\"crt-static\"
+target_feature=\"fxsr\"
+target_feature=\"sse\"
+target_feature=\"sse2\"
+target_has_atomic=\"16\"
+target_has_atomic=\"32\"
+target_has_atomic=\"64\"
+target_has_atomic=\"8\"
+target_has_atomic=\"ptr\"
+target_has_atomic_equal_alignment=\"16\"
+target_has_atomic_equal_alignment=\"32\"
+target_has_atomic_equal_alignment=\"64\"
+target_has_atomic_equal_alignment=\"8\"
+target_has_atomic_equal_alignment=\"ptr\"
+target_has_atomic_load_store=\"16\"
+target_has_atomic_load_store=\"32\"
+target_has_atomic_load_store=\"64\"
+target_has_atomic_load_store=\"8\"
+target_has_atomic_load_store=\"ptr\"
+target_os=\"windows\"
+target_pointer_width=\"64\"
+target_thread_local
+target_vendor=\"pc\"
+windows
+",
+        )
+        .run();
+}