| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 Google Inc. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """ Unit tests for the ninja.py file. """ | 7 """ Unit tests for the ninja.py file. """ |
| 8 | 8 |
| 9 import gyp.generator.ninja as ninja | 9 import gyp.generator.ninja as ninja |
| 10 import unittest | 10 import unittest |
| 11 import StringIO | 11 import StringIO |
| 12 import sys | 12 import sys |
| 13 import TestCommon | 13 import TestCommon |
| 14 | 14 |
| 15 | 15 |
| 16 class TestPrefixesAndSuffixes(unittest.TestCase): | 16 class TestPrefixesAndSuffixes(unittest.TestCase): |
| 17 if sys.platform in ('win32', 'cygwin'): | 17 if sys.platform in ('win32', 'cygwin'): |
| 18 def test_BinaryNamesWindows(self): | 18 def test_BinaryNamesWindows(self): |
| 19 writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'ninja.build', 'win') | 19 writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'ninja.build', 'win') |
| 20 spec = { 'target_name': 'wee' } | 20 spec = { 'target_name': 'wee' } |
| 21 self.assertTrue(writer.ComputeOutputFileName(spec, 'executable'). | 21 self.assertTrue(writer.ComputeOutputFileName(spec, 'executable'). |
| 22 endswith('.exe')) | 22 endswith('.exe')) |
| 23 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). | 23 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). |
| 24 endswith('.dll')) | 24 endswith('.dll')) |
| 25 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). | 25 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). |
| 26 endswith('.lib')) | 26 endswith('.lib')) |
| 27 self.assertTrue(writer.ComputeOutputFileName(spec, |
| 28 'standalone_static_library'). |
| 29 endswith('.lib')) |
| 27 | 30 |
| 28 if sys.platform == 'linux2': | 31 if sys.platform == 'linux2': |
| 29 def test_BinaryNamesLinux(self): | 32 def test_BinaryNamesLinux(self): |
| 30 writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'ninja.build', 'linux') | 33 writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'ninja.build', 'linux') |
| 31 spec = { 'target_name': 'wee' } | 34 spec = { 'target_name': 'wee' } |
| 32 self.assertTrue('.' not in writer.ComputeOutputFileName(spec, | 35 self.assertTrue('.' not in writer.ComputeOutputFileName(spec, |
| 33 'executable')) | 36 'executable')) |
| 34 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). | 37 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). |
| 35 startswith('lib')) | 38 startswith('lib')) |
| 36 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). | 39 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). |
| 37 startswith('lib')) | 40 startswith('lib')) |
| 38 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). | 41 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). |
| 39 endswith('.so')) | 42 endswith('.so')) |
| 40 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). | 43 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). |
| 41 endswith('.a')) | 44 endswith('.a')) |
| 45 self.assertTrue(writer.ComputeOutputFileName(spec, |
| 46 'standalone_static_library'). |
| 47 endswith('.a')) |
| 42 | 48 |
| 43 if __name__ == '__main__': | 49 if __name__ == '__main__': |
| 44 unittest.main() | 50 unittest.main() |
| OLD | NEW |