@@ -433,6 +433,136 @@ def test_load_symlinked_workspace(
433
433
assert pane .current_path == str (realtemp )
434
434
435
435
436
+ if t .TYPE_CHECKING :
437
+ from typing_extensions import TypeAlias
438
+
439
+ ExpectedOutput : TypeAlias = t .Optional [t .Union [str , t .List [str ]]]
440
+
441
+
442
+ class CLILoadFixture (t .NamedTuple ):
443
+ test_id : str
444
+ cli_args : t .List [str ]
445
+ config_paths : t .List [str ]
446
+ expected_exit_code : int
447
+ expected_in_out : "ExpectedOutput" = None
448
+ expected_not_in_out : "ExpectedOutput" = None
449
+ expected_in_err : "ExpectedOutput" = None
450
+ expected_not_in_err : "ExpectedOutput" = None
451
+
452
+
453
+ TEST_LOAD_FIXTURES = [
454
+ CLILoadFixture (
455
+ test_id = "dir-relative-dot-samedir" ,
456
+ cli_args = ["load" , "." ],
457
+ config_paths = ["{tmp_path}/.tmuxp.yaml" ],
458
+ expected_exit_code = 0 ,
459
+ expected_in_out = None ,
460
+ expected_not_in_out = None ,
461
+ ),
462
+ CLILoadFixture (
463
+ test_id = "dir-relative-dot-slash-samedir" ,
464
+ cli_args = ["load" , "./" ],
465
+ config_paths = ["{tmp_path}/.tmuxp.yaml" ],
466
+ expected_exit_code = 0 ,
467
+ expected_in_out = None ,
468
+ expected_not_in_out = None ,
469
+ ),
470
+ CLILoadFixture (
471
+ test_id = "dir-relative-file-samedir" ,
472
+ cli_args = ["load" , "./.tmuxp.yaml" ],
473
+ config_paths = ["{tmp_path}/.tmuxp.yaml" ],
474
+ expected_exit_code = 0 ,
475
+ expected_in_out = None ,
476
+ expected_not_in_out = None ,
477
+ ),
478
+ CLILoadFixture (
479
+ test_id = "filename-relative-file-samedir" ,
480
+ cli_args = ["load" , "./my_config.yaml" ],
481
+ config_paths = ["{tmp_path}/my_config.yaml" ],
482
+ expected_exit_code = 0 ,
483
+ expected_in_out = None ,
484
+ expected_not_in_out = None ,
485
+ ),
486
+ CLILoadFixture (
487
+ test_id = "configdir-session-name" ,
488
+ cli_args = ["load" , "my_config" ],
489
+ config_paths = ["{TMUXP_CONFIGDIR}/my_config.yaml" ],
490
+ expected_exit_code = 0 ,
491
+ expected_in_out = None ,
492
+ expected_not_in_out = None ,
493
+ ),
494
+ CLILoadFixture (
495
+ test_id = "configdir-absolute" ,
496
+ cli_args = ["load" , "~/.config/tmuxp/my_config.yaml" ],
497
+ config_paths = ["{TMUXP_CONFIGDIR}/my_config.yaml" ],
498
+ expected_exit_code = 0 ,
499
+ expected_in_out = None ,
500
+ expected_not_in_out = None ,
501
+ ),
502
+ ]
503
+
504
+
505
+ @pytest .mark .parametrize (
506
+ list (CLILoadFixture ._fields ),
507
+ TEST_LOAD_FIXTURES ,
508
+ ids = [test .test_id for test in TEST_LOAD_FIXTURES ],
509
+ )
510
+ @pytest .mark .usefixtures ("tmuxp_configdir_default" )
511
+ def test_load (
512
+ tmp_path : pathlib .Path ,
513
+ tmuxp_configdir : pathlib .Path ,
514
+ server : "Server" ,
515
+ session : Session ,
516
+ capsys : pytest .CaptureFixture ,
517
+ monkeypatch : pytest .MonkeyPatch ,
518
+ test_id : str ,
519
+ cli_args : t .List [str ],
520
+ config_paths : t .List [str ],
521
+ expected_exit_code : int ,
522
+ expected_in_out : "ExpectedOutput" ,
523
+ expected_not_in_out : "ExpectedOutput" ,
524
+ expected_in_err : "ExpectedOutput" ,
525
+ expected_not_in_err : "ExpectedOutput" ,
526
+ ) -> None :
527
+ assert server .socket_name is not None
528
+
529
+ monkeypatch .chdir (tmp_path )
530
+ for config_path in config_paths :
531
+ tmuxp_config = pathlib .Path (
532
+ config_path .format (tmp_path = tmp_path , TMUXP_CONFIGDIR = tmuxp_configdir )
533
+ )
534
+ tmuxp_config .write_text (
535
+ """
536
+ session_name: test
537
+ windows:
538
+ - window_name: test
539
+ panes:
540
+ -
541
+ """ ,
542
+ encoding = "utf-8" ,
543
+ )
544
+
545
+ try :
546
+ cli .cli ([* cli_args , "-d" , "-L" , server .socket_name ])
547
+ except SystemExit :
548
+ pass
549
+
550
+ result = capsys .readouterr ()
551
+ output = "" .join (list (result .out ))
552
+
553
+ if expected_in_out is not None :
554
+ if isinstance (expected_in_out , str ):
555
+ expected_in_out = [expected_in_out ]
556
+ for needle in expected_in_out :
557
+ assert needle in output
558
+
559
+ if expected_not_in_out is not None :
560
+ if isinstance (expected_not_in_out , str ):
561
+ expected_not_in_out = [expected_not_in_out ]
562
+ for needle in expected_not_in_out :
563
+ assert needle not in output
564
+
565
+
436
566
def test_regression_00132_session_name_with_dots (
437
567
tmp_path : pathlib .Path ,
438
568
server : "Server" ,
0 commit comments