]> git.proxmox.com Git - cargo.git/commitdiff
Add a test that uses a custom binary target
authorPhilipp Oppermann <dev@phil-opp.com>
Mon, 16 Sep 2019 07:31:20 +0000 (09:31 +0200)
committerPhilipp Oppermann <dev@phil-opp.com>
Mon, 16 Sep 2019 07:31:20 +0000 (09:31 +0200)
The custom target name contains the crate type `bin`.

tests/testsuite/custom_target.rs

index 8c57e3da9ca16a66c86f8923ffc04bc3e56f1ab1..adcec16bb13284b371803dcdcb6b74d7a4f41645 100644 (file)
@@ -130,3 +130,50 @@ fn custom_target_dependency() {
 
     p.cargo("build --lib --target custom-target.json -v").run();
 }
+
+#[cargo_test]
+fn custom_bin_target() {
+    if !is_nightly() {
+        // Requires features no_core, lang_items
+        return;
+    }
+    let p = project()
+        .file(
+            "src/main.rs",
+            r#"
+            #![feature(no_core)]
+            #![feature(lang_items)]
+            #![no_core]
+            #![no_main]
+
+            #[lang = "sized"]
+            pub trait Sized {
+                // Empty.
+            }
+            #[lang = "copy"]
+            pub trait Copy {
+                // Empty.
+            }
+        "#,
+        )
+        .file(
+            "custom-bin-target.json",
+            r#"
+            {
+                "llvm-target": "x86_64-unknown-none-gnu",
+                "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
+                "arch": "x86_64",
+                "target-endian": "little",
+                "target-pointer-width": "64",
+                "target-c-int-width": "32",
+                "os": "none",
+                "linker-flavor": "ld.lld",
+                "linker": "rust-lld",
+                "executables": true
+            }
+        "#,
+        )
+        .build();
+
+    p.cargo("build --target custom-bin-target.json -v").run();
+}