diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-11-28 21:21:02 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-04-14 18:37:04 -0400 |
commit | 5df0fb45ca44282e011078b5386831bb4dcbc2ee (patch) | |
tree | 8012123a016e477690a843e40c8d980d5e0da5bf | |
parent | 6a287fae5d10d4c46277e2533aaa3093de05acf1 (diff) | |
download | meson-5df0fb45ca44282e011078b5386831bb4dcbc2ee.zip meson-5df0fb45ca44282e011078b5386831bb4dcbc2ee.tar.gz meson-5df0fb45ca44282e011078b5386831bb4dcbc2ee.tar.bz2 |
unittests: make datatests capable of parsing module subsections properly
We will need to update the tests for each module that gets newly added,
apparently, but the basic structure for doing so is hopefully there.
-rw-r--r-- | unittests/datatests.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/unittests/datatests.py b/unittests/datatests.py index b623f1f..4d4d3a1 100644 --- a/unittests/datatests.py +++ b/unittests/datatests.py @@ -119,12 +119,18 @@ class DataTests(unittest.TestCase): found_entries = set() sections = re.finditer(r"^## (.+)$", md, re.MULTILINE) # Extract the content for this section + u_subcontents = [] content = self._get_section_content("Universal options", sections, md) subsections = tee(re.finditer(r"^### (.+)$", content, re.MULTILINE)) - subcontent1 = self._get_section_content("Directories", subsections[0], content) - subcontent2 = self._get_section_content("Core options", subsections[1], content) - subcontent3 = self._get_section_content("Module options", sections, md) - for subcontent in (subcontent1, subcontent2, subcontent3): + u_subcontents.append(self._get_section_content("Directories", subsections[0], content)) + u_subcontents.append(self._get_section_content("Core options", subsections[1], content)) + + mod_subcontents = [] + content = self._get_section_content("Module options", sections, md) + subsections = tee(re.finditer(r"^### (.+)$", content, re.MULTILINE)) + for idx, mod in enumerate(['Python']): + mod_subcontents.append(self._get_section_content(f'{mod} module', subsections[idx], content)) + for subcontent in u_subcontents + mod_subcontents: # Find the option names options = set() # Match either a table row or a table heading separator: | ------ | @@ -151,9 +157,9 @@ class DataTests(unittest.TestCase): # setting of builtin options behaves # # Find all tables inside this subsection - tables = re.finditer(r"^\| (\w+) .* \|\n\| *[-|\s]+ *\|$", subcontent2, re.MULTILINE) + tables = re.finditer(r"^\| (\w+) .* \|\n\| *[-|\s]+ *\|$", u_subcontents[1], re.MULTILINE) # Get the table we want using the header of the first column - table = self._get_section_content('buildtype', tables, subcontent2) + table = self._get_section_content('buildtype', tables, u_subcontents[1]) # Get table row data rows = re.finditer(r"^\|(?: (\w+)\s+\| (\w+)\s+\| (\w+) .* | *-+ *)\|", table, re.MULTILINE) env = get_fake_env() |