@@ -216,7 +216,7 @@ pub fn gha_output(tag: &str, content: &str) {
216
216
println ! ( "::set-output name={tag}::{}" , content)
217
217
}
218
218
219
- pub fn read_dockerfiles ( msg_info : MessageInfo ) -> cross:: Result < Vec < String > > {
219
+ pub fn read_dockerfiles ( msg_info : MessageInfo ) -> cross:: Result < Vec < ( PathBuf , String ) > > {
220
220
let root = project_dir ( msg_info) ?;
221
221
let docker = root. join ( "docker" ) ;
222
222
let mut dockerfiles = vec ! [ ] ;
@@ -225,18 +225,18 @@ pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result<Vec<String>> {
225
225
let file_type = entry. file_type ( ) ?;
226
226
let file_name = entry. file_name ( ) ;
227
227
if file_type. is_file ( ) && file_name. to_utf8 ( ) ?. starts_with ( "Dockerfile" ) {
228
- dockerfiles. push ( fs:: read_to_string ( entry. path ( ) ) ?) ;
228
+ let contents = fs:: read_to_string ( entry. path ( ) ) ?;
229
+ dockerfiles. push ( ( entry. path ( ) . to_path_buf ( ) , contents) ) ;
229
230
}
230
231
}
231
232
232
233
Ok ( dockerfiles)
233
234
}
234
235
235
- #[ cfg( tests ) ]
236
+ #[ cfg( test ) ]
236
237
mod tests {
237
238
use super :: * ;
238
239
239
- use crate :: util:: read_dockerfiles;
240
240
use cross:: shell:: Verbosity ;
241
241
use std:: collections:: BTreeMap ;
242
242
@@ -245,15 +245,13 @@ mod tests {
245
245
// count all the entries of FROM for our images
246
246
let mut counts = BTreeMap :: new ( ) ;
247
247
let dockerfiles = read_dockerfiles ( Verbosity :: Verbose . into ( ) ) ?;
248
- for dockerfile in dockerfiles {
248
+ for ( path , dockerfile) in dockerfiles {
249
249
let lines: Vec < & str > = dockerfile. lines ( ) . collect ( ) ;
250
250
let index = lines
251
251
. iter ( )
252
252
. map ( |x| x. trim ( ) )
253
253
. position ( |x| x. to_lowercase ( ) . starts_with ( "from" ) )
254
- . ok_or_else ( || {
255
- eyre:: eyre!( "unable to find FROM instruction for {:?}" , entry. path( ) )
256
- } ) ?;
254
+ . ok_or_else ( || eyre:: eyre!( "unable to find FROM instruction for {:?}" , path) ) ?;
257
255
let tag = lines[ index]
258
256
. split_whitespace ( )
259
257
. nth ( 1 )
0 commit comments