@@ -18,7 +18,7 @@ const TONIC_INCLUDES: &[&str] = &["src/proto/opentelemetry-proto", "src/proto"];
18
18
19
19
#[ test]
20
20
fn build_tonic ( ) {
21
- let before_build = build_content_map ( TONIC_OUT_DIR ) ;
21
+ let before_build = build_content_map ( TONIC_OUT_DIR , false ) ;
22
22
23
23
let out_dir = TempDir :: new ( ) . expect ( "failed to create temp dir to store the generated files" ) ;
24
24
@@ -95,11 +95,11 @@ fn build_tonic() {
95
95
. compile ( TONIC_PROTO_FILES , TONIC_INCLUDES )
96
96
. expect ( "cannot compile protobuf using tonic" ) ;
97
97
98
- let after_build = build_content_map ( out_dir. path ( ) ) ;
98
+ let after_build = build_content_map ( out_dir. path ( ) , true ) ;
99
99
ensure_files_are_same ( before_build, after_build, TONIC_OUT_DIR ) ;
100
100
}
101
101
102
- fn build_content_map ( path : impl AsRef < Path > ) -> HashMap < String , String > {
102
+ fn build_content_map ( path : impl AsRef < Path > , normalize_line_feed : bool ) -> HashMap < String , String > {
103
103
std:: fs:: read_dir ( path)
104
104
. expect ( "cannot open dictionary of generated files" )
105
105
. flatten ( )
@@ -108,9 +108,18 @@ fn build_content_map(path: impl AsRef<Path>) -> HashMap<String, String> {
108
108
let file_name = path
109
109
. file_name ( )
110
110
. expect ( "file name should always exist for generated files" ) ;
111
+
112
+ let file_contents;
113
+ if normalize_line_feed && cfg ! ( windows) {
114
+ file_contents = std:: fs:: read_to_string ( path. clone ( ) ) . expect ( "cannot read from existing generated file" ) . replace ( "\n " , "\r \n " ) ;
115
+ }
116
+ else {
117
+ file_contents = std:: fs:: read_to_string ( path. clone ( ) ) . expect ( "cannot read from existing generated file" ) ;
118
+ }
119
+
111
120
(
112
121
file_name. to_string_lossy ( ) . to_string ( ) ,
113
- std :: fs :: read_to_string ( path ) . expect ( "cannot read from existing generated file" ) ,
122
+ file_contents ,
114
123
)
115
124
} )
116
125
. collect ( )
0 commit comments