diff options
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() |