File tree Expand file tree Collapse file tree 1 file changed +150
-0
lines changed Expand file tree Collapse file tree 1 file changed +150
-0
lines changed Original file line number Diff line number Diff line change @@ -268,3 +268,153 @@ fn aliases_can_be_defined_as_attributes() {
268
268
. status ( EXIT_SUCCESS )
269
269
. run ( ) ;
270
270
}
271
+
272
+ #[ test]
273
+ fn multiple_aliases_can_be_defined_as_attributes ( ) {
274
+ Test :: new ( )
275
+ . justfile (
276
+ "
277
+ [alias('bar')]
278
+ [alias('foo')]
279
+ baz:
280
+ " ,
281
+ )
282
+ . arg ( "foo" )
283
+ . status ( EXIT_SUCCESS )
284
+ . run ( ) ;
285
+ }
286
+
287
+ #[ test]
288
+ fn duplicate_alias_attributes_are_forbidden ( ) {
289
+ Test :: new ( )
290
+ . justfile (
291
+ "
292
+ [alias('foo')]
293
+ [alias('foo')]
294
+ baz:
295
+ " ,
296
+ )
297
+ . arg ( "foo" )
298
+ . stderr (
299
+ "
300
+ error: Alias `foo` first defined on line 1 is redefined on line 2
301
+ βββΆ justfile:2:9
302
+ β
303
+ 2 β [alias('foo')]
304
+ β ^^^
305
+ " ,
306
+ )
307
+ . status ( EXIT_FAILURE )
308
+ . run ( ) ;
309
+ }
310
+
311
+ #[ test]
312
+ fn alias_attributes_duplicating_alias_definition_is_forbidden ( ) {
313
+ Test :: new ( )
314
+ . justfile (
315
+ "
316
+ alias foo := baz
317
+ [alias('foo')]
318
+ baz:
319
+ " ,
320
+ )
321
+ . arg ( "foo" )
322
+ . stderr (
323
+ "
324
+ error: Alias `foo` first defined on line 1 is redefined on line 2
325
+ βββΆ justfile:2:9
326
+ β
327
+ 2 β [alias('foo')]
328
+ β ^^^
329
+ " ,
330
+ )
331
+ . status ( EXIT_FAILURE )
332
+ . run ( ) ;
333
+ }
334
+
335
+ #[ test]
336
+ fn alias_definitions_duplicating_alias_attributes_is_forbidden ( ) {
337
+ Test :: new ( )
338
+ . justfile (
339
+ "
340
+ [alias('foo')]
341
+ baz:
342
+
343
+ alias foo := baz
344
+ " ,
345
+ )
346
+ . arg ( "foo" )
347
+ . stderr (
348
+ "
349
+ error: Alias `foo` first defined on line 1 is redefined on line 4
350
+ βββΆ justfile:4:7
351
+ β
352
+ 4 β alias foo := baz
353
+ β ^^^
354
+ " ,
355
+ )
356
+ . status ( EXIT_FAILURE )
357
+ . run ( ) ;
358
+ }
359
+
360
+ #[ test]
361
+ fn alphanumeric_and_underscores_are_valid_alias_attributes ( ) {
362
+ let out = Test :: new ( )
363
+ . justfile (
364
+ "
365
+ [alias('alpha_numeric_123')]
366
+ baz:
367
+ " ,
368
+ )
369
+ . arg ( "alpha_numeric_123" )
370
+ . status ( EXIT_SUCCESS )
371
+ . run ( ) ;
372
+
373
+ dbg ! ( out. stdout) ;
374
+ }
375
+
376
+ #[ test]
377
+ fn nonalphanumeric_alias_attribute_is_forbidden ( ) {
378
+ Test :: new ( )
379
+ . justfile (
380
+ "
381
+ [alias('invalid name!')]
382
+ baz:
383
+ " ,
384
+ )
385
+ . arg ( "foo" )
386
+ . stderr (
387
+ "
388
+ error: `invalid name!` is not a valid alias. Aliases must only contain alphanumeric characters and underscores.
389
+ βββΆ justfile:1:9
390
+ β
391
+ 1 β [alias('invalid name!')]
392
+ β ^^^^^^^^^^^^^
393
+ " ,
394
+ )
395
+ . status ( EXIT_FAILURE )
396
+ . run ( ) ;
397
+ }
398
+
399
+ #[ test]
400
+ fn empty_alias_attribute_is_forbidden ( ) {
401
+ Test :: new ( )
402
+ . justfile (
403
+ "
404
+ [alias('')]
405
+ baz:
406
+ " ,
407
+ )
408
+ . arg ( "baz" )
409
+ . stderr (
410
+ "
411
+ error: `` is not a valid alias. Aliases must only contain alphanumeric characters and underscores.
412
+ βββΆ justfile:1:9
413
+ β
414
+ 1 β [alias('')]
415
+ β ^
416
+ " ,
417
+ )
418
+ . status ( EXIT_FAILURE )
419
+ . run ( ) ;
420
+ }
You canβt perform that action at this time.
0 commit comments