@@ -25,7 +25,7 @@ fn pattern_mismatch() {
2525 . args ( [ "foo" , "bar" ] )
2626 . stderr (
2727 "
28- error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ' BAR'
28+ error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ` BAR`
2929 " ,
3030 )
3131 . failure ( ) ;
@@ -43,7 +43,7 @@ fn patterns_are_regular_expressions() {
4343 . args ( [ "foo" , r"\d+" ] )
4444 . stderr (
4545 r"
46- error: argument `\d+` passed to recipe `foo` parameter `bar` does not match pattern ' \d+'
46+ error: argument `\d+` passed to recipe `foo` parameter `bar` does not match pattern ` \d+`
4747 " ,
4848 )
4949 . failure ( ) ;
@@ -61,7 +61,7 @@ fn pattern_must_match_entire_string() {
6161 . args ( [ "foo" , "xbarx" ] )
6262 . stderr (
6363 "
64- error: argument `xbarx` passed to recipe `foo` parameter `bar` does not match pattern ' bar'
64+ error: argument `xbarx` passed to recipe `foo` parameter `bar` does not match pattern ` bar`
6565 " ,
6666 )
6767 . failure ( ) ;
@@ -105,7 +105,7 @@ fn pattern_may_be_expression() {
105105 . args ( [ "foo" , "bar" ] )
106106 . stderr (
107107 "
108- error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ' BAR'
108+ error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ` BAR`
109109 " ,
110110 )
111111 . failure ( ) ;
@@ -154,28 +154,59 @@ fn pattern_cannot_reference_undefined_variable() {
154154}
155155
156156#[ test]
157- fn pattern_cannot_be_list ( ) {
157+ fn pattern_list_match ( ) {
158+ Test :: new ( )
159+ . justfile (
160+ "
161+ set lists
162+ [arg('bar', pattern=['A', 'B'])]
163+ foo bar:
164+ " ,
165+ )
166+ . env ( "JUST_UNSTABLE" , "1" )
167+ . args ( [ "foo" , "A" ] )
168+ . success ( )
169+ . test ( )
170+ . env ( "JUST_UNSTABLE" , "1" )
171+ . args ( [ "foo" , "B" ] )
172+ . success ( ) ;
173+ }
174+
175+ #[ test]
176+ fn pattern_list_mismatch ( ) {
158177 Test :: new ( )
159178 . justfile (
160179 "
161180 set lists
162- [arg('bar', pattern=['a ', 'b '])]
181+ [arg('bar', pattern=['A ', 'B '])]
163182 foo bar:
164183 " ,
165184 )
166185 . env ( "JUST_UNSTABLE" , "1" )
186+ . args ( [ "foo" , "C" ] )
167187 . stderr (
168- r#"
169- error: list value ["a", "b"] used as `arg` attribute pattern
170- ——▶ justfile:2:13
171- │
172- 2 │ [arg('bar', pattern=['a', 'b'])]
173- │ ^^^^^^^
174- "# ,
188+ "
189+ error: argument `C` passed to recipe `foo` parameter `bar` does not match pattern `A` or `B`
190+ " ,
175191 )
176192 . failure ( ) ;
177193}
178194
195+ #[ test]
196+ fn pattern_empty_list_accepts_all_arguments ( ) {
197+ Test :: new ( )
198+ . justfile (
199+ "
200+ set lists
201+ [arg('bar', pattern=[])]
202+ foo bar:
203+ " ,
204+ )
205+ . env ( "JUST_UNSTABLE" , "1" )
206+ . args ( [ "foo" , "anything" ] )
207+ . success ( ) ;
208+ }
209+
179210#[ test]
180211fn pattern_cannot_reference_non_const_variable ( ) {
181212 Test :: new ( )
@@ -277,7 +308,7 @@ fn pattern_mismatches_are_caught_before_running_dependencies() {
277308 . args ( [ "foo" , "bar" ] )
278309 . stderr (
279310 "
280- error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ' BAR'
311+ error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ` BAR`
281312 " ,
282313 )
283314 . failure ( ) ;
@@ -298,7 +329,7 @@ fn pattern_mismatches_are_caught_before_running_invocation() {
298329 . args ( [ "baz" , "foo" , "bar" ] )
299330 . stderr (
300331 "
301- error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ' BAR'
332+ error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ` BAR`
302333 " ,
303334 )
304335 . failure ( ) ;
@@ -317,7 +348,7 @@ fn pattern_mismatches_are_caught_in_evaluated_arguments() {
317348 )
318349 . stderr (
319350 "
320- error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ' BAR'
351+ error: argument `bar` passed to recipe `foo` parameter `bar` does not match pattern ` BAR`
321352 " ,
322353 )
323354 . failure ( ) ;
@@ -335,7 +366,7 @@ fn alternates_do_not_bind_to_anchors() {
335366 . args ( [ "foo" , "aa" ] )
336367 . stderr (
337368 "
338- error: argument `aa` passed to recipe `foo` parameter `bar` does not match pattern ' a|b'
369+ error: argument `aa` passed to recipe `foo` parameter `bar` does not match pattern ` a|b`
339370 " ,
340371 )
341372 . failure ( ) ;
@@ -366,7 +397,7 @@ fn pattern_mismatch_variadic() {
366397 . args ( [ "foo" , "BAR" , "BAR" ] )
367398 . stderr (
368399 "
369- error: argument `BAR` passed to recipe `foo` parameter `bar` does not match pattern ' BAR BAR'
400+ error: argument `BAR` passed to recipe `foo` parameter `bar` does not match pattern ` BAR BAR`
370401 " ,
371402 )
372403 . failure ( ) ;
0 commit comments