@@ -2914,3 +2914,268 @@ See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more inform
2914
2914
"# ] ] )
2915
2915
. run ( ) ;
2916
2916
}
2917
+
2918
+ #[ cargo_test( nightly, reason = "`rustdoc --emit` is unstable" ) ]
2919
+ fn rebuild_tracks_target_src_outside_package_root ( ) {
2920
+ let p = cargo_test_support:: project_in ( "parent" )
2921
+ . file (
2922
+ "Cargo.toml" ,
2923
+ r#"
2924
+ [package]
2925
+ name = "foo"
2926
+ edition = "2015"
2927
+ [lib]
2928
+ path = "../lib.rs"
2929
+ "# ,
2930
+ )
2931
+ . file ( "../lib.rs" , "//! # depinfo-before" )
2932
+ . build ( ) ;
2933
+
2934
+ p. cargo ( "doc -Zrustdoc-depinfo" )
2935
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
2936
+ . with_stderr_data ( str![ [ r#"
2937
+ [DOCUMENTING] foo v0.0.0 ([ROOT]/parent/foo)
2938
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2939
+ [GENERATED] [ROOT]/parent/foo/target/doc/foo/index.html
2940
+
2941
+ "# ] ] )
2942
+ . run ( ) ;
2943
+
2944
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
2945
+ assert ! ( doc_html. contains( "depinfo-before" ) ) ;
2946
+
2947
+ p. change_file ( "../lib.rs" , "//! # depinfo-after" ) ;
2948
+
2949
+ p. cargo ( "doc --verbose -Zrustdoc-depinfo" )
2950
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
2951
+ . with_stderr_data ( str![ [ r#"
2952
+ [FRESH] foo v0.0.0 ([ROOT]/parent/foo)
2953
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2954
+ [GENERATED] [ROOT]/parent/foo/target/doc/foo/index.html
2955
+
2956
+ "# ] ] )
2957
+ . run ( ) ;
2958
+
2959
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
2960
+ assert ! ( !doc_html. contains( "depinfo-after" ) ) ;
2961
+ }
2962
+
2963
+ #[ cargo_test( nightly, reason = "`rustdoc --emit` is unstable" ) ]
2964
+ fn rebuild_tracks_include_str ( ) {
2965
+ let p = cargo_test_support:: project_in ( "parent" )
2966
+ . file ( "Cargo.toml" , & basic_lib_manifest ( "foo" ) )
2967
+ . file ( "src/lib.rs" , r#"#![doc = include_str!("../../README")]"# )
2968
+ . file ( "../README" , "# depinfo-before" )
2969
+ . build ( ) ;
2970
+
2971
+ p. cargo ( "doc -Zrustdoc-depinfo" )
2972
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
2973
+ . with_stderr_data ( str![ [ r#"
2974
+ [DOCUMENTING] foo v0.5.0 ([ROOT]/parent/foo)
2975
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2976
+ [GENERATED] [ROOT]/parent/foo/target/doc/foo/index.html
2977
+
2978
+ "# ] ] )
2979
+ . run ( ) ;
2980
+
2981
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
2982
+ assert ! ( doc_html. contains( "depinfo-before" ) ) ;
2983
+
2984
+ p. change_file ( "../README" , "# depinfo-after" ) ;
2985
+
2986
+ p. cargo ( "doc --verbose -Zrustdoc-depinfo" )
2987
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
2988
+ . with_stderr_data ( str![ [ r#"
2989
+ [FRESH] foo v0.5.0 ([ROOT]/parent/foo)
2990
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2991
+ [GENERATED] [ROOT]/parent/foo/target/doc/foo/index.html
2992
+
2993
+ "# ] ] )
2994
+ . run ( ) ;
2995
+
2996
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
2997
+ assert ! ( !doc_html. contains( "depinfo-after" ) ) ;
2998
+ }
2999
+
3000
+ #[ cargo_test( nightly, reason = "`rustdoc --emit` is unstable" ) ]
3001
+ fn rebuild_tracks_path_attr ( ) {
3002
+ let p = cargo_test_support:: project_in ( "parent" )
3003
+ . file ( "Cargo.toml" , & basic_lib_manifest ( "foo" ) )
3004
+ . file ( "src/lib.rs" , r#"#[path = "../../bar.rs"] pub mod bar;"# )
3005
+ . file ( "../bar.rs" , "//! # depinfo-before" )
3006
+ . build ( ) ;
3007
+
3008
+ p. cargo ( "doc -Zrustdoc-depinfo" )
3009
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
3010
+ . with_stderr_data ( str![ [ r#"
3011
+ [DOCUMENTING] foo v0.5.0 ([ROOT]/parent/foo)
3012
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3013
+ [GENERATED] [ROOT]/parent/foo/target/doc/foo/index.html
3014
+
3015
+ "# ] ] )
3016
+ . run ( ) ;
3017
+
3018
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
3019
+ assert ! ( doc_html. contains( "depinfo-before" ) ) ;
3020
+
3021
+ p. change_file ( "../bar.rs" , "//! # depinfo-after" ) ;
3022
+
3023
+ p. cargo ( "doc --verbose -Zrustdoc-depinfo" )
3024
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
3025
+ . with_stderr_data ( str![ [ r#"
3026
+ [FRESH] foo v0.5.0 ([ROOT]/parent/foo)
3027
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3028
+ [GENERATED] [ROOT]/parent/foo/target/doc/foo/index.html
3029
+
3030
+ "# ] ] )
3031
+ . run ( ) ;
3032
+
3033
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
3034
+ assert ! ( !doc_html. contains( "depinfo-after" ) ) ;
3035
+ }
3036
+
3037
+ #[ cargo_test( nightly, reason = "`rustdoc --emit` is unstable" ) ]
3038
+ fn rebuild_tracks_env ( ) {
3039
+ let env = "__RUSTDOC_INJECTED" ;
3040
+ let p = project ( )
3041
+ . file ( "Cargo.toml" , & basic_lib_manifest ( "foo" ) )
3042
+ . file ( "src/lib.rs" , & format ! ( r#"#![doc = env!("{env}")]"# ) )
3043
+ . build ( ) ;
3044
+
3045
+ p. cargo ( "doc -Zrustdoc-depinfo" )
3046
+ . env ( env, "# depinfo-before" )
3047
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
3048
+ . with_stderr_data ( str![ [ r#"
3049
+ [DOCUMENTING] foo v0.5.0 ([ROOT]/foo)
3050
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3051
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
3052
+
3053
+ "# ] ] )
3054
+ . run ( ) ;
3055
+
3056
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
3057
+ assert ! ( doc_html. contains( "depinfo-before" ) ) ;
3058
+
3059
+ p. cargo ( "doc --verbose -Zrustdoc-depinfo" )
3060
+ . env ( env, "# depinfo-after" )
3061
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
3062
+ . with_stderr_data ( str![ [ r#"
3063
+ [FRESH] foo v0.5.0 ([ROOT]/foo)
3064
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3065
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
3066
+
3067
+ "# ] ] )
3068
+ . run ( ) ;
3069
+
3070
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
3071
+ assert ! ( !doc_html. contains( "depinfo-after" ) ) ;
3072
+ }
3073
+
3074
+ #[ cargo_test( nightly, reason = "`rustdoc --emit` is unstable" ) ]
3075
+ fn rebuild_tracks_env_in_dep ( ) {
3076
+ let env = "__RUSTDOC_INJECTED" ;
3077
+ Package :: new ( "bar" , "0.1.0" )
3078
+ . file ( "src/lib.rs" , & format ! ( r#"#![doc = env!("{env}")]"# ) )
3079
+ . publish ( ) ;
3080
+
3081
+ let env = "__RUSTDOC_INJECTED" ;
3082
+ let p = project ( )
3083
+ . file (
3084
+ "Cargo.toml" ,
3085
+ r#"
3086
+ [package]
3087
+ name = "foo"
3088
+ edition = "2015"
3089
+ [dependencies]
3090
+ bar = "0.1.0"
3091
+ "# ,
3092
+ )
3093
+ . file ( "src/lib.rs" , "" )
3094
+ . build ( ) ;
3095
+
3096
+ p. cargo ( "doc -Zrustdoc-depinfo" )
3097
+ . env ( env, "# depinfo-before" )
3098
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
3099
+ . with_stderr_data (
3100
+ str![ [ r#"
3101
+ [UPDATING] `dummy-registry` index
3102
+ [LOCKING] 1 package to latest compatible version
3103
+ [DOWNLOADING] crates ...
3104
+ [DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
3105
+ [CHECKING] bar v0.1.0
3106
+ [DOCUMENTING] bar v0.1.0
3107
+ [DOCUMENTING] foo v0.0.0 ([ROOT]/foo)
3108
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3109
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
3110
+
3111
+ "# ] ]
3112
+ . unordered ( ) ,
3113
+ )
3114
+ . run ( ) ;
3115
+
3116
+ let doc_html = p. read_file ( "target/doc/bar/index.html" ) ;
3117
+ assert ! ( doc_html. contains( "depinfo-before" ) ) ;
3118
+
3119
+ p. cargo ( "doc --verbose -Zrustdoc-depinfo" )
3120
+ . env ( env, "# depinfo-after" )
3121
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
3122
+ . with_stderr_data ( str![ [ r#"
3123
+ [DIRTY] bar v0.1.0: the environment variable __RUSTDOC_INJECTED changed
3124
+ [CHECKING] bar v0.1.0
3125
+ [RUNNING] `rustc --crate-name bar [..]`
3126
+ [DIRTY] foo v0.0.0 ([ROOT]/foo): the dependency bar was rebuilt
3127
+ [DOCUMENTING] foo v0.0.0 ([ROOT]/foo)
3128
+ [RUNNING] `rustdoc [..]--crate-name foo [..]`
3129
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3130
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
3131
+
3132
+ "# ] ] )
3133
+ . run ( ) ;
3134
+
3135
+ let doc_html = p. read_file ( "target/doc/bar/index.html" ) ;
3136
+ assert ! ( !doc_html. contains( "depinfo-after" ) ) ;
3137
+ }
3138
+
3139
+ #[ cargo_test(
3140
+ nightly,
3141
+ reason = "`rustdoc --emit` is unstable; requires -Zchecksum-hash-algorithm"
3142
+ ) ]
3143
+ fn rebuild_tracks_checksum ( ) {
3144
+ let p = cargo_test_support:: project_in ( "parent" )
3145
+ . file ( "Cargo.toml" , & basic_lib_manifest ( "foo" ) )
3146
+ . file ( "src/lib.rs" , r#"#![doc = include_str!("../../README")]"# )
3147
+ . file ( "../README" , "# depinfo-before" )
3148
+ . build ( ) ;
3149
+
3150
+ p. cargo ( "doc -Zrustdoc-depinfo -Zchecksum-freshness" )
3151
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" , "checksum-freshness" ] )
3152
+ . with_stderr_data ( str![ [ r#"
3153
+ [DOCUMENTING] foo v0.5.0 ([ROOT]/parent/foo)
3154
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3155
+ [GENERATED] [ROOT]/parent/foo/target/doc/foo/index.html
3156
+
3157
+ "# ] ] )
3158
+ . run ( ) ;
3159
+
3160
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
3161
+ assert ! ( doc_html. contains( "depinfo-before" ) ) ;
3162
+
3163
+ p. change_file ( "../README" , "# depinfo-after" ) ;
3164
+ // Change mtime into the future
3165
+ p. root ( ) . move_into_the_future ( ) ;
3166
+
3167
+ p. cargo ( "doc --verbose -Zrustdoc-depinfo -Zchecksum-freshness" )
3168
+ . masquerade_as_nightly_cargo ( & [ "rustdoc-depinfo" ] )
3169
+ . with_stderr_data ( str![ [ r#"
3170
+ [DIRTY] foo v0.5.0 ([ROOT]/parent/foo): the precalculated components changed
3171
+ [DOCUMENTING] foo v0.5.0 ([ROOT]/parent/foo)
3172
+ [RUNNING] `rustdoc [..]`
3173
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3174
+ [GENERATED] [ROOT]/parent/foo/target/doc/foo/index.html
3175
+
3176
+ "# ] ] )
3177
+ . run ( ) ;
3178
+
3179
+ let doc_html = p. read_file ( "target/doc/foo/index.html" ) ;
3180
+ assert ! ( doc_html. contains( "depinfo-after" ) ) ;
3181
+ }
0 commit comments