| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) | 10 SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) |
| 11 SRC_DIR = os.path.dirname(SCRIPT_DIR) | 11 SRC_DIR = os.path.dirname(SCRIPT_DIR) |
| 12 | 12 |
| 13 sys.path.append(os.path.join(SRC_DIR, 'third_party', 'pymock')) | 13 sys.path.append(os.path.join(SRC_DIR, 'third_party', 'pymock')) |
| 14 | 14 |
| 15 import mock | 15 import mock |
| 16 | 16 |
| 17 # TODO(sbc): Make gyp_chromium more testable by putting the code in | 17 import gyp_chromium |
| 18 # a .py file. | |
| 19 gyp_chromium = __import__('gyp_chromium') | |
| 20 | 18 |
| 21 | 19 |
| 22 class TestGetOutputDirectory(unittest.TestCase): | 20 class TestGetOutputDirectory(unittest.TestCase): |
| 23 @mock.patch('os.environ', {}) | 21 @mock.patch('os.environ', {}) |
| 24 @mock.patch('sys.argv', [__file__]) | 22 @mock.patch('sys.argv', [__file__]) |
| 25 def testDefaultValue(self): | 23 def testDefaultValue(self): |
| 26 self.assertEqual(gyp_chromium.GetOutputDirectory(), 'out') | 24 self.assertEqual(gyp_chromium.GetOutputDirectory(), 'out') |
| 27 | 25 |
| 28 @mock.patch('os.environ', {'GYP_GENERATOR_FLAGS': 'output_dir=envfoo'}) | 26 @mock.patch('os.environ', {'GYP_GENERATOR_FLAGS': 'output_dir=envfoo'}) |
| 29 @mock.patch('sys.argv', [__file__]) | 27 @mock.patch('sys.argv', [__file__]) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 57 self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': '1'}) | 55 self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': '1'}) |
| 58 | 56 |
| 59 @mock.patch('os.environ', {}) | 57 @mock.patch('os.environ', {}) |
| 60 @mock.patch('sys.argv', [__file__, '-D', 'foo=bar', '-Dbaz']) | 58 @mock.patch('sys.argv', [__file__, '-D', 'foo=bar', '-Dbaz']) |
| 61 def testDFlagMulti(self): | 59 def testDFlagMulti(self): |
| 62 self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': 'bar', 'baz': '1'}) | 60 self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': 'bar', 'baz': '1'}) |
| 63 | 61 |
| 64 | 62 |
| 65 if __name__ == '__main__': | 63 if __name__ == '__main__': |
| 66 unittest.main() | 64 unittest.main() |
| OLD | NEW |