@@ -182,6 +182,125 @@ fn doc_no_deps() {
182182 assert ! ( !p. root( ) . join( "target/doc/bar/index.html" ) . is_file( ) ) ;
183183}
184184
185+ #[ cargo_test]
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]
246+ fn doc_no_deps_rustdoc_mergeable_info ( ) {
247+ let p = project ( )
248+ . file (
249+ "Cargo.toml" ,
250+ r#"
251+ [package]
252+ name = "foo"
253+ version = "0.0.1"
254+ edition = "2015"
255+ authors = []
256+
257+ [dependencies.bar]
258+ path = "bar"
259+ "# ,
260+ )
261+ . file ( "src/lib.rs" , "extern crate bar; pub fn foo() {}" )
262+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.0.1" ) )
263+ . file ( "bar/src/lib.rs" , "pub fn bar() {}" )
264+ . build ( ) ;
265+
266+ p. cargo ( "doc --no-deps -Zunstable-options -Zrustdoc-mergeable-info" )
267+ . masquerade_as_nightly_cargo ( & [ "rustdoc-mergeable-info" ] )
268+ . with_stderr_data (
269+ str![ [ r#"
270+ [LOCKING] 1 package to latest compatible version
271+ [CHECKING] bar v0.0.1 ([ROOT]/foo/bar)
272+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
273+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
274+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
275+
276+ "# ] ]
277+ . unordered ( ) ,
278+ )
279+ . run ( ) ;
280+
281+ assert ! ( p. root( ) . join( "target/doc" ) . is_dir( ) ) ;
282+ assert ! ( p. root( ) . join( "target/doc/foo/index.html" ) . is_file( ) ) ;
283+ assert ! ( !p. root( ) . join( "target/doc/bar/index.html" ) . is_file( ) ) ;
284+
285+ // Verify that it only emits rmeta for the dependency.
286+ assert_eq ! ( p. glob( "target/debug/**/*.rlib" ) . count( ) , 0 ) ;
287+ assert_eq ! ( p. glob( "target/debug/deps/libbar-*.rmeta" ) . count( ) , 1 ) ;
288+
289+ // Make sure it doesn't recompile.
290+ p. cargo ( "doc --no-deps -Zunstable-options -Zrustdoc-mergeable-info" )
291+ . masquerade_as_nightly_cargo ( & [ "rustdoc-mergeable-info" ] )
292+ . with_stderr_data ( str![ [ r#"
293+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
294+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
295+
296+ "# ] ] )
297+ . run ( ) ;
298+
299+ assert ! ( p. root( ) . join( "target/doc" ) . is_dir( ) ) ;
300+ assert ! ( p. root( ) . join( "target/doc/foo/index.html" ) . is_file( ) ) ;
301+ assert ! ( !p. root( ) . join( "target/doc/bar/index.html" ) . is_file( ) ) ;
302+ }
303+
185304#[ cargo_test]
186305fn doc_only_bin ( ) {
187306 let p = project ( )
0 commit comments