diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2022-03-09 13:22:14 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2022-03-09 13:22:14 +0200 |
commit | 1e6c2a0c040a799671beeecfac84e97cf17afcd0 (patch) | |
tree | 0b627ae1c54d08340c293f326d4c306243dfb1b9 | |
parent | 7cc4ca2cbb38360743f1d56a5a709bbd51b53ad6 (diff) | |
download | meson-pyrefix.zip meson-pyrefix.tar.gz meson-pyrefix.tar.bz2 |
Replace freezing regex with plain text operations.pyrefix
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.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 665e0c6..d6c77e9 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -3378,7 +3378,12 @@ class AllPlatformTests(BasePlatformTests): 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(',')} + self.assertTrue(help_output.startswith('usage: ')) + line1 = help_output.split('\n')[0] + cmndstr = line1.split('{')[1] + self.assertTrue(cmndstr.endswith('} ...')) + help_commands = cmndstr.split('}')[0].split(',') + self.assertTrue(len(help_commands) > 0) self.assertEqual(md_commands | {'help'}, help_commands, f'Doc file: `{doc_path}`') |