OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS 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 mox | 6 import mox |
7 import os | 7 import os |
8 import prebuilt | 8 import prebuilt |
9 import shutil | 9 import shutil |
10 import tempfile | 10 import tempfile |
11 import unittest | 11 import unittest |
12 from chromite.lib import cros_build_lib | 12 from chromite.lib import cros_build_lib |
13 | 13 |
14 class TestUpdateFile(unittest.TestCase): | 14 class TestUpdateFile(unittest.TestCase): |
15 | 15 |
16 def setUp(self): | 16 def setUp(self): |
17 self.contents_str = ['# comment that should be skipped', | 17 self.contents_str = ['# comment that should be skipped', |
18 'PKGDIR="/var/lib/portage/pkgs"', | 18 'PKGDIR="/var/lib/portage/pkgs"', |
19 'PORTAGE_BINHOST="http://no.thanks.com"', | 19 'PORTAGE_BINHOST="http://no.thanks.com"', |
20 'portage portage-20100310.tar.bz2'] | 20 'portage portage-20100310.tar.bz2', |
| 21 'COMPILE_FLAGS="some_value=some_other"', |
| 22 ] |
21 temp_fd, self.version_file = tempfile.mkstemp() | 23 temp_fd, self.version_file = tempfile.mkstemp() |
22 os.write(temp_fd, '\n'.join(self.contents_str)) | 24 os.write(temp_fd, '\n'.join(self.contents_str)) |
23 os.close(temp_fd) | 25 os.close(temp_fd) |
24 | 26 |
25 def tearDown(self): | 27 def tearDown(self): |
26 os.remove(self.version_file) | 28 os.remove(self.version_file) |
27 | 29 |
28 def _read_version_file(self): | 30 def _read_version_file(self): |
29 """Read the contents of self.version_file and return as a list.""" | 31 """Read the contents of self.version_file and return as a list.""" |
30 version_fh = open(self.version_file) | 32 version_fh = open(self.version_file) |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 temp_packages_file.flush() | 224 temp_packages_file.flush() |
223 new_packages_file = prebuilt.FilterPackagesFile(temp_packages_file.name) | 225 new_packages_file = prebuilt.FilterPackagesFile(temp_packages_file.name) |
224 new_contents = open(new_packages_file.name).read() | 226 new_contents = open(new_packages_file.name).read() |
225 self.assertEqual("".join(private_packages_file), new_contents) | 227 self.assertEqual("".join(private_packages_file), new_contents) |
226 self.assertEqual("".join(private_packages_file), new_packages_file.read()) | 228 self.assertEqual("".join(private_packages_file), new_packages_file.read()) |
227 new_packages_file.close() | 229 new_packages_file.close() |
228 | 230 |
229 | 231 |
230 if __name__ == '__main__': | 232 if __name__ == '__main__': |
231 unittest.main() | 233 unittest.main() |
OLD | NEW |