From 78dc45e99e7a5b66d81d4294ee83773e49c74f1f Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 21 Feb 2021 00:18:01 +0100 Subject: [PATCH] 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. --- plugins/Aka/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Aka/test.py b/plugins/Aka/test.py index 3aee0a983..6f7b0fdd8 100644 --- a/plugins/Aka/test.py +++ b/plugins/Aka/test.py @@ -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