| 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 sys | 7 import sys |
| 8 import re | 8 import re |
| 9 import tarfile | 9 import tarfile |
| 10 import tempfile | 10 import tempfile |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 self.assertTrue('pepper_26_more' in output) | 112 self.assertTrue('pepper_26_more' in output) |
| 113 | 113 |
| 114 def testListBasic(self): | 114 def testListBasic(self): |
| 115 """The list command should display basic information about remote | 115 """The list command should display basic information about remote |
| 116 bundles.""" | 116 bundles.""" |
| 117 self._WriteManifest() | 117 self._WriteManifest() |
| 118 output = self._Run(['list']) | 118 output = self._Run(['list']) |
| 119 self.assertTrue(re.search('I.*?sdk_tools.*?stable', output, re.MULTILINE)) | 119 self.assertTrue(re.search('I.*?sdk_tools.*?stable', output, re.MULTILINE)) |
| 120 # This line is important (it's used by the updater to determine if the | 120 # This line is important (it's used by the updater to determine if the |
| 121 # sdk_tools bundle needs to be updated), so let's be explicit. | 121 # sdk_tools bundle needs to be updated), so let's be explicit. |
| 122 self.assertTrue('All installed bundles are up-to-date.') | 122 self.assertTrue('All installed bundles are up to date.') |
| 123 | 123 |
| 124 def testListMultiple(self): | 124 def testListMultiple(self): |
| 125 """The list command should display multiple bundles.""" | 125 """The list command should display multiple bundles.""" |
| 126 self._AddDummyBundle(self.manifest, 'pepper_23') | 126 self._AddDummyBundle(self.manifest, 'pepper_23') |
| 127 self._WriteManifest() | 127 self._WriteManifest() |
| 128 output = self._Run(['list']) | 128 output = self._Run(['list']) |
| 129 # Added pepper_23 to the remote manifest not the local manifest, so it | 129 # Added pepper_23 to the remote manifest not the local manifest, so it |
| 130 # shouldn't be installed. | 130 # shouldn't be installed. |
| 131 self.assertTrue(re.search('^[^I]*pepper_23', output, re.MULTILINE)) | 131 self.assertTrue(re.search('^[^I]*pepper_23', output, re.MULTILINE)) |
| 132 self.assertTrue('sdk_tools' in output) | 132 self.assertTrue('sdk_tools' in output) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 """The update command should update if the bundle directory does not exist, | 200 """The update command should update if the bundle directory does not exist, |
| 201 even if the bundle is already in the cache manifest.""" | 201 even if the bundle is already in the cache manifest.""" |
| 202 self._AddDummyBundle(self.manifest, 'pepper_23') | 202 self._AddDummyBundle(self.manifest, 'pepper_23') |
| 203 self._WriteCacheManifest(self.manifest) | 203 self._WriteCacheManifest(self.manifest) |
| 204 self._WriteManifest() | 204 self._WriteManifest() |
| 205 self._Run(['update', 'pepper_23']) | 205 self._Run(['update', 'pepper_23']) |
| 206 self.assertTrue(os.path.exists( | 206 self.assertTrue(os.path.exists( |
| 207 os.path.join(self.basedir, 'nacl_sdk', 'pepper_23', 'dummy.txt'))) | 207 os.path.join(self.basedir, 'nacl_sdk', 'pepper_23', 'dummy.txt'))) |
| 208 | 208 |
| 209 def testUpdateNoNewVersion(self): | 209 def testUpdateNoNewVersion(self): |
| 210 """The update command should do nothing if the bundle is already up-to-date. | 210 """The update command should do nothing if the bundle is already up to date. |
| 211 """ | 211 """ |
| 212 self._AddDummyBundle(self.manifest, 'pepper_23') | 212 self._AddDummyBundle(self.manifest, 'pepper_23') |
| 213 self._WriteManifest() | 213 self._WriteManifest() |
| 214 self._Run(['update', 'pepper_23']) | 214 self._Run(['update', 'pepper_23']) |
| 215 output = self._Run(['update', 'pepper_23']) | 215 output = self._Run(['update', 'pepper_23']) |
| 216 self.assertTrue('is already up-to-date.' in output) | 216 self.assertTrue('is already up to date.' in output) |
| 217 | 217 |
| 218 def testUpdateWithNewVersion(self): | 218 def testUpdateWithNewVersion(self): |
| 219 """The update command should update to a new version if it exists.""" | 219 """The update command should update to a new version if it exists.""" |
| 220 bundle = self._AddDummyBundle(self.manifest, 'pepper_23') | 220 bundle = self._AddDummyBundle(self.manifest, 'pepper_23') |
| 221 self._WriteManifest() | 221 self._WriteManifest() |
| 222 self._Run(['update', 'pepper_23']) | 222 self._Run(['update', 'pepper_23']) |
| 223 | 223 |
| 224 bundle.revision += 1 | 224 bundle.revision += 1 |
| 225 self._WriteManifest() | 225 self._WriteManifest() |
| 226 output = self._Run(['update', 'pepper_23']) | 226 output = self._Run(['update', 'pepper_23']) |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 self._WriteConfig('{ "cache_max": 0 }') | 466 self._WriteConfig('{ "cache_max": 0 }') |
| 467 self._AddDummyBundle(self.manifest, 'pepper_23') | 467 self._AddDummyBundle(self.manifest, 'pepper_23') |
| 468 self._WriteManifest() | 468 self._WriteManifest() |
| 469 self._Run(['update', 'pepper_23']) | 469 self._Run(['update', 'pepper_23']) |
| 470 archive_cache = os.path.join(self.cache_dir, 'archives') | 470 archive_cache = os.path.join(self.cache_dir, 'archives') |
| 471 # Archive folder should be completely remove by cache cleanup | 471 # Archive folder should be completely remove by cache cleanup |
| 472 self.assertFalse(os.path.exists(archive_cache)) | 472 self.assertFalse(os.path.exists(archive_cache)) |
| 473 | 473 |
| 474 if __name__ == '__main__': | 474 if __name__ == '__main__': |
| 475 unittest.main() | 475 unittest.main() |
| OLD | NEW |