Expanded SCons.Scanner.LaTeX.comment_re to not break on \%
[scons.git] / src / engine / SCons / Platform / PlatformTests.py
1 #
2 # __COPYRIGHT__
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #
23
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
25
26 import SCons.compat
27
28 import collections
29 import sys
30 import unittest
31
32 import SCons.Errors
33 import SCons.Platform
34
35 class Environment(collections.UserDict):
36     def Detect(self, cmd):
37         return cmd
38     def AppendENVPath(self, key, value):
39         pass
40
41 class PlatformTestCase(unittest.TestCase):
42     def test_Platform(self):
43         """Test the Platform() function"""
44         p = SCons.Platform.Platform('cygwin')
45         assert str(p) == 'cygwin', p
46         env = Environment()
47         p(env)
48         assert env['PROGSUFFIX'] == '.exe', env
49         assert env['LIBSUFFIX'] == '.a', env
50         assert env['SHELL'] == 'sh', env
51
52         p = SCons.Platform.Platform('os2')
53         assert str(p) == 'os2', p
54         env = Environment()
55         p(env)
56         assert env['PROGSUFFIX'] == '.exe', env
57         assert env['LIBSUFFIX'] == '.lib', env
58
59         p = SCons.Platform.Platform('posix')
60         assert str(p) == 'posix', p
61         env = Environment()
62         p(env)
63         assert env['PROGSUFFIX'] == '', env
64         assert env['LIBSUFFIX'] == '.a', env
65         assert env['SHELL'] == 'sh', env
66
67         p = SCons.Platform.Platform('irix')
68         assert str(p) == 'irix', p
69         env = Environment()
70         p(env)
71         assert env['PROGSUFFIX'] == '', env
72         assert env['LIBSUFFIX'] == '.a', env
73         assert env['SHELL'] == 'sh', env
74
75         p = SCons.Platform.Platform('aix')
76         assert str(p) == 'aix', p
77         env = Environment()
78         p(env)
79         assert env['PROGSUFFIX'] == '', env
80         assert env['LIBSUFFIX'] == '.a', env
81         assert env['SHELL'] == 'sh', env
82
83         p = SCons.Platform.Platform('sunos')
84         assert str(p) == 'sunos', p
85         env = Environment()
86         p(env)
87         assert env['PROGSUFFIX'] == '', env
88         assert env['LIBSUFFIX'] == '.a', env
89         assert env['SHELL'] == 'sh', env
90
91         p = SCons.Platform.Platform('hpux')
92         assert str(p) == 'hpux', p
93         env = Environment()
94         p(env)
95         assert env['PROGSUFFIX'] == '', env
96         assert env['LIBSUFFIX'] == '.a', env
97         assert env['SHELL'] == 'sh', env
98
99         p = SCons.Platform.Platform('win32')
100         assert str(p) == 'win32', p
101         env = Environment()
102         p(env)
103         assert env['PROGSUFFIX'] == '.exe', env
104         assert env['LIBSUFFIX'] == '.lib', env
105         assert str
106
107         try:
108             p = SCons.Platform.Platform('_does_not_exist_')
109         except SCons.Errors.UserError:
110             pass
111         else:
112             raise
113
114         env = Environment()
115         SCons.Platform.Platform()(env)
116         assert env != {}, env
117
118
119 if __name__ == "__main__":
120     suite = unittest.makeSuite(PlatformTestCase, 'test_')
121     if not unittest.TextTestRunner().run(suite).wasSuccessful():
122         sys.exit(1)
123
124 # Local Variables:
125 # tab-width:4
126 # indent-tabs-mode:nil
127 # End:
128 # vim: set expandtab tabstop=4 shiftwidth=4: