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 re | 7 import re |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import tarfile | 10 import tarfile |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 archive = manifest_util.Archive('all') | 105 archive = manifest_util.Archive('all') |
106 archive.url = self.server.GetURL('%s/sdk_tools.tgz' % (rel_path,)) | 106 archive.url = self.server.GetURL('%s/sdk_tools.tgz' % (rel_path,)) |
107 archive.checksum = archive_sha1 | 107 archive.checksum = archive_sha1 |
108 archive.size = archive_size | 108 archive.size = archive_size |
109 return archive | 109 return archive |
110 | 110 |
111 def _Run(self, args): | 111 def _Run(self, args): |
112 naclsdk_shell_script = os.path.join(self.basedir, 'nacl_sdk', 'naclsdk') | 112 naclsdk_shell_script = os.path.join(self.basedir, 'nacl_sdk', 'naclsdk') |
113 if getos.GetPlatform() == 'win': | 113 if getos.GetPlatform() == 'win': |
114 naclsdk_shell_script += '.bat' | 114 naclsdk_shell_script += '.bat' |
115 cmd = [naclsdk_shell_script, '-U', self.server.GetURL(MANIFEST_BASENAME)] | 115 cmd = [naclsdk_shell_script] |
116 cmd.extend(args) | 116 cmd.extend(args) |
| 117 cmd.extend(['-U', self.server.GetURL(MANIFEST_BASENAME)]) |
117 process = subprocess.Popen(cmd, stdout=subprocess.PIPE) | 118 process = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
118 stdout, _ = process.communicate() | 119 stdout, _ = process.communicate() |
119 self.assertEqual(process.returncode, 0) | 120 self.assertEqual(process.returncode, 0) |
120 return stdout | 121 return stdout |
121 | 122 |
122 def _RunAndExtractRevision(self): | 123 def _RunAndExtractRevision(self): |
123 stdout = self._Run(['-v']) | 124 stdout = self._Run(['version']) |
124 match = re.search('version r(\d+)', stdout) | 125 match = re.search('version r(\d+)', stdout) |
125 self.assertTrue(match is not None) | 126 self.assertTrue(match is not None) |
126 return int(match.group(1)) | 127 return int(match.group(1)) |
127 | 128 |
128 | 129 |
129 class TestSdkTools(SdkToolsTestCase): | 130 class TestSdkTools(SdkToolsTestCase): |
130 def testPathHasSpaces(self): | 131 def testPathHasSpaces(self): |
131 """Test that running naclsdk from a path with spaces works.""" | 132 """Test that running naclsdk from a path with spaces works.""" |
132 self.SetupWithBaseDirPrefix('sdk tools') | 133 self.SetupWithBaseDirPrefix('sdk tools') |
133 self._WriteManifest() | 134 self._WriteManifest() |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 If the sdk_tools bundle was updated normally (i.e. the old way), it would | 189 If the sdk_tools bundle was updated normally (i.e. the old way), it would |
189 leave a sdk_tools_update folder that would then be copied over on a | 190 leave a sdk_tools_update folder that would then be copied over on a |
190 subsequent run. This test ensures that there is no folder made. | 191 subsequent run. This test ensures that there is no folder made. |
191 """ | 192 """ |
192 new_revision = self.current_revision + 1 | 193 new_revision = self.current_revision + 1 |
193 archive = self._BuildUpdaterArchive('new', new_revision) | 194 archive = self._BuildUpdaterArchive('new', new_revision) |
194 self.sdk_tools_bundle.AddArchive(archive) | 195 self.sdk_tools_bundle.AddArchive(archive) |
195 self.sdk_tools_bundle.revision = new_revision | 196 self.sdk_tools_bundle.revision = new_revision |
196 self._WriteManifest() | 197 self._WriteManifest() |
197 | 198 |
| 199 sdk_tools_update_dir = os.path.join(self.basedir, 'nacl_sdk', |
| 200 'sdk_tools_update') |
| 201 self.assertFalse(os.path.exists(sdk_tools_update_dir)) |
198 stdout = self._Run(['update', 'sdk_tools']) | 202 stdout = self._Run(['update', 'sdk_tools']) |
199 self.assertTrue(stdout.find('Ignoring manual update request.') != -1) | 203 self.assertTrue(stdout.find('Ignoring manual update request.') != -1) |
200 sdk_tools_update_dir = os.path.join(self.basedir, 'nacl_sdk', | |
201 'sdk_tools_update') | |
202 self.assertFalse(os.path.exists(sdk_tools_update_dir)) | 204 self.assertFalse(os.path.exists(sdk_tools_update_dir)) |
203 | 205 |
204 | 206 |
205 class TestAutoUpdateSdkToolsDifferentFilesystem(TestAutoUpdateSdkTools): | 207 class TestAutoUpdateSdkToolsDifferentFilesystem(TestAutoUpdateSdkTools): |
206 def setUp(self): | 208 def setUp(self): |
207 # On Linux (on my machine at least), /tmp is a different filesystem than | 209 # On Linux (on my machine at least), /tmp is a different filesystem than |
208 # the current directory. os.rename fails when the source and destination | 210 # the current directory. os.rename fails when the source and destination |
209 # are on different filesystems. Test that case here. | 211 # are on different filesystems. Test that case here. |
210 self.SetupWithBaseDirPrefix('sdktools', tmpdir='.') | 212 self.SetupWithBaseDirPrefix('sdktools', tmpdir='.') |
211 | 213 |
212 | 214 |
213 def main(): | 215 def main(): |
214 suite = unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]) | 216 unittest.main() |
215 result = unittest.TextTestRunner(verbosity=2).run(suite) | |
216 | |
217 return int(not result.wasSuccessful()) | |
218 | 217 |
219 if __name__ == '__main__': | 218 if __name__ == '__main__': |
220 sys.exit(main()) | 219 sys.exit(main()) |
OLD | NEW |