@@ -182,6 +182,126 @@ fn doc_no_deps() {
182182 assert ! ( !p. root( ) . join( "target/doc/bar/index.html" ) . is_file( ) ) ;
183183}
184184
185+ #[ cargo_test( nightly, reason = "rustdoc mergeable crate info is unstable" ) ]
186+ fn doc_deps_rustdoc_mergeable_info ( ) {
187+ let p = project ( )
188+ . file (
189+ "Cargo.toml" ,
190+ r#"
191+ [package]
192+ name = "foo"
193+ version = "0.0.1"
194+ edition = "2015"
195+ authors = []
196+
197+ [dependencies.bar]
198+ path = "bar"
199+ "# ,
200+ )
201+ . file ( "src/lib.rs" , "extern crate bar; pub fn foo() {}" )
202+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.0.1" ) )
203+ . file ( "bar/src/lib.rs" , "pub fn bar() {}" )
204+ . build ( ) ;
205+
206+ p. cargo ( "doc -Zunstable-options -Zrustdoc-mergeable-info" )
207+ . masquerade_as_nightly_cargo ( & [ "rustdoc-mergeable-info" ] )
208+ . with_stderr_data (
209+ str![ [ r#"
210+ [LOCKING] 1 package to latest compatible version
211+ [DOCUMENTING] bar v0.0.1 ([ROOT]/foo/bar)
212+ [CHECKING] bar v0.0.1 ([ROOT]/foo/bar)
213+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
214+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
215+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
216+
217+ "# ] ]
218+ . unordered ( ) ,
219+ )
220+ . run ( ) ;
221+
222+ assert ! ( p. root( ) . join( "target/doc" ) . is_dir( ) ) ;
223+ assert ! ( p. root( ) . join( "target/doc/foo/index.html" ) . is_file( ) ) ;
224+ assert ! ( p. root( ) . join( "target/doc/bar/index.html" ) . is_file( ) ) ;
225+
226+ // Verify that it only emits rmeta for the dependency.
227+ assert_eq ! ( p. glob( "target/debug/**/*.rlib" ) . count( ) , 0 ) ;
228+ assert_eq ! ( p. glob( "target/debug/deps/libbar-*.rmeta" ) . count( ) , 1 ) ;
229+
230+ // Make sure it doesn't recompile.
231+ p. cargo ( "doc -Zunstable-options -Zrustdoc-mergeable-info" )
232+ . masquerade_as_nightly_cargo ( & [ "rustdoc-mergeable-info" ] )
233+ . with_stderr_data ( str![ [ r#"
234+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
235+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
236+
237+ "# ] ] )
238+ . run ( ) ;
239+
240+ assert ! ( p. root( ) . join( "target/doc" ) . is_dir( ) ) ;
241+ assert ! ( p. root( ) . join( "target/doc/foo/index.html" ) . is_file( ) ) ;
242+ assert ! ( p. root( ) . join( "target/doc/bar/index.html" ) . is_file( ) ) ;
243+ }
244+
245+ #[ cargo_test( nightly, reason = "rustdoc mergeable crate info is unstable" ) ]
246+ = "rustdoc scrape examples flags are unstable" ) ]
247+ fn doc_no_deps_rustdoc_mergeable_info ( ) {
248+ let p = project ( )
249+ . file (
250+ "Cargo.toml" ,
251+ r#"
252+ [package]
253+ name = "foo"
254+ version = "0.0.1"
255+ edition = "2015"
256+ authors = []
257+
258+ [dependencies.bar]
259+ path = "bar"
260+ "# ,
261+ )
262+ . file ( "src/lib.rs" , "extern crate bar; pub fn foo() {}" )
263+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.0.1" ) )
264+ . file ( "bar/src/lib.rs" , "pub fn bar() {}" )
265+ . build ( ) ;
266+
267+ p. cargo ( "doc --no-deps -Zunstable-options -Zrustdoc-mergeable-info" )
268+ . masquerade_as_nightly_cargo ( & [ "rustdoc-mergeable-info" ] )
269+ . with_stderr_data (
270+ str![ [ r#"
271+ [LOCKING] 1 package to latest compatible version
272+ [CHECKING] bar v0.0.1 ([ROOT]/foo/bar)
273+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
274+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
275+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
276+
277+ "# ] ]
278+ . unordered ( ) ,
279+ )
280+ . run ( ) ;
281+
282+ assert ! ( p. root( ) . join( "target/doc" ) . is_dir( ) ) ;
283+ assert ! ( p. root( ) . join( "target/doc/foo/index.html" ) . is_file( ) ) ;
284+ assert ! ( !p. root( ) . join( "target/doc/bar/index.html" ) . is_file( ) ) ;
285+
286+ // Verify that it only emits rmeta for the dependency.
287+ assert_eq ! ( p. glob( "target/debug/**/*.rlib" ) . count( ) , 0 ) ;
288+ assert_eq ! ( p. glob( "target/debug/deps/libbar-*.rmeta" ) . count( ) , 1 ) ;
289+
290+ // Make sure it doesn't recompile.
291+ p. cargo ( "doc --no-deps -Zunstable-options -Zrustdoc-mergeable-info" )
292+ . masquerade_as_nightly_cargo ( & [ "rustdoc-mergeable-info" ] )
293+ . with_stderr_data ( str![ [ r#"
294+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
295+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
296+
297+ "# ] ] )
298+ . run ( ) ;
299+
300+ assert ! ( p. root( ) . join( "target/doc" ) . is_dir( ) ) ;
301+ assert ! ( p. root( ) . join( "target/doc/foo/index.html" ) . is_file( ) ) ;
302+ assert ! ( !p. root( ) . join( "target/doc/bar/index.html" ) . is_file( ) ) ;
303+ }
304+
185305#[ cargo_test]
186306fn doc_only_bin ( ) {
187307 let p = project ( )
0 commit comments