Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: build/gyp_chromium_test.py

Issue 896663002: gyp_chromium: Better parsing of -G command line flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/gyp_chromium ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/gyp_chromium_test.py
diff --git a/build/gyp_chromium_test.py b/build/gyp_chromium_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..0c0e479d1c3132366a7cb49d413ed4b02490d79f
--- /dev/null
+++ b/build/gyp_chromium_test.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import sys
+import unittest
+
+SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
+SRC_DIR = os.path.dirname(SCRIPT_DIR)
+
+sys.path.append(os.path.join(SRC_DIR, 'third_party', 'pymock'))
+
+import mock
+
+# TODO(sbc): Make gyp_chromium more testable by putting the code in
+# a .py file.
+gyp_chromium = __import__('gyp_chromium')
scottmg 2015/02/03 02:09:18 there is a .py because it's required on windows fo
Sam Clegg 2015/02/03 02:10:30 Oh yeah! That is funny/strange. Not importable
+
+
+class TestGetOutputDirectory(unittest.TestCase):
+ @mock.patch('os.environ', {})
+ @mock.patch('sys.argv', [__file__])
+ def testDefaultValue(self):
+ self.assertEqual(gyp_chromium.GetOutputDirectory(), 'out')
+
+ @mock.patch('os.environ', {'GYP_GENERATOR_FLAGS': 'output_dir=envfoo'})
+ @mock.patch('sys.argv', [__file__])
+ def testEnvironment(self):
+ self.assertEqual(gyp_chromium.GetOutputDirectory(), 'envfoo')
+
+ @mock.patch('os.environ', {'GYP_GENERATOR_FLAGS': 'output_dir=envfoo'})
+ @mock.patch('sys.argv', [__file__, '-Goutput_dir=cmdfoo'])
+ def testGFlagOverridesEnv(self):
+ self.assertEqual(gyp_chromium.GetOutputDirectory(), 'cmdfoo')
+
+ @mock.patch('os.environ', {})
+ @mock.patch('sys.argv', [__file__, '-G', 'output_dir=foo'])
+ def testGFlagWithSpace(self):
+ self.assertEqual(gyp_chromium.GetOutputDirectory(), 'foo')
+
+
+class TestGetGypVars(unittest.TestCase):
+ @mock.patch('os.environ', {})
+ def testDefault(self):
+ self.assertEqual(gyp_chromium.GetGypVars([]), {})
+
+ @mock.patch('os.environ', {})
+ @mock.patch('sys.argv', [__file__, '-D', 'foo=bar'])
+ def testDFlags(self):
+ self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': 'bar'})
+
+ @mock.patch('os.environ', {})
+ @mock.patch('sys.argv', [__file__, '-D', 'foo'])
+ def testDFlagsNoValue(self):
+ self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': '1'})
+
+ @mock.patch('os.environ', {})
+ @mock.patch('sys.argv', [__file__, '-D', 'foo=bar', '-Dbaz'])
+ def testDFlagMulti(self):
+ self.assertEqual(gyp_chromium.GetGypVars([]), {'foo': 'bar', 'baz': '1'})
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « build/gyp_chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698