home · contact · privacy
In testing, for "repeat" instruction, use named anchors rather than (constantly chang...
authorChristian Heller <c.heller@plomlompom.de>
Fri, 26 Sep 2025 08:00:19 +0000 (10:00 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 26 Sep 2025 08:00:19 +0000 (10:00 +0200)
src/ircplom/testing.py
src/tests/test.txt

index 558dc45d7053907452d8b565be48d7a35bf3a3eb..23062e540243109bed8bf5d865f74669809adc27 100644 (file)
@@ -102,6 +102,10 @@ class TestingClientTui(ClientTui):
         self._q_keypresses = self._term._q_keypresses
         with self._path_test.open('r', encoding='utf8') as f:
             self._playbook = tuple(line[:-1] for line in f.readlines())
+        self._playbook_anchors: dict[str, int] = {}
+        for idx, line in enumerate(self._playbook):
+            if line[:1] == '|':
+                self._playbook_anchors[line[1:]] = idx + 1
         self._playbook_idx = -1
         self._play_till_next_log()
 
@@ -140,11 +144,13 @@ class TestingClientTui(ClientTui):
         while True:
             self._playbook_idx += 1
             line = self._playbook[self._playbook_idx]
-            if line[:1] == '#' or not line.strip():
+            if line[:1] in '#|' or not line.strip():
                 continue
             context, msg = line.split(' ', maxsplit=1)
             if context == 'repeat':
-                start, end = msg.split(':')
+                start_key, end_key = msg.split(' ')
+                start = self._playbook_anchors[start_key]
+                end = self._playbook_anchors[end_key]
                 self._playbook = (self._playbook[:self._playbook_idx + 1]
                                   + self._playbook[int(start):int(end)]
                                   + self._playbook[self._playbook_idx + 1:])
index dc0d9ac2572e1bc76039ed8b68837b8524be9b3d..5af8ac6d88f15cf5ac3b585f80237a47faa0aaea 100644 (file)
 1 $ realname set to: [baz]
 1 $ password set to: [bar]
 1 $ port set to: [6697]
+|conn0
 1 $ connection_state set to: [connecting]
 1 $ connection_state set to: [connected]
+|conn1
 , $ CONNECTED
+|conn2
 1 > CAP LS :302
 1 > USER foobarbazquux 0 * :baz
 1 > NICK :foo
@@ -76,6 +79,7 @@
 
 # of all pre-MOTD greeting messages, only process isupports
 0:1 < :foo.bar.baz 001 foo1 :Welcome to the foo.bar.baz network
+|conn3
 0:1 < :foo.bar.baz 002 foo1 :Your host is foo.bar.baz
 0:1 < :foo.bar.baz 003 foo1 :This server was created Jan 1 2020
 0:1 < :foo.bar.baz 004 foo1 foo.bar.baz ircserver-1.0 abc def ghi
 # handle bot query NOTICE
 0:1 < :SaslServ!SaslServ@services.bar.baz NOTICE foo1 :Last login from ~foobarbaz@foo.bar.baz on Jan 1 22:00:00 2021 +0000.
 3 < *** [SaslServ] Last login from ~foobarbaz@foo.bar.baz on Jan 1 22:00:00 2021 +0000.
+|conn4
 
 # check difference in available commands when switching to client window
 > /join #test
 0 #   1) foo.bar.baz :DEBUG
 0 #   2) foo.bar.baz  server
 0 #   3) foo.bar.baz SaslServ
+|conn5
 > /window 1
 > /help
 1 # commands available in this window:
 1 !$ cannot send, connection seems closed
 > /privmsg #test test
 1 !$ not sending, since not in channel
+|conn6
 
 # test setting up second client, but 432 irrecoverably
 > /connect baz.bar.foo ?foo foo:foo
 
 # check that (save TUI tests assuming start on window 0, and no 4 yet) on reconnect, all the same effects can be expected
 > /reconnect
-repeat 21:23
+repeat conn0 conn1
 2,3,4,5,6,7 $ CONNECTED
-repeat 24:78
+repeat conn2 conn3
 1 > JOIN :#testtest
-repeat 78:116
-repeat 126:340
+repeat conn3 conn4
+repeat conn5 conn6
 
 > /quit
 0 <