Skip to content

Commit 5bc05b4

Browse files
committed
Add tests
1 parent 5d302e5 commit 5bc05b4

File tree

5 files changed

+52
-19
lines changed

5 files changed

+52
-19
lines changed

tests/testsuite/build_script.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ fn testing_and_such() {
813813
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
814814
[RUNNING] `[..]/foo-[..][EXE]`
815815
[DOCTEST] foo
816-
[RUNNING] `rustdoc --test [..]`",
816+
[RUNNING] `rustdoc [..]--test [..]`",
817817
)
818818
.with_stdout_contains_n("running 0 tests", 2)
819819
.run();
@@ -2747,7 +2747,7 @@ fn doctest_receives_build_link_args() {
27472747

27482748
p.cargo("test -v")
27492749
.with_stderr_contains(
2750-
"[RUNNING] `rustdoc --test [..] --crate-name foo [..]-L native=bar[..]`",
2750+
"[RUNNING] `rustdoc [..]--test [..] --crate-name foo [..]-L native=bar[..]`",
27512751
)
27522752
.run();
27532753
}

tests/testsuite/profile_targets.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fn profile_selection_test() {
306306
[RUNNING] `[..]/deps/foo-[..]`
307307
[RUNNING] `[..]/deps/test1-[..]`
308308
[DOCTEST] foo
309-
[RUNNING] `rustdoc --test [..]
309+
[RUNNING] `rustdoc [..]--test [..]
310310
").run();
311311
p.cargo("test -vv")
312312
.with_stderr_unordered(
@@ -319,7 +319,7 @@ fn profile_selection_test() {
319319
[RUNNING] `[..]/deps/foo-[..]`
320320
[RUNNING] `[..]/deps/test1-[..]`
321321
[DOCTEST] foo
322-
[RUNNING] `rustdoc --test [..]
322+
[RUNNING] `rustdoc [..]--test [..]
323323
",
324324
)
325325
.run();
@@ -371,7 +371,7 @@ fn profile_selection_test_release() {
371371
[RUNNING] `[..]/deps/foo-[..]`
372372
[RUNNING] `[..]/deps/test1-[..]`
373373
[DOCTEST] foo
374-
[RUNNING] `rustdoc --test [..]`
374+
[RUNNING] `rustdoc [..]--test [..]`
375375
").run();
376376
p.cargo("test --release -vv")
377377
.with_stderr_unordered(
@@ -384,7 +384,7 @@ fn profile_selection_test_release() {
384384
[RUNNING] `[..]/deps/foo-[..]`
385385
[RUNNING] `[..]/deps/test1-[..]`
386386
[DOCTEST] foo
387-
[RUNNING] `rustdoc --test [..]
387+
[RUNNING] `rustdoc [..]--test [..]
388388
",
389389
)
390390
.run();
@@ -633,7 +633,7 @@ fn profile_selection_doc() {
633633
[COMPILING] bar [..]
634634
[DOCUMENTING] bar [..]
635635
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=1 -C debuginfo=2 [..]
636-
[RUNNING] `rustdoc --crate-name bar bar/src/lib.rs [..]
636+
[RUNNING] `rustdoc [..]--crate-name bar bar/src/lib.rs [..]
637637
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]
638638
[COMPILING] bdep [..]
639639
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=1 -C debuginfo=2 [..]
@@ -642,7 +642,7 @@ fn profile_selection_doc() {
642642
[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
643643
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
644644
[DOCUMENTING] foo [..]
645-
[RUNNING] `rustdoc --crate-name foo src/lib.rs [..]
645+
[RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]
646646
[FINISHED] dev [unoptimized + debuginfo] [..]
647647
").run();
648648
}

tests/testsuite/rename_deps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ fn can_run_doc_tests() {
263263
.with_stderr_contains(
264264
"\
265265
[DOCTEST] foo
266-
[RUNNING] `rustdoc --test [CWD]/src/lib.rs \
266+
[RUNNING] `rustdoc [..]--test [CWD]/src/lib.rs \
267267
[..] \
268268
--extern bar=[CWD]/target/debug/deps/libbar-[..].rlib \
269269
--extern baz=[CWD]/target/debug/deps/libbar-[..].rlib \

tests/testsuite/rustdoc.rs

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::support::{basic_manifest, project};
1+
use crate::support::{basic_manifest, is_nightly, project};
22

33
#[cargo_test]
44
fn rustdoc_simple() {
@@ -8,7 +8,7 @@ fn rustdoc_simple() {
88
.with_stderr(
99
"\
1010
[DOCUMENTING] foo v0.0.1 ([CWD])
11-
[RUNNING] `rustdoc --crate-name foo src/lib.rs [..]\
11+
[RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
1212
-o [CWD]/target/doc \
1313
[..] \
1414
-L dependency=[CWD]/target/debug/deps`
@@ -26,7 +26,7 @@ fn rustdoc_args() {
2626
.with_stderr(
2727
"\
2828
[DOCUMENTING] foo v0.0.1 ([CWD])
29-
[RUNNING] `rustdoc --crate-name foo src/lib.rs [..]\
29+
[RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
3030
-o [CWD]/target/doc \
3131
[..] \
3232
--cfg=foo \
@@ -66,7 +66,7 @@ fn rustdoc_foo_with_bar_dependency() {
6666
[CHECKING] bar v0.0.1 ([..])
6767
[RUNNING] `rustc [..]bar/src/lib.rs [..]`
6868
[DOCUMENTING] foo v0.0.1 ([CWD])
69-
[RUNNING] `rustdoc --crate-name foo src/lib.rs [..]\
69+
[RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
7070
-o [CWD]/target/doc \
7171
[..] \
7272
--cfg=foo \
@@ -105,7 +105,7 @@ fn rustdoc_only_bar_dependency() {
105105
.with_stderr(
106106
"\
107107
[DOCUMENTING] bar v0.0.1 ([..])
108-
[RUNNING] `rustdoc --crate-name bar [..]bar/src/lib.rs [..]\
108+
[RUNNING] `rustdoc [..]--crate-name bar [..]bar/src/lib.rs [..]\
109109
-o [CWD]/target/doc \
110110
[..] \
111111
--cfg=foo \
@@ -127,7 +127,7 @@ fn rustdoc_same_name_documents_lib() {
127127
.with_stderr(
128128
"\
129129
[DOCUMENTING] foo v0.0.1 ([..])
130-
[RUNNING] `rustdoc --crate-name foo src/lib.rs [..]\
130+
[RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
131131
-o [CWD]/target/doc \
132132
[..] \
133133
--cfg=foo \
@@ -161,6 +161,39 @@ fn features() {
161161
.run();
162162
}
163163

164+
#[cargo_test]
165+
fn proc_macro_crate_type() {
166+
// NOTE - Remove this once 'rustdoc --crate-type'
167+
// rides to stable
168+
if !is_nightly() {
169+
return;
170+
}
171+
let p = project()
172+
.file(
173+
"Cargo.toml",
174+
r#"
175+
[package]
176+
name = "foo"
177+
version = "0.0.1"
178+
authors = []
179+
180+
[lib]
181+
proc-macro = true
182+
183+
"#,
184+
)
185+
.file("src/lib.rs", "")
186+
.build();
187+
188+
p.cargo("rustdoc --verbose")
189+
.with_stderr_contains(
190+
"\
191+
[RUNNING] `rustdoc --crate-type proc-macro [..]`
192+
",
193+
)
194+
.run();
195+
}
196+
164197
#[cargo_test]
165198
#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
166199
fn rustdoc_target() {
@@ -170,7 +203,7 @@ fn rustdoc_target() {
170203
.with_stderr(
171204
"\
172205
[DOCUMENTING] foo v0.0.1 ([..])
173-
[RUNNING] `rustdoc --crate-name foo src/lib.rs [..]\
206+
[RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
174207
--target x86_64-unknown-linux-gnu \
175208
-o [CWD]/target/x86_64-unknown-linux-gnu/doc \
176209
[..] \

tests/testsuite/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn cargo_test_release() {
9797
[RUNNING] `[..]target/release/deps/foo-[..][EXE]`
9898
[RUNNING] `[..]target/release/deps/test-[..][EXE]`
9999
[DOCTEST] foo
100-
[RUNNING] `rustdoc --test [..]lib.rs[..]`",
100+
[RUNNING] `rustdoc [..]--test [..]lib.rs[..]`",
101101
)
102102
.with_stdout_contains_n("test test ... ok", 2)
103103
.with_stdout_contains("running 0 tests")
@@ -2702,15 +2702,15 @@ fn pass_correct_cfgs_flags_to_rustdoc() {
27022702
.with_stderr_contains(
27032703
"\
27042704
[DOCTEST] feature_a
2705-
[RUNNING] `rustdoc --test [..]mock_serde_codegen[..]`",
2705+
[RUNNING] `rustdoc [..]--test [..]mock_serde_codegen[..]`",
27062706
)
27072707
.run();
27082708

27092709
p.cargo("test --verbose")
27102710
.with_stderr_contains(
27112711
"\
27122712
[DOCTEST] foo
2713-
[RUNNING] `rustdoc --test [..]feature_a[..]`",
2713+
[RUNNING] `rustdoc [..]--test [..]feature_a[..]`",
27142714
)
27152715
.run();
27162716
}

0 commit comments

Comments
 (0)