aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2022-03-09 13:22:14 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2022-03-09 16:31:12 +0200
commit6ec6e0c9ec5a9f0a01fe573cfc76fb26986fbd18 (patch)
treee7f9cd4f961565817cce1c0698a3e7f61840f3e9
parent7df6c6a7289157d3f7094a63c7205aca22351900 (diff)
downloadmeson-6ec6e0c9ec5a9f0a01fe573cfc76fb26986fbd18.zip
meson-6ec6e0c9ec5a9f0a01fe573cfc76fb26986fbd18.tar.gz
meson-6ec6e0c9ec5a9f0a01fe573cfc76fb26986fbd18.tar.bz2
Replace freezing regex with plain text operations.
The regex in question causes Python's regex parser to freeze indefinitely in certain Python versions. That might be due to a bug or because the re does infinite backtracking and it just happened to work on earlier implementations.
-rw-r--r--unittests/allplatformstests.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 665e0c6..6efff61 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -3376,9 +3376,21 @@ class AllPlatformTests(BasePlatformTests):
## Validate commands
md_commands = {k for k,v in md_command_sections.items()}
-
help_output = self._run(self.meson_command + ['--help'])
- help_commands = {c.strip() for c in re.findall(r'usage:(?:.+)?{((?:[a-z]+,*)+?)}', help_output, re.MULTILINE|re.DOTALL)[0].split(',')}
+ # Python's argument parser might put the command list to its own line. Or it might not.
+ self.assertTrue(help_output.startswith('usage: '))
+ lines = help_output.split('\n')
+ line1 = lines[0]
+ line2 = lines[1]
+ if '{' in line1:
+ cmndline = line1
+ else:
+ self.assertIn('{', line2)
+ cmndline = line2
+ cmndstr = cmndline.split('{')[1]
+ self.assertIn('}', cmndstr)
+ help_commands = set(cmndstr.split('}')[0].split(','))
+ self.assertTrue(len(help_commands) > 0, 'Must detect some command names.')
self.assertEqual(md_commands | {'help'}, help_commands, f'Doc file: `{doc_path}`')