Support `--target` argument in `cargo rustdoc`
authorAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 28 May 2018 14:27:52 +0000 (17:27 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 28 May 2018 14:27:52 +0000 (17:27 +0300)
src/bin/cargo/commands/rustdoc.rs
tests/testsuite/rustdoc.rs

index 194eaaef82a30eb21603d2940053c293ccd59230..9dda84f2e73cb7a1fc4ef564b5e6b87d2dc26508 100644 (file)
@@ -27,6 +27,7 @@ pub fn cli() -> App {
         )
         .arg_release("Build artifacts in release mode, with optimizations")
         .arg_features()
+        .arg_target_triple("Build for the target triple")
         .arg_target_dir()
         .arg_manifest_path()
         .arg_message_format()
index d18df7687ce1a8f80e4911b86b8068e5b65361dd..75a808359779ad03a64869dae567294008856378 100644 (file)
@@ -251,3 +251,32 @@ fn features() {
             .with_stderr_contains("[..]feature=[..]quux[..]"),
     );
 }
+
+#[test]
+#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
+fn rustdoc_target() {
+    let p = project("foo")
+        .file(
+            "Cargo.toml",
+            r#"
+            [package]
+            name = "a"
+            version = "0.0.1"
+            authors = []
+        "#,
+        )
+        .file("src/lib.rs", "")
+        .build();
+
+    assert_that(
+        p.cargo("rustdoc --verbose --target x86_64-unknown-linux-gnu"),
+        execs().with_status(0).with_stderr("\
+[DOCUMENTING] a v0.0.1 ([..])
+[RUNNING] `rustdoc --crate-name a src[/]lib.rs \
+    --target x86_64-unknown-linux-gnu \
+    -o [..]foo[/]target[/]x86_64-unknown-linux-gnu[/]doc \
+    -L dependency=[..]foo[/]target[/]x86_64-unknown-linux-gnu[/]debug[/]deps \
+    -L dependency=[..]foo[/]target[/]debug[/]deps`
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]"),
+    );
+}