mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1890589 - Fix toml linter to remove 'lineno' lines and adjust the manifest test r=perftest-reviewers,sparky
Differential Revision: https://phabricator.services.mozilla.com/D207290
This commit is contained in:
parent
4d65070f63
commit
4316e4e403
@ -30,6 +30,7 @@ def read_ini(
|
||||
strict=True,
|
||||
handle_defaults=True,
|
||||
document=False,
|
||||
add_line_no=False,
|
||||
):
|
||||
"""
|
||||
read an .ini file and return a list of [(section, values)]
|
||||
@ -40,6 +41,7 @@ def read_ini(
|
||||
- separators : strings that denote key, value separation in order
|
||||
- strict : whether to be strict about parsing
|
||||
- handle_defaults : whether to incorporate defaults into each section
|
||||
- add_line_no: whether to include the line number that points to the test in the generated ini file.
|
||||
"""
|
||||
|
||||
# variables
|
||||
|
@ -56,6 +56,7 @@ class ManifestParser(object):
|
||||
handle_defaults=True,
|
||||
use_toml=True,
|
||||
document=False,
|
||||
add_line_no=False,
|
||||
):
|
||||
"""Creates a ManifestParser from the given manifest files.
|
||||
|
||||
@ -82,6 +83,7 @@ class ManifestParser(object):
|
||||
variable in this case.
|
||||
:param use_toml: If True *.toml configration files will be used iff present in the same location as *.ini files (applies to included files as well). If False only *.ini files will be considered. (defaults to True)
|
||||
:param document: If True *.toml configration will preserve the parsed document from `tomlkit` in self.source_documents[filename] (defaults to False)
|
||||
:param add_line_no: If True, the *.toml configuration will add the line number where the test name appears in the file to the parsed document. Also, the document should be set to True. (defaults to False)
|
||||
"""
|
||||
self._defaults = defaults or {}
|
||||
self.tests = []
|
||||
@ -95,6 +97,7 @@ class ManifestParser(object):
|
||||
self._handle_defaults = handle_defaults
|
||||
self.use_toml = use_toml
|
||||
self.document = document
|
||||
self.add_line_no = add_line_no
|
||||
self.logger = Logger()
|
||||
if manifests:
|
||||
self.read(*manifests)
|
||||
@ -229,6 +232,7 @@ class ManifestParser(object):
|
||||
strict=self.strict,
|
||||
handle_defaults=self._handle_defaults,
|
||||
document=self.document,
|
||||
add_line_no=self.add_line_no,
|
||||
)
|
||||
if filename is not None:
|
||||
self.source_documents[filename] = document
|
||||
|
@ -82,6 +82,7 @@ def read_toml(
|
||||
strict=True,
|
||||
handle_defaults=True,
|
||||
document=False,
|
||||
add_line_no=False,
|
||||
):
|
||||
"""
|
||||
read a .toml file and return a list of [(section, values)]
|
||||
@ -93,6 +94,7 @@ def read_toml(
|
||||
- strict : whether to be strict about parsing
|
||||
- handle_defaults : whether to incorporate defaults into each section
|
||||
- document: read TOML with tomlkit and return source in test["document"]
|
||||
- add_line_no: add the line number where the test name appears in the file to the source. Also, the document variable must be set to True for this flag to work. (This is used only to generate the documentation)
|
||||
"""
|
||||
|
||||
# variables
|
||||
@ -163,12 +165,12 @@ def read_toml(
|
||||
# merge combined defaults into each section
|
||||
sections = [(i, combine_fields(defaults, j)) for i, j in sections]
|
||||
|
||||
if document:
|
||||
if document and add_line_no:
|
||||
# Take the line where the test name appears in the file.
|
||||
for i, _ in enumerate(sections):
|
||||
line = contents.split(sections[i][0])[0].count(os.linesep) + 1
|
||||
manifest.setdefault(sections[i][0], {})["lineno"] = str(line)
|
||||
else:
|
||||
elif not document:
|
||||
manifest = None
|
||||
|
||||
return sections, defaults, manifest
|
||||
|
@ -5,7 +5,6 @@
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
@ -621,12 +620,6 @@ yellow = submarine
|
||||
after = "edit-manifest-after.toml"
|
||||
after_path = os.path.join(here, after)
|
||||
after_str = open(after_path, "r", encoding="utf-8").read()
|
||||
|
||||
# Define the regex pattern to match lines containing 'lineno'
|
||||
pattern = re.compile(r"^.*lineno.*$\n?", re.MULTILINE)
|
||||
# Remove lines containing 'lineno'
|
||||
manifest_str = re.sub(pattern, "", manifest_str)
|
||||
|
||||
assert manifest_str == after_str
|
||||
|
||||
|
||||
|
@ -3,32 +3,22 @@
|
||||
["test_arithmetic.js"]
|
||||
|
||||
# I think this can be re-enabled when we implement https://bugzilla.mozilla.org/show_bug.cgi?id=1888668
|
||||
lineno = "3"
|
||||
|
||||
["test_callbacks.js"]
|
||||
disabled = "Temporarily disabled until we can re-enable callback support"
|
||||
lineno = "8"
|
||||
|
||||
["test_custom_types.js"]
|
||||
lineno = "12"
|
||||
|
||||
["test_external_types.js"]
|
||||
lineno = "15"
|
||||
|
||||
["test_geometry.js"]
|
||||
lineno = "18"
|
||||
|
||||
["test_refcounts.js"]
|
||||
lineno = "21"
|
||||
|
||||
["test_rondpoint.js"]
|
||||
lineno = "24"
|
||||
|
||||
["test_sprites.js"]
|
||||
lineno = "27"
|
||||
|
||||
["test_todolist.js"]
|
||||
lineno = "30"
|
||||
|
||||
["test_type_checking.js"]
|
||||
lineno = "33"
|
||||
|
@ -206,7 +206,9 @@ class RaptorGatherer(FrameworkGatherer):
|
||||
:return list: the list of the tests
|
||||
"""
|
||||
desc_exclusion = ["here", "manifest_relpath", "path", "relpath"]
|
||||
test_manifest = TestManifest([str(manifest_path)], strict=False, document=True)
|
||||
test_manifest = TestManifest(
|
||||
[str(manifest_path)], strict=False, document=True, add_line_no=True
|
||||
)
|
||||
test_list = test_manifest.active_tests(exists=False, disabled=False)
|
||||
subtests = {}
|
||||
for subtest in test_list:
|
||||
|
Loading…
Reference in New Issue
Block a user