Bug 1652503: [mozlint] Use `mozpack.path` for paths in lint tests; r=ahal
authorTom Prince <mozilla@hocat.ca>
Thu, 23 Jul 2020 14:55:55 +0000
changeset 541786 2bf32877d9fc93ea791de94fc38f6ca454d94727
parent 541785 1e61f55a5cd797667adf473f17c4c765b989f7e6
child 541787 6259301066022496a1072f1ac1b9a944a15511ae
push id37633
push userccoroiu@mozilla.com
push dateFri, 24 Jul 2020 09:32:06 +0000
treeherdermozilla-central@141543043270 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1652503
milestone80.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1652503: [mozlint] Use `mozpack.path` for paths in lint tests; r=ahal Differential Revision: https://phabricator.services.mozilla.com/D84645
tools/lint/test/conftest.py
--- a/tools/lint/test/conftest.py
+++ b/tools/lint/test/conftest.py
@@ -4,23 +4,24 @@ import logging
 import os
 import sys
 from collections import defaultdict
 
 from mozbuild.base import MozbuildObject
 from mozlint.pathutils import findobject
 from mozlint.parser import Parser
 from mozlint.result import ResultSummary
+from mozpack import path
 
 import pytest
 
-here = os.path.abspath(os.path.dirname(__file__))
+here = path.abspath(path.dirname(__file__))
 build = MozbuildObject.from_environment(cwd=here)
 
-lintdir = os.path.dirname(here)
+lintdir = path.dirname(here)
 sys.path.insert(0, lintdir)
 logger = logging.getLogger("mozlint")
 
 
 def pytest_generate_tests(metafunc):
     """Finds, loads and returns the config for the linter name specified by the
     LINTER global variable in the calling module.
 
@@ -30,17 +31,17 @@ def pytest_generate_tests(metafunc):
     """
     if "config" in metafunc.fixturenames:
         if not hasattr(metafunc.module, "LINTER"):
             pytest.fail(
                 "'config' fixture used from a module that didn't set the LINTER variable"
             )
 
         name = metafunc.module.LINTER
-        config_path = os.path.join(lintdir, "{}.yml".format(name))
+        config_path = path.join(lintdir, "{}.yml".format(name))
         parser = Parser(build.topsrcdir)
         configs = parser.parse(config_path)
         config_names = {config["name"] for config in configs}
 
         marker = metafunc.definition.get_closest_marker("lint_config")
         if marker:
             config_name = marker.kwargs["name"]
             if config_name not in config_names:
@@ -58,32 +59,32 @@ def root(request):
     """Return the root directory for the files of the linter under test.
 
     For example, with LINTER=flake8 this would be tools/lint/test/files/flake8.
     """
     if not hasattr(request.module, "LINTER"):
         pytest.fail(
             "'root' fixture used from a module that didn't set the LINTER variable"
         )
-    return os.path.join(here, "files", request.module.LINTER)
+    return path.join(here, "files", request.module.LINTER)
 
 
 @pytest.fixture(scope="module")
 def paths(root):
     """Return a function that can resolve file paths relative to the linter
     under test.
 
     Can be used like `paths('foo.py', 'bar/baz')`. This will return a list of
     absolute paths under the `root` files directory.
     """
 
     def _inner(*paths):
         if not paths:
             return [root]
-        return [os.path.normpath(os.path.join(root, p)) for p in paths]
+        return [path.normpath(path.join(root, p)) for p in paths]
 
     return _inner
 
 
 @pytest.fixture(autouse=True)
 def run_setup(config):
     """Make sure that if the linter named in the LINTER global variable has a
     setup function, it gets called before running the tests.