diff options
author | sbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 22:41:47 +0000 |
---|---|---|
committer | sbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 22:41:47 +0000 |
commit | de01fea5b4b26b1ff16bbcfa82027b99dc7641d6 (patch) | |
tree | ec686b123a0638c17f229cad0d6e9e32056f40db /native_client_sdk | |
parent | 62cdf8418c87ee3281ebe9f81a31912c92cac084 (diff) | |
download | chromium_src-de01fea5b4b26b1ff16bbcfa82027b99dc7641d6.zip chromium_src-de01fea5b4b26b1ff16bbcfa82027b99dc7641d6.tar.gz chromium_src-de01fea5b4b26b1ff16bbcfa82027b99dc7641d6.tar.bz2 |
[NaCl SDK] add zip tests to test_all.py
BUG=
Review URL: https://chromiumcodereview.appspot.com/11411246
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170262 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-x | native_client_sdk/src/build_tools/tests/test_all.py | 9 | ||||
-rwxr-xr-x | native_client_sdk/src/tools/oshelpers.py | 12 | ||||
-rwxr-xr-x | native_client_sdk/src/tools/zip_test.py | 19 |
3 files changed, 21 insertions, 19 deletions
diff --git a/native_client_sdk/src/build_tools/tests/test_all.py b/native_client_sdk/src/build_tools/tests/test_all.py index b7216d7..934fc18 100755 --- a/native_client_sdk/src/build_tools/tests/test_all.py +++ b/native_client_sdk/src/build_tools/tests/test_all.py @@ -5,11 +5,18 @@ import sys import unittest +import os + +# add tools folder to sys.path +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +SDK_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR)) +sys.path.append(os.path.join(SDK_DIR, 'tools')) TEST_MODULES = [ + 'zip_test', 'test_sdktools', 'test_sdktools_commands', - 'test_update_nacl_manifest' + 'test_update_nacl_manifest', ] def main(): diff --git a/native_client_sdk/src/tools/oshelpers.py b/native_client_sdk/src/tools/oshelpers.py index fe9f64e..041e9aa 100755 --- a/native_client_sdk/src/tools/oshelpers.py +++ b/native_client_sdk/src/tools/oshelpers.py @@ -457,12 +457,16 @@ FuncMap = { def main(args): - func = FuncMap.get(args[1]) + if not args: + print 'No command specified' + print 'Available commands: %s' % ' '.join(FuncMap) + return 1 + func = FuncMap.get(args[0]) if not func: - print 'Do not recognize command: ' + args[1] + print 'Do not recognize command: ' + args[0] print 'Available commands: %s' % ' '.join(FuncMap) return 1 - return func(args[2:]) + return func(args[1:]) if __name__ == '__main__': - sys.exit(main(sys.argv)) + sys.exit(main(sys.argv[1:])) diff --git a/native_client_sdk/src/tools/zip_test.py b/native_client_sdk/src/tools/zip_test.py index f3c7dd2..66f61bc 100755 --- a/native_client_sdk/src/tools/zip_test.py +++ b/native_client_sdk/src/tools/zip_test.py @@ -3,7 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import doctest import os import oshelpers import shutil @@ -26,18 +25,17 @@ class RunZipError(subprocess.CalledProcessError): msg += '.\nstderr: """%s"""' % (self.error_output,) return msg + def RunZip(args, cwd): - command = [sys.executable, - os.path.join(os.path.dirname(__file__), 'oshelpers.py'), - 'zip'] + args + command = [sys.executable, 'oshelpers.py', 'zip'] + args process = subprocess.Popen(stdout=subprocess.PIPE, stderr=subprocess.PIPE, args=command, cwd=cwd) output, error_output = process.communicate() - retcode = process.poll() + retcode = process.returncode - if retcode != 0: + if retcode: raise RunZipError(retcode, command, output, error_output) return output, error_output @@ -182,12 +180,5 @@ class TestZip(unittest.TestCase): self.assertEqual(len(self.zipfile.namelist()), 3) -def main(): - suite = unittest.TestLoader().loadTestsFromTestCase(TestZip) - suite.addTests(doctest.DocTestSuite(oshelpers)) - result = unittest.TextTestRunner(verbosity=2).run(suite) - return int(not result.wasSuccessful()) - - if __name__ == '__main__': - sys.exit(main()) + unittest.main() |