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 def test_BinaryNamesWindows(self): | 17 def test_BinaryNamesWindows(self): |
18 # These cannot run on non-Windows as they require a VS installation to | 18 writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'build.ninja', '.', |
19 # correctly handle variable expansion. | 19 'build.ninja', 'win') |
20 if sys.platform.startswith('win'): | 20 spec = { 'target_name': 'wee' } |
21 writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'build.ninja', '.', | 21 self.assertTrue(writer.ComputeOutputFileName(spec, 'executable'). |
22 'build.ninja', 'win') | 22 endswith('.exe')) |
23 spec = { 'target_name': 'wee' } | 23 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). |
24 self.assertTrue(writer.ComputeOutputFileName(spec, 'executable'). | 24 endswith('.dll')) |
25 endswith('.exe')) | 25 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). |
26 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). | 26 endswith('.lib')) |
27 endswith('.dll')) | |
28 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). | |
29 endswith('.lib')) | |
30 | 27 |
31 def test_BinaryNamesLinux(self): | 28 def test_BinaryNamesLinux(self): |
32 writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'build.ninja', '.', | 29 writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'build.ninja', '.', |
33 'build.ninja', 'linux') | 30 'build.ninja', 'linux') |
34 spec = { 'target_name': 'wee' } | 31 spec = { 'target_name': 'wee' } |
35 self.assertTrue('.' not in writer.ComputeOutputFileName(spec, | 32 self.assertTrue('.' not in writer.ComputeOutputFileName(spec, |
36 'executable')) | 33 'executable')) |
37 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). | 34 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). |
38 startswith('lib')) | 35 startswith('lib')) |
39 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). | 36 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). |
40 startswith('lib')) | 37 startswith('lib')) |
41 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). | 38 self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). |
42 endswith('.so')) | 39 endswith('.so')) |
43 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). | 40 self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). |
44 endswith('.a')) | 41 endswith('.a')) |
45 | 42 |
46 if __name__ == '__main__': | 43 if __name__ == '__main__': |
47 unittest.main() | 44 unittest.main() |
OLD | NEW |