Aka: eliminate race condition in tests?

Sometimes (very rarely), the test errors with:

```
======================================================================
FAIL: testHistsearch (Aka.test.AkaChannelTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/supybot/test.py", line 214, in runTest
    originalRunTest()
  File "/usr/lib/python3/dist-packages/supybot/plugins/Aka/test.py", line 67, in testHistsearch
    self.assertResponse('histsearch .*', '@echo foo')
  File "/usr/lib/python3/dist-packages/supybot/test.py", line 402, in assertResponse
    self.assertEqual(m.args[1], expectedResponse,
AssertionError: '@aka add histsearch "last --from [cif true[80 chars]"]]"' != '@echo foo'
- @aka add histsearch "last --from [cif true \"echo test\" \"echo test\"] --regexp [concat \"m/$1/\" [re s/g// \"@2\"]]"
+ @echo foo
 : '@echo foo' != '@aka add histsearch "last --from [cif true \\"echo test\\" \\"echo test\\"] --regexp [concat \\"m/$1/\\" [re s/g// \\"@2\\"]]"'
```

ie. histsearch returns the 'aka add' message instead of the 'echo foo'
one.

My guess is that if they happen too closely to each other, they get
added to the history in the wrong order (how? it's not threaded)

So this commit works around the issue by making the regexp unambiguous.
This commit is contained in:
Valentin Lorentz 2021-02-21 00:18:01 +01:00
parent 85549bf0c3
commit 78dc45e99e

View File

@ -64,7 +64,7 @@ class AkaChannelTestCase(ChannelPluginTestCase):
r'\"echo test\" \"echo test\"] '
r'--regexp [concat \"m/$1/\" [re s/g// \"@2\"]]"')
self.assertResponse('echo foo', 'foo')
self.assertResponse('histsearch .*', '@echo foo')
self.assertResponse('histsearch .*foo.*', '@echo foo')
def testDoesNotOverwriteCommands(self):
# We don't have dispatcher commands anymore