Skip to content

Commit c22415f

Browse files
committed
Make CTParserBuilder error on test_files with matchless glob.
1 parent e91fa58 commit c22415f

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

lrlex/src/lib/ctbuilder.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,16 @@ where
561561
match setting {
562562
Setting::String(test_files, _) => {
563563
let path_joined = grm_path.parent().unwrap().join(test_files);
564-
for path in
565-
glob(&path_joined.to_string_lossy()).map_err(|e| e.to_string())?
566-
{
564+
let path_str = &path_joined.to_string_lossy();
565+
let mut glob_paths = glob(path_str).map_err(|e| e.to_string())?.peekable();
566+
if glob_paths.peek().is_none() {
567+
return Err(format!("'test_files' glob '{}' matched no paths", path_str)
568+
.to_string()
569+
.into(),
570+
);
571+
}
572+
573+
for path in glob_paths {
567574
let path = path?;
568575
if let Some(ext) = path.extension() {
569576
if let Some(ext) = ext.to_str() {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Test empty matchless glob in array of %grmtools{test_files}
2+
grammar: |
3+
%grmtools {
4+
yacckind: Original(YaccOriginalActionKind::UserAction),
5+
recoverer: RecoveryKind::None,
6+
test_files: ["*.nonexistent"]
7+
}
8+
%start Expr
9+
%actiontype ()
10+
%%
11+
Expr: '(' ')' { () } ;
12+
lexer: |
13+
%%
14+
\( "("
15+
\) ")"
16+
[\t\n ]+ ;

0 commit comments

Comments
 (0)