@@ -175,9 +175,11 @@ mod tests {
175
175
. contains ( "content/inside-rust/" ) ;
176
176
177
177
let content = fs:: read_to_string ( & post) . unwrap ( ) ;
178
- let ( front_matter, rest) = parse ( & content) . unwrap ( ) ;
178
+ let ( front_matter, rest) = parse ( & content) . unwrap_or_else ( |err| {
179
+ panic ! ( "failed to parse {:?}: {err}" , post. display( ) ) ;
180
+ } ) ;
179
181
let normalized = normalize ( & front_matter, slug, inside_rust) . unwrap_or_else ( |err| {
180
- panic ! ( "failed to normalize {:?}: {err}" , post. file_name ( ) . unwrap ( ) ) ;
182
+ panic ! ( "failed to normalize {:?}: {err}" , post. display ( ) ) ;
181
183
} ) ;
182
184
183
185
if front_matter != normalized {
@@ -253,11 +255,14 @@ The post {post} has abnormal front matter.
253
255
}
254
256
255
257
fn all_posts ( ) -> impl Iterator < Item = PathBuf > {
256
- let repo_root = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( ".." ) ;
257
- fs:: read_dir ( repo_root. join ( "content" ) )
258
- . unwrap ( )
259
- . chain ( fs:: read_dir ( repo_root. join ( "content/inside-rust" ) ) . unwrap ( ) )
260
- . map ( |p| p. unwrap ( ) . path ( ) )
261
- . filter ( |p| p. is_file ( ) && p. file_name ( ) != Some ( "_index.md" . as_ref ( ) ) )
258
+ walkdir:: WalkDir :: new ( concat ! ( env!( "CARGO_MANIFEST_DIR" ) , "/../content" ) )
259
+ . into_iter ( )
260
+ . filter_map ( |e| e. ok ( ) . map ( |e| e. into_path ( ) ) )
261
+ . filter ( |p| {
262
+ p. is_file ( )
263
+ && p. extension ( ) == Some ( "md" . as_ref ( ) )
264
+ && p. file_name ( ) != Some ( "_index.md" . as_ref ( ) )
265
+ && p. file_name ( ) != Some ( "latest.md" . as_ref ( ) )
266
+ } )
262
267
}
263
268
}
0 commit comments