forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1313306 - Move --help dependency checks to the linter. r=chmanche…
…ster Missing such dependencies shouldn't impair running configure itself after local modifications, but they are currently required for (mostly) documentation purpose. Which means they are better done in the linter. --HG-- extra : rebase_source : 6bfff2342cda2ed1351f561c9eb9623f1fb4e4c4
- Loading branch information
Showing
5 changed files
with
96 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# 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 | ||
import os | ||
import textwrap | ||
import unittest | ||
|
||
from mozunit import ( | ||
main, | ||
MockedOpen, | ||
) | ||
|
||
from mozbuild.configure import ConfigureError | ||
from mozbuild.configure.lint import LintSandbox | ||
|
||
import mozpack.path as mozpath | ||
|
||
test_data_path = mozpath.abspath(mozpath.dirname(__file__)) | ||
test_data_path = mozpath.join(test_data_path, 'data') | ||
|
||
|
||
class TestLint(unittest.TestCase): | ||
def lint_test(self, options=[], env={}): | ||
sandbox = LintSandbox(env, ['configure'] + options) | ||
|
||
sandbox.run(mozpath.join(test_data_path, 'moz.configure')) | ||
|
||
def moz_configure(self, source): | ||
return MockedOpen({ | ||
os.path.join(test_data_path, | ||
'moz.configure'): textwrap.dedent(source) | ||
}) | ||
|
||
def test_depends_failures(self): | ||
with self.assertRaises(ConfigureError) as e: | ||
with self.moz_configure(''' | ||
option('--foo', help='foo') | ||
@depends('--foo') | ||
def foo(value): | ||
return value | ||
@depends('--help', foo) | ||
def bar(help, foo): | ||
return | ||
'''): | ||
self.lint_test() | ||
|
||
self.assertEquals(e.exception.message, | ||
"`bar` depends on '--help' and `foo`. " | ||
"`foo` must depend on '--help'") | ||
|
||
with self.assertRaises(ConfigureError) as e: | ||
with self.moz_configure(''' | ||
option('--foo', help='foo') | ||
@depends('--foo') | ||
def foo(value): | ||
return value | ||
include(foo) | ||
'''): | ||
self.lint_test() | ||
|
||
self.assertEquals(e.exception.message, | ||
"Missing @depends for `foo`: '--help'") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |