Correctly handle undo with multiple tasks (#3886)

The `std::stringstream::clear` method does not, in fact, clear the
string -- it just resets some internal flags. Assigning a new
stringstream to the variable is not the most efficient way to do this,
but it's the clearest.
This commit is contained in:
Dustin J. Mitchell 2025-05-26 13:07:35 -04:00 committed by GitHub
parent 89d84f0bdd
commit f6824e90a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View file

@ -27,6 +27,7 @@
import sys
import os
import re
import unittest
# Ensure python finds the local simpletap module
@ -61,6 +62,25 @@ class TestUndo(TestCase):
code, out, err = self.t("_get 1.status")
self.assertEqual(out.strip(), "pending")
def test_modify_multiple_tasks(self):
"""'add' then 'done' then 'undo'"""
self.t("add one")
self.t("add two")
self.t("add three")
self.t("rc.bulk=0 1,2,3 modify +sometag")
code, out, err = self.t("undo", input="y\n")
# This undo output should show one tag modification for each task, possibly with some
# modification-time updates if the modifications spanned a second boundary.
self.assertRegex(
out,
"\s+".join(
[
r"""[0-9a-f-]{36} (Update property 'modified' from\s+'[0-9]+' to '[0-9]+'\s+)?Add tag 'sometag'\s+Add property 'tags' with value 'sometag'"""
]
* 3
),
)
def test_undo_en_passant(self):
"""Verify that en-passant changes during undo are an error"""
self.t("add one")