Bug 1313306 - Add a placeholder python configure linter. r=chmanchester

--HG--
extra : rebase_source : d7b17160bbf61e9aca2edfb2874a87182140c144
This commit is contained in:
Mike Hommey 2016-10-27 09:36:33 +09:00
Родитель 9be13f02e3
Коммит e9aa83949b
3 изменённых файлов: 89 добавлений и 0 удалений

Просмотреть файл

@ -37,6 +37,7 @@ PYTHON_UNIT_TESTS += [
'mozbuild/mozbuild/test/backend/test_recursivemake.py',
'mozbuild/mozbuild/test/backend/test_visualstudio.py',
'mozbuild/mozbuild/test/compilation/test_warnings.py',
'mozbuild/mozbuild/test/configure/lint.py',
'mozbuild/mozbuild/test/configure/test_checks_configure.py',
'mozbuild/mozbuild/test/configure/test_compile_checks.py',
'mozbuild/mozbuild/test/configure/test_configure.py',

Просмотреть файл

@ -0,0 +1,23 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
from StringIO import StringIO
from . import ConfigureSandbox
class LintSandbox(ConfigureSandbox):
def __init__(self, environ=None, argv=None, stdout=None, stderr=None):
out = StringIO()
stdout = stdout or out
stderr = stderr or out
environ = environ or {}
argv = argv or []
super(LintSandbox, self).__init__({}, environ=environ, argv=argv,
stdout=stdout, stderr=stderr)
def run(self, path=None):
if path:
self.include_file(path)

Просмотреть файл

@ -0,0 +1,65 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
import os
import unittest
from StringIO import StringIO
from mozunit import main
from buildconfig import (
topobjdir,
topsrcdir,
)
from mozbuild.configure.lint import LintSandbox
test_path = os.path.abspath(__file__)
class LintMeta(type):
def __new__(mcs, name, bases, attrs):
def create_test(project, func):
def test(self):
return func(self, project)
return test
for project in (
'b2g',
'b2g/dev',
'b2g/graphene',
'browser',
'embedding/ios',
'extensions',
'js',
'mobile/android',
):
attrs['test_%s' % project.replace('/', '_')] = create_test(
project, attrs['lint'])
return type.__new__(mcs, name, bases, attrs)
class Lint(unittest.TestCase):
__metaclass__ = LintMeta
def setUp(self):
self._curdir = os.getcwd()
os.chdir(topobjdir)
def tearDown(self):
os.chdir(self._curdir)
def lint(self, project):
sandbox = LintSandbox({
'OLD_CONFIGURE': os.path.join(topsrcdir, 'old-configure'),
'MOZCONFIG': os.path.join(os.path.dirname(test_path), 'data',
'empty_mozconfig'),
}, ['--enable-project=%s' % project])
sandbox.run(os.path.join(topsrcdir, 'moz.configure'))
if __name__ == '__main__':
main()