fortrangoingonforty/fortsh / 3e63fcf

Browse files

add PTY tests for bracketed paste + selection replacement

Authored by espadonne
SHA
3e63fcfebee804572be4a833c153e2d98a6ffb95
Parents
4d20292
Tree
ec5aa67

1 changed file

StatusFile+-
M tests/interactive/test_specs/selection.yaml 60 0
tests/interactive/test_specs/selection.yamlmodified
@@ -540,3 +540,63 @@ tests:
540540
       - send_key: "Enter"
541541
     expect_output: "hello"
542542
     match_type: "contains"
543
+
544
+  # =============================================================
545
+  # SPRINT 6 — BRACKETED PASTE MODE
546
+  # The enable (ESC[?2004h) and payload parser (ESC[200~...ESC[201~)
547
+  # predate the shift phase. Sprint 6 adds the FORTSH_NO_BRACKETED_PASTE
548
+  # kill switch and verifies the Sprint 3 insert_char_wrapper hook
549
+  # makes bracketed paste replace an active selection.
550
+  # =============================================================
551
+
552
+  - name: "Sprint 6: bracketed paste inserts at cursor"
553
+    # Baseline: send a bracketed paste payload. The terminal would send
554
+    # ESC[200~<text>ESC[201~ when a user pastes. Our parser consumes
555
+    # the framing and inserts the inner text.
556
+    steps:
557
+      - send: "echo "
558
+      - send: "\u001b[200~pasted_text\u001b[201~"
559
+      - send_key: "Enter"
560
+    expect_output: "pasted_text"
561
+    match_type: "contains"
562
+
563
+  - name: "Sprint 6: bracketed paste replaces active selection"
564
+    # Type "echo hello world", select "world" via Shift+Left x5, then
565
+    # fire a bracketed paste. The first char of the paste triggers
566
+    # delete_selection (Sprint 3 insert_char_wrapper hook); subsequent
567
+    # chars insert normally. Buffer becomes "echo hello BRACKET".
568
+    steps:
569
+      - send: "echo hello world"
570
+      - send_key: "S-Left"
571
+      - send_key: "S-Left"
572
+      - send_key: "S-Left"
573
+      - send_key: "S-Left"
574
+      - send_key: "S-Left"
575
+      - send: "\u001b[200~BRACKET\u001b[201~"
576
+      - send_key: "Enter"
577
+    expect_output: "hello BRACKET"
578
+    match_type: "contains"
579
+
580
+  - name: "Sprint 6: bracketed paste without selection just inserts"
581
+    # Regression guard: with no active selection, bracketed paste inserts
582
+    # at cursor without any deletion. Type "aa", paste "BB", Enter → "aaBB".
583
+    steps:
584
+      - send: "echo aa"
585
+      - send: "\u001b[200~BB\u001b[201~"
586
+      - send_key: "Enter"
587
+    expect_output: "aaBB"
588
+    match_type: "contains"
589
+
590
+  - name: "Sprint 6: FORTSH_NO_BRACKETED_PASTE kill switch does not crash"
591
+    # When the kill switch is set, fortsh does NOT emit the enable
592
+    # sequence (verified manually via pexpect — PTY regex can't easily
593
+    # assert absence of ESC[?2004h in output). This test just ensures
594
+    # fortsh still functions with the kill switch set: prompt returns,
595
+    # echo executes, no crash on startup/teardown.
596
+    env:
597
+      FORTSH_NO_BRACKETED_PASTE: "1"
598
+    fresh_session: true
599
+    steps:
600
+      - send_line: "echo hi"
601
+    expect_output: "hi"
602
+    match_type: "contains"