Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: native_client_sdk/src/build_tools/tests/test_sdktools.py

Issue 11228013: [NaCl SDK] Refactor sdk_update*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests pass Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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)])
Sam Clegg 2012/10/22 22:55:30 So does '-U' first no longer work?
binji 2012/10/23 00:14:09 No, it is a breaking change. But in some ways I th
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 205
205 class TestAutoUpdateSdkToolsDifferentFilesystem(TestAutoUpdateSdkTools): 206 class TestAutoUpdateSdkToolsDifferentFilesystem(TestAutoUpdateSdkTools):
206 def setUp(self): 207 def setUp(self):
207 # On Linux (on my machine at least), /tmp is a different filesystem than 208 # 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 209 # the current directory. os.rename fails when the source and destination
209 # are on different filesystems. Test that case here. 210 # are on different filesystems. Test that case here.
210 self.SetupWithBaseDirPrefix('sdktools', tmpdir='.') 211 self.SetupWithBaseDirPrefix('sdktools', tmpdir='.')
211 212
212 213
213 def main(): 214 def main():
214 suite = unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]) 215 unittest.main()
215 result = unittest.TextTestRunner(verbosity=2).run(suite)
216
217 return int(not result.wasSuccessful())
218 216
219 if __name__ == '__main__': 217 if __name__ == '__main__':
220 sys.exit(main()) 218 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698