OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import shutil | 7 import shutil |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 import unittest | 10 import unittest |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 self.patch = mock.patch.dict('os.environ', | 110 self.patch = mock.patch.dict('os.environ', |
111 {'NACL_SDK_ROOT': self.tempdir}) | 111 {'NACL_SDK_ROOT': self.tempdir}) |
112 self.patch.start() | 112 self.patch.start() |
113 | 113 |
114 def tearDown(self): | 114 def tearDown(self): |
115 shutil.rmtree(self.tempdir) | 115 shutil.rmtree(self.tempdir) |
116 self.patch.stop() | 116 self.patch.stop() |
117 | 117 |
118 def testGetSDKVersion(self): | 118 def testGetSDKVersion(self): |
119 """correctly parses README to find SDK version.""" | 119 """correctly parses README to find SDK version.""" |
120 expected_version = (16, '196') | 120 expected_version = (16, '0a1b2c3d') |
121 with open(os.path.join(self.tempdir, 'README'), 'w') as out: | 121 with open(os.path.join(self.tempdir, 'README'), 'w') as out: |
122 out.write('Version: %s\n' % expected_version[0]) | 122 out.write('Version: %s\n' % expected_version[0]) |
123 out.write('Chrome Revision: %s\n' % expected_version[1]) | 123 out.write('Chrome Revision: %s\n' % expected_version[1]) |
124 | 124 |
125 version = getos.GetSDKVersion() | 125 version = getos.GetSDKVersion() |
126 self.assertEqual(version, expected_version) | 126 self.assertEqual(version, expected_version) |
127 | 127 |
128 def testCheckVersion(self): | |
129 """correctly rejects SDK versions earlier than the required one.""" | |
130 actual_version = (16, '0a1b2c3d') | |
binji
2014/08/27 01:05:02
See https://codereview.chromium.org/507883003/
I
Matt Giuca
2014/08/27 01:17:50
Oh OK, cool. I was expecting we would end up with
| |
131 with open(os.path.join(self.tempdir, 'README'), 'w') as out: | |
132 out.write('Version: %s\n' % actual_version[0]) | |
133 out.write('Chrome Revision: %s\n' % actual_version[1]) | |
134 | |
135 required_version = (15, 196) | |
136 getos.CheckVersion(required_version) | |
137 | |
138 # Note: The revision part is currently ignored due to Git; see | |
139 # http://crbug.com/406993. | |
140 required_version = (16, 196) | |
141 getos.CheckVersion(required_version) | |
142 | |
143 required_version = (17, 196) | |
144 self.assertRaisesRegexp( | |
145 getos.Error, | |
146 r'SDK version too old \(current: 16, required: 17\)', | |
147 getos.CheckVersion, | |
148 required_version) | |
149 | |
128 | 150 |
129 if __name__ == '__main__': | 151 if __name__ == '__main__': |
130 unittest.main() | 152 unittest.main() |
OLD | NEW |