1#!/usr/bin/env python
2
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
5# found in the LICENSE file.
6
7""" Unit tests for the ninja.py file. """
8
9import gyp.generator.ninja as ninja
10import unittest
11import StringIO
12import sys
13import TestCommon
14
15
16class TestPrefixesAndSuffixes(unittest.TestCase):
17  def test_BinaryNamesWindows(self):
18    writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'build.ninja', '.',
19        'build.ninja', 'win')
20    spec = { 'target_name': 'wee' }
21    self.assertTrue(writer.ComputeOutputFileName(spec, 'executable').
22        endswith('.exe'))
23    self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library').
24        endswith('.dll'))
25    self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library').
26        endswith('.lib'))
27
28  def test_BinaryNamesLinux(self):
29    writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'build.ninja', '.',
30        'build.ninja', 'linux')
31    spec = { 'target_name': 'wee' }
32    self.assertTrue('.' not in writer.ComputeOutputFileName(spec,
33                                                            'executable'))
34    self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library').
35        startswith('lib'))
36    self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library').
37        startswith('lib'))
38    self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library').
39        endswith('.so'))
40    self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library').
41        endswith('.a'))
42
43if __name__ == '__main__':
44  unittest.main()
45