File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -84,9 +84,10 @@ impl Compiler {
84
84
require_literal_separator : false ,
85
85
require_literal_leading_dot : false ,
86
86
} ;
87
- let import_paths = glob:: glob_with ( & import_base_str, glob_options) . unwrap ( ) ;
87
+ let import_paths = glob:: glob_with ( & import_base_str, glob_options)
88
+ . map_err ( |error| Error :: ImportGlob { error, path : * path } ) ?;
88
89
for import in import_paths {
89
- let import = import. unwrap ( ) ;
90
+ let Ok ( import) = import else { continue } ;
90
91
91
92
if import. is_file ( ) {
92
93
if current. file_path . contains ( & import) {
354
355
) ;
355
356
}
356
357
358
+ #[ test]
359
+ fn invalid_glob_imports ( ) {
360
+ let justfile = r#"
361
+ import "./subdir/***.just"
362
+ "# ;
363
+ let tmp = temptree ! {
364
+ justfile: justfile,
365
+ } ;
366
+ let loader = Loader :: new ( ) ;
367
+ let justfile_path = tmp. path ( ) . join ( "justfile" ) ;
368
+ let error = Compiler :: compile ( & loader, & justfile_path) . unwrap_err ( ) ;
369
+ let expected = "error: import path glob: Pattern syntax error" ;
370
+ let actual = error. color_display ( Color :: never ( ) ) . to_string ( ) ;
371
+ assert ! ( actual. contains( expected) , "Actual: {actual}" ) ;
372
+ }
373
+
357
374
#[ test]
358
375
fn find_module_file ( ) {
359
376
#[ track_caller]
Original file line number Diff line number Diff line change @@ -107,6 +107,10 @@ pub(crate) enum Error<'src> {
107
107
io_error : io:: Error ,
108
108
} ,
109
109
Homedir ,
110
+ ImportGlob {
111
+ error : glob:: PatternError ,
112
+ path : Token < ' src > ,
113
+ } ,
110
114
InitExists {
111
115
justfile : PathBuf ,
112
116
} ,
@@ -209,7 +213,7 @@ impl<'src> Error<'src> {
209
213
Self :: Backtick { token, .. } => Some ( * token) ,
210
214
Self :: Compile { compile_error } => Some ( compile_error. context ( ) ) ,
211
215
Self :: FunctionCall { function, .. } => Some ( function. token ) ,
212
- Self :: MissingImportFile { path } => Some ( * path) ,
216
+ Self :: MissingImportFile { path } | Self :: ImportGlob { path , .. } => Some ( * path) ,
213
217
_ => None ,
214
218
}
215
219
}
@@ -389,6 +393,7 @@ impl<'src> ColorDisplay for Error<'src> {
389
393
Homedir => {
390
394
write ! ( f, "Failed to get homedir" ) ?;
391
395
}
396
+ ImportGlob { error, .. } => write ! ( f, "import path glob: {error}" ) ?,
392
397
InitExists { justfile } => {
393
398
write ! ( f, "Justfile `{}` already exists" , justfile. display( ) ) ?;
394
399
}
You can’t perform that action at this time.
0 commit comments