summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
l---------cbuildbot/archive_lib_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/archive_lib_unittest.py13
l---------cbuildbot/cbuildbot_config_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/cbuildbot_config_unittest.py9
l---------cbuildbot/cbuildbot_run_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/cbuildbot_run_unittest.py17
l---------cbuildbot/cbuildbot_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/cbuildbot_unittest.py10
l---------cbuildbot/chroot_lib_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/chroot_lib_unittest.py7
l---------cbuildbot/commands_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/commands_unittest.py15
l---------cbuildbot/failures_lib_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/failures_lib_unittest.py9
l---------cbuildbot/lab_status_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/lab_status_unittest.py12
l---------cbuildbot/lkgm_manager_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/lkgm_manager_unittest.py16
l---------cbuildbot/manifest_version_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/manifest_version_unittest.py11
l---------cbuildbot/metadata_lib_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/metadata_lib_unittest.py9
l---------cbuildbot/prebuilts_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/prebuilts_unittest.py15
-rw-r--r--cbuildbot/remote_try.py4
l---------cbuildbot/remote_try_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/remote_try_unittest.py9
l---------cbuildbot/repository_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/repository_unittest.py9
-rw-r--r--cbuildbot/run_tests.py50
l---------cbuildbot/run_tests_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/run_tests_unittest.py30
l---------cbuildbot/stages/artifact_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/artifact_stages_unittest.py12
l---------cbuildbot/stages/branch_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/branch_stages_unittest.py7
l---------cbuildbot/stages/build_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/build_stages_unittest.py7
l---------cbuildbot/stages/chrome_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/chrome_stages_unittest.py12
l---------cbuildbot/stages/completion_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/completion_stages_unittest.py13
l---------cbuildbot/stages/generic_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/generic_stages_unittest.py11
l---------cbuildbot/stages/release_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/release_stages_unittest.py14
l---------cbuildbot/stages/report_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/report_stages_unittest.py14
l---------cbuildbot/stages/sdk_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/sdk_stages_unittest.py8
l---------cbuildbot/stages/stage_results_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/stage_results_unittest.py13
l---------cbuildbot/stages/sync_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/sync_stages_unittest.py13
l---------cbuildbot/stages/test_stages_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/stages/test_stages_unittest.py14
l---------cbuildbot/tree_status_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/tree_status_unittest.py13
l---------cbuildbot/triage_lib_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/triage_lib_unittest.py13
l---------cbuildbot/trybot_patch_pool_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/trybot_patch_pool_unittest.py11
l---------cbuildbot/validation_pool_unittest1
-rw-r--r--[-rwxr-xr-x]cbuildbot/validation_pool_unittest.py13
l---------cros/commands/cros_bootstrap_overlay_unittest1
-rw-r--r--[-rwxr-xr-x]cros/commands/cros_bootstrap_overlay_unittest.py9
l---------cros/commands/cros_build_unittest1
-rw-r--r--[-rwxr-xr-x]cros/commands/cros_build_unittest.py13
l---------cros/commands/cros_chrome_sdk_unittest1
-rw-r--r--[-rwxr-xr-x]cros/commands/cros_chrome_sdk_unittest.py7
l---------cros/commands/cros_flash_unittest1
-rw-r--r--[-rwxr-xr-x]cros/commands/cros_flash_unittest.py7
l---------cros/commands/cros_image_unittest1
-rw-r--r--[-rwxr-xr-x]cros/commands/cros_image_unittest.py8
l---------cros/commands/cros_lint_unittest1
-rw-r--r--[-rwxr-xr-x]cros/commands/cros_lint_unittest.py9
l---------cros/commands/init_unittest1
-rw-r--r--[-rwxr-xr-x]cros/commands/init_unittest.py9
l---------cros/commands/lint_unittest1
-rw-r--r--[-rwxr-xr-x]cros/commands/lint_unittest.py9
l---------cros/init_unittest1
-rw-r--r--[-rwxr-xr-x]cros/init_unittest.py9
-rw-r--r--[-rwxr-xr-x]cros/tests/cros_vm_test.py1
l---------lib/alerts_unittest1
-rw-r--r--[-rwxr-xr-x]lib/alerts_unittest.py10
l---------lib/binpkg_unittest1
-rw-r--r--[-rwxr-xr-x]lib/binpkg_unittest.py9
l---------lib/cache_unittest1
-rw-r--r--[-rwxr-xr-x]lib/cache_unittest.py13
l---------lib/cgroups_unittest1
-rw-r--r--[-rwxr-xr-x]lib/cgroups_unittest.py10
l---------lib/chrome_util_unittest1
-rw-r--r--[-rwxr-xr-x]lib/chrome_util_unittest.py8
l---------lib/cidb_integration_test1
-rw-r--r--[-rwxr-xr-x]lib/cidb_integration_test.py14
l---------lib/cidb_setup_unittest1
-rw-r--r--[-rwxr-xr-x]lib/cidb_setup_unittest.py12
l---------lib/clactions_unittest1
-rw-r--r--[-rwxr-xr-x]lib/clactions_unittest.py10
l---------lib/commandline_unittest1
-rw-r--r--[-rwxr-xr-x]lib/commandline_unittest.py7
l---------lib/cros_build_lib_unittest1
-rw-r--r--[-rwxr-xr-x]lib/cros_build_lib_unittest.py15
-rw-r--r--lib/cros_test_lib.py13
l---------lib/cros_test_lib_unittest1
-rw-r--r--[-rwxr-xr-x]lib/cros_test_lib_unittest.py16
-rw-r--r--lib/dev_server_wrapper_stress_test.py1
l---------lib/filetype_unittest1
-rw-r--r--[-rwxr-xr-x]lib/filetype_unittest.py10
l---------lib/gclient_unittest1
-rw-r--r--[-rwxr-xr-x]lib/gclient_unittest.py9
l---------lib/gdata_lib_unittest1
-rw-r--r--[-rwxr-xr-x]lib/gdata_lib_unittest.py11
l---------lib/gerrit_unittest1
-rw-r--r--[-rwxr-xr-x]lib/gerrit_unittest.py12
l---------lib/git_unittest1
-rw-r--r--[-rwxr-xr-x]lib/git_unittest.py12
l---------lib/gob_util_unittest1
-rw-r--r--[-rwxr-xr-x]lib/gob_util_unittest.py12
l---------lib/gs_unittest1
-rw-r--r--[-rwxr-xr-x]lib/gs_unittest.py13
l---------lib/loas_unittest1
-rw-r--r--[-rwxr-xr-x]lib/loas_unittest.py9
l---------lib/namespaces_unittest1
-rw-r--r--[-rwxr-xr-x]lib/namespaces_unittest.py8
l---------lib/osutils_unittest1
-rw-r--r--[-rwxr-xr-x]lib/osutils_unittest.py12
l---------lib/parallel_unittest1
-rw-r--r--[-rwxr-xr-x]lib/parallel_unittest.py11
l---------lib/parseelf_unittest1
-rw-r--r--[-rwxr-xr-x]lib/parseelf_unittest.py9
l---------lib/partial_mock_unittest1
-rw-r--r--[-rwxr-xr-x]lib/partial_mock_unittest.py12
l---------lib/patch_unittest1
-rw-r--r--[-rwxr-xr-x]lib/patch_unittest.py11
l---------lib/perf_uploader_unittest1
-rw-r--r--[-rwxr-xr-x]lib/perf_uploader_unittest.py7
l---------lib/portage_util_unittest1
-rw-r--r--[-rwxr-xr-x]lib/portage_util_unittest.py8
l---------lib/process_util_unittest1
-rw-r--r--[-rwxr-xr-x]lib/process_util_unittest.py9
l---------lib/remote_access_unittest1
-rw-r--r--[-rwxr-xr-x]lib/remote_access_unittest.py10
l---------lib/retry_stats_unittest1
-rw-r--r--[-rwxr-xr-x]lib/retry_stats_unittest.py10
l---------lib/stats_unittest1
-rw-r--r--[-rwxr-xr-x]lib/stats_unittest.py8
l---------lib/table_unittest1
-rw-r--r--[-rwxr-xr-x]lib/table_unittest.py7
l---------lib/timeout_util_unittest1
-rw-r--r--[-rwxr-xr-x]lib/timeout_util_unittest.py10
-rw-r--r--lib/tracker_access.py3
l---------lib/upgrade_table_unittest1
-rw-r--r--[-rwxr-xr-x]lib/upgrade_table_unittest.py10
l---------scripts/autotest_quickmerge_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/autotest_quickmerge_unittest.py11
l---------scripts/cbuildbot_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cbuildbot_unittest.py11
l---------scripts/cbuildbot_view_config_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cbuildbot_view_config_unittest.py9
l---------scripts/check_gdata_token_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/check_gdata_token_unittest.py7
l---------scripts/cros_best_revision_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_best_revision_unittest.py10
l---------scripts/cros_generate_breakpad_symbols_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_generate_breakpad_symbols_unittest.py13
l---------scripts/cros_generate_sysroot_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_generate_sysroot_unittest.py13
l---------scripts/cros_install_debug_syms_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_install_debug_syms_unittest.py9
l---------scripts/cros_list_modified_packages_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_list_modified_packages_unittest.py10
l---------scripts/cros_list_overlays_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_list_overlays_unittest.py9
l---------scripts/cros_mark_as_stable_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_mark_as_stable_unittest.py14
l---------scripts/cros_mark_chrome_as_stable_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_mark_chrome_as_stable_unittest.py13
l---------scripts/cros_mark_mojo_as_stable_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_mark_mojo_as_stable_unittest.py10
l---------scripts/cros_portage_upgrade_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_portage_upgrade_unittest.py8
l---------scripts/cros_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/cros_unittest.py9
l---------scripts/dep_tracker_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/dep_tracker_unittest.py8
l---------scripts/deploy_chrome_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/deploy_chrome_unittest.py15
l---------scripts/gather_builder_stats_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/gather_builder_stats_unittest.py11
l---------scripts/generate_delta_sysroot_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/generate_delta_sysroot_unittest.py9
l---------scripts/merge_package_status_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/merge_package_status_unittest.py8
l---------scripts/pushimage_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/pushimage_unittest.py8
l---------scripts/sync_package_status_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/sync_package_status_unittest.py10
l---------scripts/test_image_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/test_image_unittest.py7
l---------scripts/upload_command_stats_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/upload_command_stats_unittest.py7
l---------scripts/upload_package_status_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/upload_package_status_unittest.py9
l---------scripts/upload_prebuilts_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/upload_prebuilts_unittest.py11
l---------scripts/upload_symbols_unittest1
-rw-r--r--[-rwxr-xr-x]scripts/upload_symbols_unittest.py11
208 files changed, 220 insertions, 1036 deletions
diff --git a/cbuildbot/archive_lib_unittest b/cbuildbot/archive_lib_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/archive_lib_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/archive_lib_unittest.py b/cbuildbot/archive_lib_unittest.py
index ac9670b03..eb7f3ff06 100755..100644
--- a/cbuildbot/archive_lib_unittest.py
+++ b/cbuildbot/archive_lib_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,18 +6,14 @@
from __future__ import print_function
-import logging
-import os
-import sys
+import mock
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import archive_lib
from chromite.cbuildbot import cbuildbot_config
from chromite.cbuildbot import cbuildbot_run
from chromite.lib import cros_test_lib
from chromite.lib import parallel_unittest
-import mock
DEFAULT_ARCHIVE_PREFIX = 'bogus_bucket/TheArchiveBase'
DEFAULT_ARCHIVE_BASE = 'gs://%s' % DEFAULT_ARCHIVE_PREFIX
@@ -220,9 +215,3 @@ class ArchiveTest(cros_test_lib.TestCase):
DEFAULT_BOT_NAME,
self._VERSION))
self.assertEqual(expected_value, value)
-
-
-
-
-if __name__ == '__main__':
- cros_test_lib.main(level=logging.DEBUG)
diff --git a/cbuildbot/cbuildbot_config_unittest b/cbuildbot/cbuildbot_config_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/cbuildbot_config_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/cbuildbot_config_unittest.py b/cbuildbot/cbuildbot_config_unittest.py
index 561f31303..2ed76dc3c 100755..100644
--- a/cbuildbot/cbuildbot_config_unittest.py
+++ b/cbuildbot/cbuildbot_config_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -10,11 +9,9 @@ from __future__ import print_function
import mock
import os
import cPickle
-import sys
-import constants
-sys.path.insert(0, constants.SOURCE_ROOT)
from chromite.cbuildbot import cbuildbot_config
+from chromite.cbuildbot import constants
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
from chromite.lib import git
@@ -732,7 +729,3 @@ class OverrideForTrybotTest(cros_test_lib.TestCase):
old = cbuildbot_config.config['duck-paladin']
new = cbuildbot_config.OverrideConfigForTrybot(old, mock_options)
self.assertEquals(new['vm_tests'], old['vm_tests'])
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/cbuildbot_run_unittest b/cbuildbot/cbuildbot_run_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/cbuildbot_run_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/cbuildbot_run_unittest.py b/cbuildbot/cbuildbot_run_unittest.py
index aa8c322c8..573abb809 100755..100644
--- a/cbuildbot/cbuildbot_run_unittest.py
+++ b/cbuildbot/cbuildbot_run_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,19 +6,16 @@
from __future__ import print_function
-import logging
-import os
import cPickle
-import sys
+import os
+import mock
import time
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import cbuildbot_config
from chromite.cbuildbot import cbuildbot_run
from chromite.lib import cros_test_lib
from chromite.lib import parallel
-import mock
DEFAULT_ARCHIVE_GS_PATH = 'bogus_bucket/TheArchiveBase'
DEFAULT_ARCHIVE_BASE = 'gs://%s' % DEFAULT_ARCHIVE_GS_PATH
@@ -349,8 +345,9 @@ class GetVersionTest(_BuilderRunTestCase):
def testGetVersionInfo(self):
verinfo = object()
- with mock.patch('cbuildbot_run.manifest_version.VersionInfo.from_repo',
- return_value=verinfo) as m:
+ target = ('chromite.cbuildbot.cbuildbot_run.manifest_version.'
+ 'VersionInfo.from_repo')
+ with mock.patch(target, return_value=verinfo) as m:
result = cbuildbot_run._BuilderRunBase.GetVersionInfo(DEFAULT_BUILDROOT)
self.assertEquals(result, verinfo)
@@ -644,7 +641,3 @@ class BoardRunAttributesTest(_BuilderRunTestCase):
"""Test that regular attributes are not known to BoardRunAttributes."""
self.assertRaises(AttributeError, getattr, self.bra, 'release_tag')
self.assertRaises(AttributeError, setattr, self.bra, 'release_tag', 'foo')
-
-
-if __name__ == '__main__':
- cros_test_lib.main(level=logging.DEBUG)
diff --git a/cbuildbot/cbuildbot_unittest b/cbuildbot/cbuildbot_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/cbuildbot_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/cbuildbot_unittest.py b/cbuildbot/cbuildbot_unittest.py
index 11b42fe13..2804c3509 100755..100644
--- a/cbuildbot/cbuildbot_unittest.py
+++ b/cbuildbot/cbuildbot_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -14,11 +13,10 @@ import optparse
import os
import sys
-import constants
-sys.path.insert(0, constants.SOURCE_ROOT)
-from chromite.cbuildbot import commands
from chromite.cbuildbot import cbuildbot_config as config
from chromite.cbuildbot import cbuildbot_run
+from chromite.cbuildbot import commands
+from chromite.cbuildbot import constants
from chromite.cbuildbot import manifest_version
from chromite.lib import cidb
from chromite.lib import cros_build_lib
@@ -675,7 +673,3 @@ class FullInterfaceTest(cros_test_lib.MoxTempDirTestCase):
self.mox.ReplayAll()
self.assertRaises(cros_build_lib.DieSystemExit, self.assertMain,
['--local', '-r', self.buildroot, 'x86-generic-paladin'])
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/chroot_lib_unittest b/cbuildbot/chroot_lib_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/chroot_lib_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/chroot_lib_unittest.py b/cbuildbot/chroot_lib_unittest.py
index 3af09ebf6..f40476fac 100755..100644
--- a/cbuildbot/chroot_lib_unittest.py
+++ b/cbuildbot/chroot_lib_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,9 +7,7 @@
from __future__ import print_function
import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import chroot_lib
from chromite.lib import cros_test_lib
from chromite.lib import osutils
@@ -60,7 +57,3 @@ class TestChrootManager(cros_test_lib.TempDirTestCase):
chroot = os.path.join(self.tempdir, 'chroot')
self.chroot_manager.EnsureChrootAtVersion('foo')
self.assertEquals(self.chroot_manager.GetChrootVersion(chroot), None)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/commands_unittest b/cbuildbot/commands_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/commands_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/commands_unittest.py b/cbuildbot/commands_unittest.py
index de8b6c85c..13174f6a8 100755..100644
--- a/cbuildbot/commands_unittest.py
+++ b/cbuildbot/commands_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,14 +7,12 @@
from __future__ import print_function
import base64
+import mock
import os
-import sys
-
from StringIO import StringIO
-import constants
-sys.path.insert(0, constants.SOURCE_ROOT)
from chromite.cbuildbot import commands
+from chromite.cbuildbot import constants
from chromite.cbuildbot import failures_lib
from chromite.lib import cros_build_lib_unittest
from chromite.lib import cros_build_lib
@@ -26,10 +23,6 @@ from chromite.lib import osutils
from chromite.lib import partial_mock
from chromite.scripts import pushimage
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
class RunBuildScriptTest(cros_test_lib.TempDirTestCase):
"""Test RunBuildScript in a variety of cases."""
@@ -724,7 +717,3 @@ class ImageTestCommandsTest(cros_build_lib_unittest.RunCommandTestCase):
],
enter_chroot=True,
)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/failures_lib_unittest b/cbuildbot/failures_lib_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/failures_lib_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/failures_lib_unittest.py b/cbuildbot/failures_lib_unittest.py
index 400c2067b..f1d61b540 100755..100644
--- a/cbuildbot/failures_lib_unittest.py
+++ b/cbuildbot/failures_lib_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,6 @@
from __future__ import print_function
-import os
-import sys
-
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import failures_lib
from chromite.lib import cros_test_lib
@@ -201,7 +196,3 @@ class ExceptInfoTest(cros_test_lib.TestCase):
self.assertEqual(except_infos[0].type, ValueError)
self.assertEqual(except_infos[0].str, message)
self.assertEqual(except_infos[0].traceback, traceback)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/lab_status_unittest b/cbuildbot/lab_status_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/lab_status_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/lab_status_unittest.py b/cbuildbot/lab_status_unittest.py
index fd920e112..103f2f36d 100755..100644
--- a/cbuildbot/lab_status_unittest.py
+++ b/cbuildbot/lab_status_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,13 +6,10 @@
from __future__ import print_function
-import constants
-from mock import Mock
-import sys
+import mock
import time
import urllib
-sys.path.insert(0, constants.SOURCE_ROOT)
from chromite.cbuildbot import lab_status
from chromite.lib import cros_test_lib
@@ -27,7 +23,7 @@ class TestLabStatus(cros_test_lib.MockTestCase):
def _LabStatusFile(self, message, general_state):
"""Returns a file-like object with the status message written in it."""
- my_response = Mock()
+ my_response = mock.Mock()
my_response.json = '{"message": "%s", "general_state": "%s"}' % (
message, general_state)
return my_response
@@ -116,7 +112,3 @@ class TestLabStatus(cros_test_lib.MockTestCase):
self.assertRaises(lab_status.BoardIsDisabledException,
lab_status.CheckLabStatus,
'stumpy')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/lkgm_manager_unittest b/cbuildbot/lkgm_manager_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/lkgm_manager_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/lkgm_manager_unittest.py b/cbuildbot/lkgm_manager_unittest.py
index 063abebb8..5b7cad473 100755..100644
--- a/cbuildbot/lkgm_manager_unittest.py
+++ b/cbuildbot/lkgm_manager_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,17 +7,14 @@
from __future__ import print_function
import contextlib
+import mock
import mox
import os
import random
-import sys
import tempfile
from xml.dom import minidom
-if __name__ == '__main__':
- import constants
- sys.path.insert(0, constants.SOURCE_ROOT)
-
+from chromite.cbuildbot import constants
from chromite.cbuildbot import lkgm_manager
from chromite.cbuildbot import repository
from chromite.lib import cros_build_lib
@@ -26,10 +22,6 @@ from chromite.lib import cros_test_lib
from chromite.lib import git
from chromite.lib import osutils
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
FAKE_VERSION_STRING = '1.2.4-rc3'
FAKE_VERSION_STRING_NEXT = '1.2.4-rc4'
@@ -675,7 +667,3 @@ class LKGMManagerTest(cros_test_lib.MoxTempDirTestCase):
os.remove(fake_manifest)
if fake_new_manifest:
os.remove(fake_new_manifest)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/manifest_version_unittest b/cbuildbot/manifest_version_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/manifest_version_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/manifest_version_unittest.py b/cbuildbot/manifest_version_unittest.py
index e52e726f9..241a318e4 100755..100644
--- a/cbuildbot/manifest_version_unittest.py
+++ b/cbuildbot/manifest_version_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,13 +8,9 @@ from __future__ import print_function
import mox
import os
-import sys
import tempfile
-import constants
-if __name__ == '__main__':
- sys.path.insert(0, constants.SOURCE_ROOT)
-
+from chromite.cbuildbot import constants
from chromite.cbuildbot import failures_lib
from chromite.cbuildbot import manifest_version
from chromite.cbuildbot import repository
@@ -407,7 +402,3 @@ class BuildSpecsManagerTest(cros_test_lib.MoxTempDirTestCase,
statuses = self._GetBuildersStatus(['build1', 'build2'], status_runs)
self.assertTrue(statuses['build1'].Failed())
self.assertTrue(statuses['build2'].Passed())
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/metadata_lib_unittest b/cbuildbot/metadata_lib_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/metadata_lib_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/metadata_lib_unittest.py b/cbuildbot/metadata_lib_unittest.py
index 8e62cb56c..f5cb21072 100755..100644
--- a/cbuildbot/metadata_lib_unittest.py
+++ b/cbuildbot/metadata_lib_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,12 +6,8 @@
from __future__ import print_function
-import logging
import multiprocessing
-import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import metadata_lib
from chromite.lib import cros_test_lib
from chromite.lib import parallel
@@ -164,7 +159,3 @@ class MetadataTest(cros_test_lib.TestCase):
q.put([board, {k: v}])
self.assertEqual(expected_dict, metadata.GetDict()['board-metadata'])
-
-
-if __name__ == '__main__':
- cros_test_lib.main(level=logging.DEBUG)
diff --git a/cbuildbot/prebuilts_unittest b/cbuildbot/prebuilts_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/prebuilts_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/prebuilts_unittest.py b/cbuildbot/prebuilts_unittest.py
index b0fc8da93..79ba45e7b 100755..100644
--- a/cbuildbot/prebuilts_unittest.py
+++ b/cbuildbot/prebuilts_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,20 +6,14 @@
from __future__ import print_function
+import mock
import os
-import sys
-import constants
-sys.path.insert(0, constants.SOURCE_ROOT)
+from chromite.cbuildbot import constants
from chromite.cbuildbot import prebuilts
from chromite.lib import cros_build_lib_unittest
-from chromite.lib import cros_test_lib
from chromite.lib import osutils
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
# pylint: disable=W0212
class PrebuiltTest(cros_build_lib_unittest.RunCommandTempDirTestCase):
@@ -111,7 +104,3 @@ ca-t3/pk-g4-4.0.1-r333
"""Test that we raise an exception when the installer file is missing."""
self.assertRaises(prebuilts.PackageFileMissing,
self.testDevInstallerPrebuilts, packages=())
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/remote_try.py b/cbuildbot/remote_try.py
index d480b0f1a..08b3367c2 100644
--- a/cbuildbot/remote_try.py
+++ b/cbuildbot/remote_try.py
@@ -10,12 +10,8 @@ import constants
import getpass
import json
import os
-import sys
import time
-if __name__ == '__main__':
- sys.path.insert(0, constants.SOURCE_ROOT)
-
from chromite.cbuildbot import repository
from chromite.cbuildbot import manifest_version
from chromite.lib import cros_build_lib
diff --git a/cbuildbot/remote_try_unittest b/cbuildbot/remote_try_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/remote_try_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/remote_try_unittest.py b/cbuildbot/remote_try_unittest.py
index 56494301e..1cf816f82 100755..100644
--- a/cbuildbot/remote_try_unittest.py
+++ b/cbuildbot/remote_try_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,12 +8,10 @@ from __future__ import print_function
import json
import os
-import sys
import shutil
import time
-import constants
-sys.path.insert(0, constants.SOURCE_ROOT)
+from chromite.cbuildbot import constants
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
from chromite.lib import git
@@ -187,7 +184,3 @@ class RemoteTryTests(cros_test_lib.MockTempDirTestCase):
job = self._CreateJob(mirror=False)
self.assertEqual(job.repo_url, remote_try.RemoteTryJob.EXTERNAL_URL)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/repository_unittest b/cbuildbot/repository_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/repository_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/repository_unittest.py b/cbuildbot/repository_unittest.py
index c3163844a..7ad7a7232 100755..100644
--- a/cbuildbot/repository_unittest.py
+++ b/cbuildbot/repository_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,8 @@
from __future__ import print_function
import os
-import sys
-import constants
-sys.path.insert(0, constants.SOURCE_ROOT)
+from chromite.cbuildbot import constants
from chromite.cbuildbot import repository
from chromite.lib import cros_build_lib_unittest
from chromite.lib import cros_test_lib
@@ -76,7 +73,3 @@ class RepoInitChromeBotTests(RepoInitTests):
def setUp(self):
os.putenv('GIT_COMMITTER_EMAIL', 'chrome-bot@chromium.org')
os.putenv('GIT_AUTHOR_EMAIL', 'chrome-bot@chromium.org')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/run_tests.py b/cbuildbot/run_tests.py
index 76debf2d0..239025549 100644
--- a/cbuildbot/run_tests.py
+++ b/cbuildbot/run_tests.py
@@ -55,41 +55,41 @@ SKIP = 'skip'
# List all exceptions, with a token describing what's odd here.
SPECIAL_TESTS = {
# Tests that need to run inside the chroot.
- 'cbuildbot/stages/test_stages_unittest.py': INSIDE,
- 'cros/commands/cros_build_unittest.py': INSIDE,
- 'cros/commands/lint_unittest.py': INSIDE,
- 'lib/filetype_unittest.py': INSIDE,
- 'lib/upgrade_table_unittest.py': INSIDE,
- 'scripts/cros_install_debug_syms_unittest.py': INSIDE,
- 'scripts/cros_list_modified_packages_unittest.py': INSIDE,
- 'scripts/cros_mark_as_stable_unittest.py': INSIDE,
- 'scripts/cros_mark_chrome_as_stable_unittest.py': INSIDE,
- 'scripts/cros_mark_mojo_as_stable_unittest.py': INSIDE,
- 'scripts/sync_package_status_unittest.py': INSIDE,
- 'scripts/cros_portage_upgrade_unittest.py': INSIDE,
- 'scripts/dep_tracker_unittest.py': INSIDE,
- 'scripts/test_image_unittest.py': INSIDE,
- 'scripts/upload_package_status_unittest.py': INSIDE,
+ 'cbuildbot/stages/test_stages_unittest': INSIDE,
+ 'cros/commands/cros_build_unittest': INSIDE,
+ 'cros/commands/lint_unittest': INSIDE,
+ 'lib/filetype_unittest': INSIDE,
+ 'lib/upgrade_table_unittest': INSIDE,
+ 'scripts/cros_install_debug_syms_unittest': INSIDE,
+ 'scripts/cros_list_modified_packages_unittest': INSIDE,
+ 'scripts/cros_mark_as_stable_unittest': INSIDE,
+ 'scripts/cros_mark_chrome_as_stable_unittest': INSIDE,
+ 'scripts/cros_mark_mojo_as_stable_unittest': INSIDE,
+ 'scripts/sync_package_status_unittest': INSIDE,
+ 'scripts/cros_portage_upgrade_unittest': INSIDE,
+ 'scripts/dep_tracker_unittest': INSIDE,
+ 'scripts/test_image_unittest': INSIDE,
+ 'scripts/upload_package_status_unittest': INSIDE,
# Tests that need to run outside the chroot.
- 'lib/cgroups_unittest.py': OUTSIDE,
+ 'lib/cgroups_unittest': OUTSIDE,
# Tests that take >2 minutes to run. All the slow tests are
# disabled atm though ...
- #'scripts/cros_portage_upgrade_unittest.py': SKIP,
+ #'scripts/cros_portage_upgrade_unittest': SKIP,
}
SLOW_TESTS = {
# Tests that require network can be really slow.
- 'buildbot/manifest_version_unittest.py': SKIP,
- 'buildbot/repository_unittest.py': SKIP,
- 'buildbot/remote_try_unittest.py': SKIP,
- 'lib/cros_build_lib_unittest.py': SKIP,
- 'lib/gerrit_unittest.py': SKIP,
- 'lib/patch_unittest.py': SKIP,
+ 'buildbot/manifest_version_unittest': SKIP,
+ 'buildbot/repository_unittest': SKIP,
+ 'buildbot/remote_try_unittest': SKIP,
+ 'lib/cros_build_lib_unittest': SKIP,
+ 'lib/gerrit_unittest': SKIP,
+ 'lib/patch_unittest': SKIP,
# cgroups_unittest runs cros_sdk a lot, so is slow.
- 'lib/cgroups_unittest.py': SKIP,
+ 'lib/cgroups_unittest': SKIP,
}
@@ -336,7 +336,7 @@ def FindTests(search_paths=('.',)):
for path in files:
test = os.path.join(os.path.relpath(root, search_path), path)
- if test.endswith('_unittest.py'):
+ if test.endswith('_unittest'):
yield test
diff --git a/cbuildbot/run_tests_unittest b/cbuildbot/run_tests_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/run_tests_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/run_tests_unittest.py b/cbuildbot/run_tests_unittest.py
index e33158b6d..5e0e424b7 100755..100644
--- a/cbuildbot/run_tests_unittest.py
+++ b/cbuildbot/run_tests_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,17 +6,13 @@
from __future__ import print_function
+import mock
import os
-import sys
-
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import run_tests
from chromite.lib import cros_test_lib
from chromite.lib import osutils
-import mock
-
class RunTestsTest(cros_test_lib.MockTestCase):
"""Tests for the RunTests() func"""
@@ -33,27 +28,27 @@ class FindTestsTest(cros_test_lib.TempDirTestCase):
"""Tests for the FindTests() func"""
def testNames(self):
- """We only look for *_unittest.py."""
- for f in ('foo', 'foo_unittests.py', 'bar_unittest.py', 'cow_unittest.py'):
+ """We only look for *_unittest."""
+ for f in ('foo', 'foo_unittests', 'bar_unittest', 'cow_unittest'):
osutils.Touch(os.path.join(self.tempdir, f))
found = run_tests.FindTests(search_paths=(self.tempdir,))
- self.assertEqual(sorted(found), ['./bar_unittest.py', './cow_unittest.py'])
+ self.assertEqual(sorted(found), ['./bar_unittest', './cow_unittest'])
def testSubdirs(self):
"""We should recurse into subdirs."""
- for f in ('bar_unittest.py', 'somw/dir/a/cow_unittest.py'):
+ for f in ('bar_unittest', 'somw/dir/a/cow_unittest'):
osutils.Touch(os.path.join(self.tempdir, f), makedirs=True)
found = run_tests.FindTests(search_paths=(self.tempdir,))
self.assertEqual(sorted(found),
- ['./bar_unittest.py', 'somw/dir/a/cow_unittest.py'])
+ ['./bar_unittest', 'somw/dir/a/cow_unittest'])
def testIgnores(self):
"""Verify we skip ignored dirs."""
- for f in ('foo', 'bar_unittest.py'):
+ for f in ('foo', 'bar_unittest'):
osutils.Touch(os.path.join(self.tempdir, f))
# Make sure it works first.
found = run_tests.FindTests(search_paths=(self.tempdir,))
- self.assertEqual(sorted(found), ['./bar_unittest.py'])
+ self.assertEqual(sorted(found), ['./bar_unittest'])
# Mark the dir ignored.
osutils.Touch(os.path.join(self.tempdir, '.testignore'))
# Make sure we ignore it.
@@ -108,7 +103,7 @@ class MainTest(cros_test_lib.MockOutputTestCase):
"""Verify --quick filters out slow tests"""
self.PatchObject(run_tests, 'RunTests', return_value=True)
# Pick a test that is in SLOW_TESTS but not in SPECIAL_TESTS.
- slow_test = 'lib/patch_unittest.py'
+ slow_test = 'lib/patch_unittest'
self.assertIn(slow_test, run_tests.SLOW_TESTS)
self.assertNotIn(slow_test, run_tests.SPECIAL_TESTS)
run_tests.main(['--quick'])
@@ -117,12 +112,7 @@ class MainTest(cros_test_lib.MockOutputTestCase):
def testSpecificTests(self):
"""Verify user specified tests are run."""
m = self.PatchObject(run_tests, 'RunTests', return_value=True)
- tests = ['./some/foo_unittest.py', './bar_unittest.py']
+ tests = ['./some/foo_unittest', './bar_unittest']
run_tests.main(tests)
m.assert_called_with(tests, jobs=mock.ANY, chroot_available=mock.ANY,
network=mock.ANY, dryrun=mock.ANY)
-
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/artifact_stages_unittest b/cbuildbot/stages/artifact_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/artifact_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/artifact_stages_unittest.py b/cbuildbot/stages/artifact_stages_unittest.py
index a89537240..31cc287ff 100755..100644
--- a/cbuildbot/stages/artifact_stages_unittest.py
+++ b/cbuildbot/stages/artifact_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,10 @@
from __future__ import print_function
import argparse
+import mock
import os
import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import commands
from chromite.cbuildbot import constants
from chromite.cbuildbot import failures_lib
@@ -22,7 +21,6 @@ from chromite.cbuildbot.stages import build_stages_unittest
from chromite.cbuildbot.stages import generic_stages_unittest
from chromite.lib import cros_build_lib
from chromite.lib import cros_build_lib_unittest
-from chromite.lib import cros_test_lib
from chromite.lib import git
from chromite.lib import osutils
from chromite.lib import parallel
@@ -32,10 +30,6 @@ from chromite.lib import partial_mock
from chromite.cbuildbot.stages.generic_stages_unittest import patch
from chromite.cbuildbot.stages.generic_stages_unittest import patches
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
DEFAULT_CHROME_BRANCH = '27'
@@ -593,7 +587,3 @@ class ArchivingStageTest(generic_stages_unittest.AbstractStageTest):
self._run, self._current_board)
return artifact_stages.ArchivingStage(
self._run, self._current_board, archive_stage)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/branch_stages_unittest b/cbuildbot/stages/branch_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/branch_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/branch_stages_unittest.py b/cbuildbot/stages/branch_stages_unittest.py
index 7e86b8635..157389c18 100755..100644
--- a/cbuildbot/stages/branch_stages_unittest.py
+++ b/cbuildbot/stages/branch_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,9 +7,7 @@
from __future__ import print_function
import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import constants
from chromite.cbuildbot import manifest_version
from chromite.cbuildbot import manifest_version_unittest
@@ -338,7 +335,3 @@ class BranchUtilStageTest(generic_stages_unittest.AbstractStageTest,
side_effect=FetchAndCheckoutTo, autospec=True)
self.assertRaises(cros_build_lib.RunCommandError,
self._SimulateIncrementFailure)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/build_stages_unittest b/cbuildbot/stages/build_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/build_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/build_stages_unittest.py b/cbuildbot/stages/build_stages_unittest.py
index 076161cce..dcce5a6ab 100755..100644
--- a/cbuildbot/stages/build_stages_unittest.py
+++ b/cbuildbot/stages/build_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,9 +8,7 @@ from __future__ import print_function
import contextlib
import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import cbuildbot_config as config
from chromite.cbuildbot import commands
from chromite.cbuildbot import constants
@@ -337,7 +334,3 @@ class BuildImageStageTest(BuildPackagesStageTest):
# TODO: This test is broken atm with tag=None.
steps = [lambda tag=x: task(tag) for x in (release_tag,)]
parallel.RunParallelSteps(steps)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/chrome_stages_unittest b/cbuildbot/stages/chrome_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/chrome_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/chrome_stages_unittest.py b/cbuildbot/stages/chrome_stages_unittest.py
index 1f33811de..ebe4712f5 100755..100644
--- a/cbuildbot/stages/chrome_stages_unittest.py
+++ b/cbuildbot/stages/chrome_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,9 @@
from __future__ import print_function
+import mock
import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import commands
from chromite.cbuildbot import constants
from chromite.cbuildbot.cbuildbot_unittest import BuilderRunMock
@@ -23,10 +21,6 @@ from chromite.lib import cros_test_lib
from chromite.lib import osutils
from chromite.lib import parallel_unittest
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
class ChromeSDKStageTest(generic_stages_unittest.AbstractStageTest,
cros_test_lib.LoggingTestCase):
@@ -108,7 +102,3 @@ class PatchChromeStageTest(generic_stages_unittest.AbstractStageTest):
"""Verify requested patches are applied."""
stage = self.ConstructStage()
stage.PerformStage()
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/completion_stages_unittest b/cbuildbot/stages/completion_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/completion_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/completion_stages_unittest.py b/cbuildbot/stages/completion_stages_unittest.py
index 2514de37d..057d5e8ca 100755..100644
--- a/cbuildbot/stages/completion_stages_unittest.py
+++ b/cbuildbot/stages/completion_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,9 @@
from __future__ import print_function
-import os
+import mock
import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import cbuildbot_run
from chromite.cbuildbot import commands
from chromite.cbuildbot import constants
@@ -23,13 +21,8 @@ from chromite.cbuildbot.stages import sync_stages_unittest
from chromite.cbuildbot.stages import sync_stages
from chromite.lib import alerts
from chromite.lib import clactions
-from chromite.lib import cros_test_lib
from chromite.lib import patch_unittest
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
# pylint: disable=protected-access
@@ -496,7 +489,3 @@ class PublishUprevChangesStageTest(generic_stages_unittest.AbstractStageTest):
self._run.options.prebuilts = True
self.RunStage()
self.push_mock.assert_called_once_with(self.build_root, ['bar'], False)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/generic_stages_unittest b/cbuildbot/stages/generic_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/generic_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/generic_stages_unittest.py b/cbuildbot/stages/generic_stages_unittest.py
index dba03be3e..b7939c703 100755..100644
--- a/cbuildbot/stages/generic_stages_unittest.py
+++ b/cbuildbot/stages/generic_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,11 +8,11 @@ from __future__ import print_function
import contextlib
import copy
+import mock
import os
import sys
import unittest
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import commands
from chromite.cbuildbot import constants
from chromite.cbuildbot import cbuildbot_config as config
@@ -31,10 +30,6 @@ from chromite.lib import partial_mock
from chromite.lib import portage_util
from chromite.scripts import cbuildbot
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
DEFAULT_BUILD_NUMBER = 1234321
DEFAULT_BUILD_ID = 31337
@@ -495,7 +490,3 @@ class ArchivingStageMixinMock(partial_mock.PartialMock):
with patch(commands, 'ArchiveFile', return_value='foo.txt'):
with patch(commands, 'UploadArchivedFile'):
self.backup['UploadArtifact'](*args, **kwargs)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/release_stages_unittest b/cbuildbot/stages/release_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/release_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/release_stages_unittest.py b/cbuildbot/stages/release_stages_unittest.py
index d5269df48..713c2e4c7 100755..100644
--- a/cbuildbot/stages/release_stages_unittest.py
+++ b/cbuildbot/stages/release_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,17 +6,14 @@
from __future__ import print_function
-import os
-import sys
+import mock
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot.cbuildbot_unittest import BuilderRunMock
from chromite.cbuildbot.stages import artifact_stages
from chromite.cbuildbot.stages import generic_stages_unittest
from chromite.cbuildbot.stages import release_stages
from chromite.cbuildbot import failures_lib
from chromite.cbuildbot import results_lib
-from chromite.lib import cros_test_lib
from chromite.lib import timeout_util
from chromite.cbuildbot.stages.generic_stages_unittest import patch
@@ -25,10 +21,6 @@ from chromite.cbuildbot.stages.generic_stages_unittest import patch
from chromite.lib.paygen import gspaths
from chromite.lib.paygen import paygen_build_lib
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
# pylint: disable=protected-access
@@ -452,7 +444,3 @@ class PaygenStageTest(generic_stages_unittest.AbstractStageTest):
run_on_builder=True,
skip_delta_payloads=True,
disable_tests=True)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/report_stages_unittest b/cbuildbot/stages/report_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/report_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/report_stages_unittest.py b/cbuildbot/stages/report_stages_unittest.py
index 5bb1a47df..e882daa98 100755..100644
--- a/cbuildbot/stages/report_stages_unittest.py
+++ b/cbuildbot/stages/report_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,9 @@
from __future__ import print_function
+import mock
import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import cbuildbot_run
from chromite.cbuildbot import commands
from chromite.cbuildbot import constants
@@ -26,18 +24,12 @@ from chromite.cbuildbot.stages import sync_stages
from chromite.cbuildbot.stages import sync_stages_unittest
from chromite.lib import alerts
from chromite.lib import cidb
-from chromite.lib import cros_test_lib
from chromite.lib import fake_cidb
from chromite.lib import gs
from chromite.lib import osutils
from chromite.lib import retry_stats
from chromite.lib import toolchain
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
-
# pylint: disable=protected-access
class BuildReexecutionStageTest(generic_stages_unittest.AbstractStageTest):
@@ -288,7 +280,3 @@ class ReportStageNoSyncTest(AbstractReportStageTest):
"""Check that we can run with a RELEASE_TAG of None."""
self._SetupUpdateStreakCounter()
self.RunStage()
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/sdk_stages_unittest b/cbuildbot/stages/sdk_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/sdk_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/sdk_stages_unittest.py b/cbuildbot/stages/sdk_stages_unittest.py
index 7f9197755..4be171c0e 100755..100644
--- a/cbuildbot/stages/sdk_stages_unittest.py
+++ b/cbuildbot/stages/sdk_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,14 +8,11 @@ from __future__ import print_function
import json
import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import commands
from chromite.cbuildbot.stages import sdk_stages
from chromite.cbuildbot.stages import generic_stages_unittest
from chromite.lib import cros_build_lib
-from chromite.lib import cros_test_lib
from chromite.lib import osutils
from chromite.lib import portage_util
@@ -113,7 +109,3 @@ class SDKTestStageTest(generic_stages_unittest.AbstractStageTest):
"""Basic run through the main code."""
self._Prepare('chromiumos-sdk')
self.RunStage()
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/stage_results_unittest b/cbuildbot/stages/stage_results_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/stage_results_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/stage_results_unittest.py b/cbuildbot/stages/stage_results_unittest.py
index a719de459..c54430555 100755..100644
--- a/cbuildbot/stages/stage_results_unittest.py
+++ b/cbuildbot/stages/stage_results_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,13 +6,12 @@
from __future__ import print_function
+import mock
import os
import signal
import StringIO
-import sys
import time
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import cbuildbot_config as config
from chromite.cbuildbot import failures_lib
from chromite.cbuildbot import results_lib
@@ -26,11 +24,6 @@ from chromite.lib import parallel
from chromite.scripts import cbuildbot
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
-
class PassStage(generic_stages.BuilderStage):
"""PassStage always works"""
@@ -480,7 +473,3 @@ class BuildStagesResultsTest(cros_test_lib.TestCase):
results = StringIO.StringIO()
results_lib.Results.Report(results)
self.assertTrue('@@@STEP_WARNINGS@@@' in results.getvalue())
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/sync_stages_unittest b/cbuildbot/stages/sync_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/sync_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/sync_stages_unittest.py b/cbuildbot/stages/sync_stages_unittest.py
index 6a53ab90a..b2c047c33 100755..100644
--- a/cbuildbot/stages/sync_stages_unittest.py
+++ b/cbuildbot/stages/sync_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -11,12 +10,11 @@ import ConfigParser
import cPickle
import datetime
import itertools
+import mock
import os
-import sys
import time
import tempfile
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import cbuildbot_config
from chromite.cbuildbot import constants
from chromite.cbuildbot import lkgm_manager
@@ -29,7 +27,6 @@ from chromite.cbuildbot import validation_pool
from chromite.cbuildbot.stages import sync_stages
from chromite.cbuildbot.stages import generic_stages_unittest
from chromite.lib import cros_build_lib_unittest
-from chromite.lib import cros_test_lib
from chromite.lib import cidb
from chromite.lib import clactions
from chromite.lib import fake_cidb
@@ -40,10 +37,6 @@ from chromite.lib import osutils
from chromite.lib import patch as cros_patch
from chromite.lib import timeout_util
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
class ManifestVersionedSyncStageTest(generic_stages_unittest.AbstractStageTest):
"""Tests the ManifestVersionedSync stage."""
@@ -843,7 +836,3 @@ class PreCQLauncherStageTest(MasterCQSyncTestCase):
requeued_actions = [a for a in actions_for_patch
if a.action == constants.CL_ACTION_REQUEUED]
self.assertEqual(1, len(requeued_actions))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/stages/test_stages_unittest b/cbuildbot/stages/test_stages_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cbuildbot/stages/test_stages_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/stages/test_stages_unittest.py b/cbuildbot/stages/test_stages_unittest.py
index 8f4d82080..338fbae73 100755..100644
--- a/cbuildbot/stages/test_stages_unittest.py
+++ b/cbuildbot/stages/test_stages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,9 @@
from __future__ import print_function
+import mock
import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import cbuildbot_config as config
from chromite.cbuildbot import commands
from chromite.cbuildbot import failures_lib
@@ -23,17 +21,11 @@ from chromite.cbuildbot.stages import generic_stages_unittest
from chromite.lib import cgroups
from chromite.lib import cros_build_lib
from chromite.lib import cros_build_lib_unittest
-from chromite.lib import cros_test_lib
from chromite.lib import git
from chromite.lib import osutils
from chromite.lib import timeout_util
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
-
class VMTestStageTest(generic_stages_unittest.AbstractStageTest):
"""Tests for the VMTest stage."""
@@ -470,7 +462,3 @@ class ImageTestStageTest(generic_stages_unittest.AbstractStageTest,
cros_build_lib.ToChrootPath(stage.GetImageDirSymlink()),
]
self.assertCommandContains(cmd)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/tree_status_unittest b/cbuildbot/tree_status_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/tree_status_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/tree_status_unittest.py b/cbuildbot/tree_status_unittest.py
index 7e47eb347..51f34563f 100755..100644
--- a/cbuildbot/tree_status_unittest.py
+++ b/cbuildbot/tree_status_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,20 +6,14 @@
from __future__ import print_function
-import os
-import sys
+import mock
import urllib
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
from chromite.cbuildbot import constants
from chromite.cbuildbot import tree_status
from chromite.lib import cros_test_lib
from chromite.lib import timeout_util
-import mock
-
# pylint: disable=protected-access
@@ -272,7 +265,3 @@ class TestGettingSheriffEmails(cros_test_lib.MockTestCase):
raw_line = "document.write('None (channel is sheriff)')"
self.PatchObject(tree_status, '_OpenSheriffURL', return_value=raw_line)
self.assertEqual(tree_status.GetSheriffEmailAddresses('lab'), [])
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/triage_lib_unittest b/cbuildbot/triage_lib_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/triage_lib_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/triage_lib_unittest.py b/cbuildbot/triage_lib_unittest.py
index ddb27bbee..87bf2056b 100755..100644
--- a/cbuildbot/triage_lib_unittest.py
+++ b/cbuildbot/triage_lib_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,13 +7,11 @@
from __future__ import print_function
import ConfigParser
+import mock
import os
-import sys
import unittest
-import constants
-sys.path.insert(0, constants.SOURCE_ROOT)
-
+from chromite.cbuildbot import constants
from chromite.cbuildbot import failures_lib
from chromite.cbuildbot import results_lib
from chromite.cbuildbot import triage_lib
@@ -26,8 +23,6 @@ from chromite.lib import osutils
from chromite.lib import patch as cros_patch
from chromite.lib import patch_unittest
-import mock
-
# Some tests require the kernel, and fail with buildtools only repo.
KERNEL_AVAILABLE = os.path.exists(os.path.join(
@@ -388,7 +383,3 @@ class ConfigFileTest(cros_test_lib.MockTestCase):
'/a/b/COMMIT-QUEUE.ini')
self.assertEqual(triage_lib._GetConfigFileForChange(p, '/a/b/'),
'/a/b/COMMIT-QUEUE.ini')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/trybot_patch_pool_unittest b/cbuildbot/trybot_patch_pool_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/trybot_patch_pool_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/trybot_patch_pool_unittest.py b/cbuildbot/trybot_patch_pool_unittest.py
index c01d9ab1a..3fee47418 100755..100644
--- a/cbuildbot/trybot_patch_pool_unittest.py
+++ b/cbuildbot/trybot_patch_pool_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,12 +6,8 @@
from __future__ import print_function
-import sys
-
-import constants
-sys.path.insert(0, constants.SOURCE_ROOT)
+from chromite.cbuildbot import constants
from chromite.cbuildbot import trybot_patch_pool
-from chromite.lib import cros_test_lib
from chromite.lib import patch as cros_patch
from chromite.lib import patch_unittest
@@ -56,7 +51,3 @@ class FilterTests(patch_unittest.GitRepoPatchTestCase):
self.assertFalse(trybot_patch_pool.BranchFilter('/,/asdf', patch))
self.assertTrue(trybot_patch_pool.BranchFilter(
patch.tracking_branch, patch))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cbuildbot/validation_pool_unittest b/cbuildbot/validation_pool_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cbuildbot/validation_pool_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cbuildbot/validation_pool_unittest.py b/cbuildbot/validation_pool_unittest.py
index 18296c2c5..f2429e93e 100755..100644
--- a/cbuildbot/validation_pool_unittest.py
+++ b/cbuildbot/validation_pool_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2011-2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -13,17 +12,15 @@ import copy
import functools
import httplib
import itertools
+import mock
import mox
import os
import pickle
import random
-import sys
import tempfile
import time
-import constants
-sys.path.insert(0, constants.SOURCE_ROOT)
-
+from chromite.cbuildbot import constants
from chromite.cbuildbot import metadata_lib
from chromite.cbuildbot import repository
from chromite.cbuildbot import tree_status
@@ -42,8 +39,6 @@ from chromite.lib import partial_mock
from chromite.lib import patch as cros_patch
from chromite.lib import patch_unittest
-import mock
-
_GetNumber = iter(itertools.count()).next
# Without this some lambda's defined in constants will not be the same as
@@ -1810,7 +1805,3 @@ class LoadManifestTest(cros_test_lib.TempDirTestCase):
self.assertEqual(self.pool.changes[0].fail_count, 2)
self.assertEqual(self.pool.changes[0].pass_count, 0)
self.assertEqual(self.pool.changes[0].total_fail_count, 3)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/commands/cros_bootstrap_overlay_unittest b/cros/commands/cros_bootstrap_overlay_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cros/commands/cros_bootstrap_overlay_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cros/commands/cros_bootstrap_overlay_unittest.py b/cros/commands/cros_bootstrap_overlay_unittest.py
index 82a554676..321d27941 100755..100644
--- a/cros/commands/cros_bootstrap_overlay_unittest.py
+++ b/cros/commands/cros_bootstrap_overlay_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,15 +8,13 @@ from __future__ import print_function
import os
import re
-import sys
-
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cros.commands import cros_bootstrap_overlay
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
from chromite.lib import osutils
+
class BootstrapOverlayCommandTest(cros_test_lib.TempDirTestCase):
"""Test class for the bootstrap-overlay command."""
@@ -123,7 +120,3 @@ DEPEND="chromeos-base/otherthing"
'metadata',
'layout.conf'))
self.assertEquals(dic['repo-name'], 'hello')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/commands/cros_build_unittest b/cros/commands/cros_build_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cros/commands/cros_build_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cros/commands/cros_build_unittest.py b/cros/commands/cros_build_unittest.py
index 9bac9ac9e..89f1fd2a3 100755..100644
--- a/cros/commands/cros_build_unittest.py
+++ b/cros/commands/cros_build_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,8 @@
from __future__ import print_function
-import os
-import sys
+import mock
-sys.path.insert(0, os.path.abspath('%s/../../../..' % __file__))
from chromite.cros.commands import cros_build
from chromite.cros.commands import init_unittest
from chromite.lib import cros_build_lib
@@ -18,10 +15,6 @@ from chromite.lib import cros_test_lib
from chromite.lib import parallel_unittest
from chromite.lib import partial_mock
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
class MockBuildCommand(init_unittest.MockCommand):
"""Mock out the build command."""
@@ -66,7 +59,3 @@ class BuildCommandTest(cros_test_lib.TestCase):
"""Test GetToolchainPackages function without mocking."""
packages = cros_build.GetToolchainPackages()
self.assertTrue(packages)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/commands/cros_chrome_sdk_unittest b/cros/commands/cros_chrome_sdk_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cros/commands/cros_chrome_sdk_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cros/commands/cros_chrome_sdk_unittest.py b/cros/commands/cros_chrome_sdk_unittest.py
index d44901fff..93103bb3d 100755..100644
--- a/cros/commands/cros_chrome_sdk_unittest.py
+++ b/cros/commands/cros_chrome_sdk_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -11,9 +10,7 @@ import copy
import mock
import os
import shutil
-import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import constants
from chromite.cros.commands import cros_chrome_sdk
from chromite.cros.commands import init_unittest
@@ -504,7 +501,3 @@ class PathVerifyTest(cros_test_lib.MockTempDirTestCase,
for msg in ['managed Goma', 'default Chromite']:
self.AssertLogsMatch(logs, msg)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/commands/cros_flash_unittest b/cros/commands/cros_flash_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cros/commands/cros_flash_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cros/commands/cros_flash_unittest.py b/cros/commands/cros_flash_unittest.py
index ae3ed8520..24fb09b96 100755..100644
--- a/cros/commands/cros_flash_unittest.py
+++ b/cros/commands/cros_flash_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,9 +8,7 @@ from __future__ import print_function
import mock
import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cros.commands import cros_flash
from chromite.cros.commands import init_unittest
from chromite.lib import cros_build_lib
@@ -282,7 +279,3 @@ class ImagingRunThroughTest(cros_test_lib.MockTempDirTestCase,
self.SetupCommandMock(['usb://', self.IMAGE])
self.cmd_mock.inst.Run()
self.assertTrue(self.imager_mock.patched['ChooseRemovableDevice'].called)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/commands/cros_image_unittest b/cros/commands/cros_image_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cros/commands/cros_image_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cros/commands/cros_image_unittest.py b/cros/commands/cros_image_unittest.py
index 3bd28c562..eae3f4bdf 100755..100644
--- a/cros/commands/cros_image_unittest.py
+++ b/cros/commands/cros_image_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,7 @@
from __future__ import print_function
import argparse
-import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cros.commands import cros_image
from chromite.lib import cros_test_lib
@@ -29,7 +25,3 @@ class ImageCommandTest(cros_test_lib.TestCase):
options = fake_parser.parse_args(['image', '--myoption=awesome'])
instance = options.cros_class(options)
self.assertEqual(instance.options.myoption, 'awesome')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/commands/cros_lint_unittest b/cros/commands/cros_lint_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cros/commands/cros_lint_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cros/commands/cros_lint_unittest.py b/cros/commands/cros_lint_unittest.py
index 48a0e9951..9e2e2d9a7 100755..100644
--- a/cros/commands/cros_lint_unittest.py
+++ b/cros/commands/cros_lint_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,6 @@
from __future__ import print_function
-import os
-import sys
-
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.cros.commands import cros_lint
from chromite.lib import cros_test_lib
@@ -23,7 +18,3 @@ class LintCommandTest(cros_test_lib.TestCase):
self.assertEqual(
set(cros_lint.LintCommand.OUTPUT_FORMATS),
set(cros_lint.CPPLINT_OUTPUT_FORMAT_MAP.keys() + ['default']))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/commands/init_unittest b/cros/commands/init_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cros/commands/init_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cros/commands/init_unittest.py b/cros/commands/init_unittest.py
index 5fc5c7e71..fa6d71c7e 100755..100644
--- a/cros/commands/init_unittest.py
+++ b/cros/commands/init_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,10 +8,6 @@ from __future__ import print_function
import glob
import imp
-import os
-import sys
-
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.lib import commandline
from chromite.lib import cros_build_lib_unittest
@@ -76,7 +71,3 @@ class CommandTest(cros_test_lib.MockTestCase):
commands._ImportCommands()
load_mock.assert_called_with(fake_module, *module_tuple)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/commands/lint_unittest b/cros/commands/lint_unittest
new file mode 120000
index 000000000..ef3e37b67
--- /dev/null
+++ b/cros/commands/lint_unittest
@@ -0,0 +1 @@
+../../scripts/wrapper.py \ No newline at end of file
diff --git a/cros/commands/lint_unittest.py b/cros/commands/lint_unittest.py
index e4c89dc0c..9e26a9d4c 100755..100644
--- a/cros/commands/lint_unittest.py
+++ b/cros/commands/lint_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,6 @@
from __future__ import print_function
import collections
-import os
-import sys
-
-sys.path.insert(0, os.path.abspath('%s/../../..' % os.path.dirname(__file__)))
from chromite.lib import cros_test_lib
import lint
@@ -336,7 +331,3 @@ class DocStringCheckerTest(cros_test_lib.TestCase):
node = TestNode(doc=dc, args=args)
self.checker._check_all_args_in_doc(node, node.lines)
self.assertEqual(len(self.results), 1)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/init_unittest b/cros/init_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/cros/init_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/cros/init_unittest.py b/cros/init_unittest.py
index 11bfe4ed0..f3bed29f2 100755..100644
--- a/cros/init_unittest.py
+++ b/cros/init_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,6 @@
from __future__ import print_function
import argparse
-import os
-import sys
-
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.lib import cros_test_lib
from chromite import cros
@@ -55,7 +50,3 @@ class CommandTest(cros_test_lib.TestCase):
pass
else:
self.fail('Invalid command was accepted by the CommandDecorator')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/cros/tests/cros_vm_test.py b/cros/tests/cros_vm_test.py
index dfe11299c..5e37a9dca 100755..100644
--- a/cros/tests/cros_vm_test.py
+++ b/cros/tests/cros_vm_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
diff --git a/lib/alerts_unittest b/lib/alerts_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/alerts_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/alerts_unittest.py b/lib/alerts_unittest.py
index e2bb052ec..f24ec3939 100755..100644
--- a/lib/alerts_unittest.py
+++ b/lib/alerts_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,13 +7,8 @@
from __future__ import print_function
from email.mime.text import MIMEText
-import os
import smtplib
import socket
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import alerts
from chromite.lib import cros_test_lib
@@ -68,8 +62,8 @@ class SendEmailLogTest(cros_test_lib.MockTestCase):
self.assertEqual(self.send_mock.call_count, 1)
-if __name__ == '__main__':
+def main(_argv):
# No need to make unittests sleep.
alerts.SMTP_RETRY_DELAY = 0
- cros_test_lib.main()
+ cros_test_lib.main(module=__name__)
diff --git a/lib/binpkg_unittest b/lib/binpkg_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/binpkg_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/binpkg_unittest.py b/lib/binpkg_unittest.py
index 70e0fda29..bde909adb 100755..100644
--- a/lib/binpkg_unittest.py
+++ b/lib/binpkg_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,6 @@
from __future__ import print_function
import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import binpkg
from chromite.lib import cros_test_lib
@@ -67,7 +62,3 @@ class DebugSymbolsTest(cros_test_lib.TempDirTestCase):
self.assertEquals(index.packages[0]['CPV'], 'chromeos-base/shill-0.0.1-r1')
self.assertEquals(index.packages[0].get('DEBUG_SYMBOLS'), 'yes')
self.assertFalse('DEBUG_SYMBOLS' in index.packages[1])
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/cache_unittest b/lib/cache_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/cache_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/cache_unittest.py b/lib/cache_unittest.py
index dbf281305..69939d326 100755..100644
--- a/lib/cache_unittest.py
+++ b/lib/cache_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2015 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,8 @@
from __future__ import print_function
+import mock
import os
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import gs
from chromite.lib import cros_test_lib
@@ -18,10 +15,6 @@ from chromite.lib import cache
from chromite.lib import osutils
from chromite.lib import retry_util
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
class CacheReferenceTest(cros_test_lib.TestCase):
"""Tests for CacheReference.
@@ -256,7 +249,3 @@ class TarballCacheTest(CacheTestCase):
testAssign = CacheTestCase._testAssign
testAssignData = CacheTestCase._testAssignData
testRemove = CacheTestCase._testRemove
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/cgroups_unittest b/lib/cgroups_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/cgroups_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/cgroups_unittest.py b/lib/cgroups_unittest.py
index 3957faf24..825fb7955 100755..100644
--- a/lib/cgroups_unittest.py
+++ b/lib/cgroups_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,11 +6,6 @@
from __future__ import print_function
-import os
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
from chromite.lib import cgroups
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
@@ -32,7 +26,3 @@ class TestCreateGroups(cros_test_lib.TestCase):
with cgroups.SimpleContainChildren('example', sigterm_timeout=5):
parallel.RunTasksInProcessPool(self._CrosSdk, [[]] * 20,
processes=10)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/chrome_util_unittest b/lib/chrome_util_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/chrome_util_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/chrome_util_unittest.py b/lib/chrome_util_unittest.py
index 0401c195e..b9feff882 100755..100644
--- a/lib/chrome_util_unittest.py
+++ b/lib/chrome_util_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,7 @@
from __future__ import print_function
import os
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_test_lib
from chromite.lib import chrome_util
@@ -236,7 +232,3 @@ class DirCopyTest(FileCopyTest):
class SloppyDirCopyTest(SloppyFileCopyTest, DirCopyTest):
"""Test directory copies with sloppy=True"""
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/cidb_integration_test b/lib/cidb_integration_test
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/cidb_integration_test
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/cidb_integration_test.py b/lib/cidb_integration_test.py
index 21b4f3c16..8c7934db5 100755..100644
--- a/lib/cidb_integration_test.py
+++ b/lib/cidb_integration_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -18,10 +17,7 @@ import datetime
import glob
import logging
import os
-import sys
import time
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.cbuildbot import constants
from chromite.cbuildbot import metadata_lib
@@ -636,9 +632,7 @@ def _SimulateCQBuildFinish(db, metadata, build_id):
db.FinishBuild(build_id, status, summary)
-# TODO(akeshet): Allow command line args to specify alternate CIDB instance
-# for testing.
-if __name__ == '__main__':
- logging.root.setLevel(logging.DEBUG)
- logging.root.addHandler(logging.StreamHandler())
- cros_test_lib.main()
+def main(_argv):
+ # TODO(akeshet): Allow command line args to specify alternate CIDB instance
+ # for testing.
+ cros_test_lib.main(module=__name__)
diff --git a/lib/cidb_setup_unittest b/lib/cidb_setup_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/cidb_setup_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/cidb_setup_unittest.py b/lib/cidb_setup_unittest.py
index 0275eb3ba..2d0d56e8b 100755..100644
--- a/lib/cidb_setup_unittest.py
+++ b/lib/cidb_setup_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,16 +6,11 @@
from __future__ import print_function
-import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
from chromite.cbuildbot import constants
from chromite.lib import cidb
from chromite.lib import cros_test_lib
+
class CIDBConnectionFactoryTest(cros_test_lib.MockTestCase):
"""Test that CIDBConnectionFactory behaves as expected."""
@@ -109,7 +103,3 @@ class CIDBConnectionFactoryTest(cros_test_lib.MockTestCase):
self.assertRaises(AssertionError, cidb.CIDBConnectionFactory.SetupProdCidb)
self.assertRaises(AssertionError, cidb.CIDBConnectionFactory.SetupDebugCidb)
self.assertRaises(AssertionError, cidb.CIDBConnectionFactory.SetupMockCidb)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/clactions_unittest b/lib/clactions_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/clactions_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/clactions_unittest.py b/lib/clactions_unittest.py
index b2fc331e7..50dcb8ba6 100755..100644
--- a/lib/clactions_unittest.py
+++ b/lib/clactions_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,11 +8,6 @@ from __future__ import print_function
import datetime
import itertools
-import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.cbuildbot import constants
from chromite.cbuildbot import metadata_lib
@@ -451,7 +445,3 @@ class TestCLStatusCounter(cros_test_lib.TestCase):
c1p2, validation_pool.CQ_PIPELINE_CONFIGS,
constants.CL_ACTION_KICKED_OUT, action_history,
latest_patchset_only=False))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/commandline_unittest b/lib/commandline_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/commandline_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/commandline_unittest.py b/lib/commandline_unittest.py
index c1dbbc2a9..489b041ba 100755..100644
--- a/lib/commandline_unittest.py
+++ b/lib/commandline_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -11,8 +10,6 @@ import cPickle
import signal
import os
import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import commandline
from chromite.lib import cros_build_lib_unittest
@@ -360,7 +357,3 @@ class ScriptWrapperMainTest(cros_test_lib.MockTestCase):
ret = lambda x: ScriptWrapperMainTest._DummyChrootTargetArgs
commandline.ScriptWrapperMain(ret)
rc.assertCommandContains(self.DUMMY_CHROOT_TARGET_ARGS, enter_chroot=True)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/cros_build_lib_unittest b/lib/cros_build_lib_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/cros_build_lib_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/cros_build_lib_unittest.py b/lib/cros_build_lib_unittest.py
index f1ae06a96..6d351a3cd 100755..100644
--- a/lib/cros_build_lib_unittest.py
+++ b/lib/cros_build_lib_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,11 +6,6 @@
from __future__ import print_function
-import os
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
import contextlib
import datetime
import difflib
@@ -19,6 +13,8 @@ import errno
import functools
import itertools
import logging
+import mock
+import os
import signal
import socket
import StringIO
@@ -35,9 +31,6 @@ from chromite.lib import partial_mock
from chromite.lib import retry_util
from chromite.lib import signals as cros_signals
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
# pylint: disable=W0212,R0904
@@ -1671,7 +1664,3 @@ EEC571FFB6E1)
self.assertRaises(KeyError, cros_build_lib.GetImageDiskPartitionInfo,
'_ignored', 'PB')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/cros_test_lib.py b/lib/cros_test_lib.py
index cc8df546b..a468fd109 100644
--- a/lib/cros_test_lib.py
+++ b/lib/cros_test_lib.py
@@ -16,6 +16,7 @@ import functools
import hashlib
import json
import logging
+import mock
import mox
import netrc
import os
@@ -41,18 +42,6 @@ import timeout_util
# do so through the normal cidb SetUp / GetConnectionForBuilder factory.
cidb.CIDBConnectionFactory.SetupMockCidb()
-if 'chromite' not in sys.modules:
- # TODO(build): Finish test wrapper (http://crosbug.com/37517).
- # Until then, we detect the chromite manipulation not yet having
- # occurred, and inject it ourselves.
- # We cannot just import chromite since this module is still accessed
- # from non chromite.lib.cros_test_lib pathways (which will be resolved
- # implicitly via 37517).
- sys.path.insert(0, os.path.join(
- os.path.dirname(os.path.abspath(__file__)), '../third_party'))
-
-import mock
-
Directory = collections.namedtuple('Directory', ['name', 'contents'])
diff --git a/lib/cros_test_lib_unittest b/lib/cros_test_lib_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/cros_test_lib_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/cros_test_lib_unittest.py b/lib/cros_test_lib_unittest.py
index 00e59ce49..082c497f5 100755..100644
--- a/lib/cros_test_lib_unittest.py
+++ b/lib/cros_test_lib_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,22 +6,15 @@
from __future__ import print_function
-import os
-import sys
+import mock
import time
import unittest
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
-
from chromite.lib import cros_test_lib
from chromite.lib import cros_build_lib_unittest
from chromite.lib import partial_mock
from chromite.lib import timeout_util
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
# pylint: disable=W0212,W0233
@@ -160,7 +152,7 @@ class MockTestCaseTest(cros_test_lib.TestCase):
TO_BE_MOCKED3 = 20
def GetPatcher(self, attr, val):
- return mock.patch('__main__.MockTestCaseTest.Mockable.%s' % attr,
+ return mock.patch('%s.MockTestCaseTest.Mockable.%s' % (__name__, attr),
new=val)
def testPatchRemovalError(self):
@@ -202,7 +194,3 @@ class TestCaseTest(unittest.TestCase):
# Run the test case, verifying it raises a TimeoutError.
test = TimeoutTestCase(methodName='testSleeping')
self.assertRaises(timeout_util.TimeoutError, test.testSleeping)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/dev_server_wrapper_stress_test.py b/lib/dev_server_wrapper_stress_test.py
index ef2cf72a7..81f103ee3 100644
--- a/lib/dev_server_wrapper_stress_test.py
+++ b/lib/dev_server_wrapper_stress_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
diff --git a/lib/filetype_unittest b/lib/filetype_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/filetype_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/filetype_unittest.py b/lib/filetype_unittest.py
index 81469c770..4ba0c6682 100755..100644
--- a/lib/filetype_unittest.py
+++ b/lib/filetype_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,11 +7,6 @@
from __future__ import print_function
import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
import stat
from chromite.lib import cros_test_lib
@@ -224,7 +218,3 @@ or10mrNRF3tyGy8e/sw88a74Q/6v/PgChZHmq6QjOOU=
osutils.WriteFile(bootsec, '\x90' * 510 + '\x55\xaa')
self.assertEquals('binary/bootsector/x86',
filetype.FileTypeDecoder.DecodeFile(bootsec))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/gclient_unittest b/lib/gclient_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/gclient_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/gclient_unittest.py b/lib/gclient_unittest.py
index d79ca2a40..5b9d4f135 100755..100644
--- a/lib/gclient_unittest.py
+++ b/lib/gclient_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2015 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,13 +7,9 @@
from __future__ import print_function
import os
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_build_lib
from chromite.lib import cros_build_lib_unittest
-from chromite.lib import cros_test_lib
from chromite.lib import gclient
from chromite.lib import osutils
@@ -136,7 +131,3 @@ class TestGclientWriteConfigFile(
'name': 'src-internal',
'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git'}]
""")
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/gdata_lib_unittest b/lib/gdata_lib_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/gdata_lib_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/gdata_lib_unittest.py b/lib/gdata_lib_unittest.py
index aeecd972e..b0ec48b17 100755..100644
--- a/lib/gdata_lib_unittest.py
+++ b/lib/gdata_lib_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,18 +8,12 @@ from __future__ import print_function
import getpass
import mox
-import os
import re
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__))), 'third_party', 'gdata', 'src'))
import atom.service
import gdata.projecthosting.client as gd_ph_client
import gdata.spreadsheet.service
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_test_lib
from chromite.lib import gdata_lib
from chromite.lib import osutils
@@ -1113,7 +1106,3 @@ class RetrySpreadsheetsServiceTest(cros_test_lib.MoxOutputTestCase):
def testRetryRequest403x5(self):
# This one should exhaust the retries.
self._TestRetryRequest([403, 403, 403, 403, 403])
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/gerrit_unittest b/lib/gerrit_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/gerrit_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/gerrit_unittest.py b/lib/gerrit_unittest.py
index 66b17dac6..85f2c09a3 100755..100644
--- a/lib/gerrit_unittest.py
+++ b/lib/gerrit_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,10 +8,7 @@ from __future__ import print_function
import getpass
import httplib
-import os
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
+import mock
from chromite.cbuildbot import constants
from chromite.lib import cros_build_lib
@@ -21,8 +17,6 @@ from chromite.lib import gerrit
from chromite.lib import git
from chromite.lib import gob_util
-import mock
-
# pylint: disable=W0212,R0904
class GerritHelperTest(cros_test_lib.GerritTestCase):
@@ -383,7 +377,3 @@ class DirectGerritHelperTest(cros_test_lib.TestCase):
changes = self.CHANGES
results = list(gerrit.GetGerritPatchInfo(changes))
self.assertEqual(changes, [x.gerrit_number_str for x in results])
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/git_unittest b/lib/git_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/git_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/git_unittest.py b/lib/git_unittest.py
index 0cc3cad99..180567f3e 100755..100644
--- a/lib/git_unittest.py
+++ b/lib/git_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,11 +7,8 @@
from __future__ import print_function
import functools
+import mock
import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_build_lib
from chromite.lib import cros_build_lib_unittest
@@ -21,8 +17,6 @@ from chromite.lib import git
from chromite.lib import partial_mock
from chromite.lib import patch_unittest
-import mock
-
class ManifestMock(partial_mock.PartialMock):
"""Partial mock for git.Manifest."""
@@ -338,7 +332,3 @@ class GitBranchDetectionTest(patch_unittest.GitRepoPatchTestCase):
git.CreateBranch(git1, 'peach', track=True)
self.CommitFile(git1, 'peach', 'Keep me.')
self.assertTrue(git.DoesCommitExistInRepo(git1, 'peach'))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/gob_util_unittest b/lib/gob_util_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/gob_util_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/gob_util_unittest.py b/lib/gob_util_unittest.py
index b202b477e..9074021c5 100755..100644
--- a/lib/gob_util_unittest.py
+++ b/lib/gob_util_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,17 +7,12 @@
from __future__ import print_function
import httplib
-import os
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
+import mock
from chromite.cbuildbot import constants
from chromite.lib import cros_test_lib
from chromite.lib import gob_util
-import mock
-
class FakeHTTPResponse(object):
"""Enough of a HTTPResponse for FetchUrl.
@@ -97,6 +91,6 @@ class NetworkGobTest(cros_test_lib.TestCase):
self.assertEqual(ex.exception.http_status, 404)
-if __name__ == '__main__':
+def main(_argv):
gob_util.TRY_LIMIT = 1
- cros_test_lib.main()
+ cros_test_lib.main(module=__name__)
diff --git a/lib/gs_unittest b/lib/gs_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/gs_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/gs_unittest.py b/lib/gs_unittest.py
index 8c1db08dc..2182b1bfa 100755..100644
--- a/lib/gs_unittest.py
+++ b/lib/gs_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -10,11 +9,9 @@ from __future__ import print_function
import contextlib
import functools
import datetime
+import mock
import os
import string
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.cbuildbot import constants
from chromite.lib import cros_build_lib
@@ -25,10 +22,6 @@ from chromite.lib import osutils
from chromite.lib import partial_mock
from chromite.lib import retry_stats
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
def PatchGS(*args, **kwargs):
"""Convenience method for patching GSContext."""
@@ -1551,7 +1544,3 @@ class UnmockedGSCounterTest(cros_test_lib.TestCase):
with self._Counter() as counter:
self._SetCounter(counter, 100)
self.assertEqual(counter.StreakDecrement(), -1)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/loas_unittest b/lib/loas_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/loas_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/loas_unittest.py b/lib/loas_unittest.py
index 3f920aa93..eedb7173b 100755..100644
--- a/lib/loas_unittest.py
+++ b/lib/loas_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,6 @@
from __future__ import print_function
import datetime
-import os
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import alerts
from chromite.lib import cros_build_lib_unittest
@@ -89,7 +84,3 @@ class TestLoas(cros_test_lib.MockTestCase):
self.loas.Status()
self.loas.Status()
self.assertEqual(self.email_mock.call_count, 2)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/namespaces_unittest b/lib/namespaces_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/namespaces_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/namespaces_unittest.py b/lib/namespaces_unittest.py
index 87282900c..2c6c29084 100755..100644
--- a/lib/namespaces_unittest.py
+++ b/lib/namespaces_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,10 +8,7 @@ from __future__ import print_function
import errno
import os
-import sys
import unittest
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_test_lib
from chromite.lib import namespaces
@@ -49,7 +45,3 @@ class UnshareTests(cros_test_lib.TestCase):
# Running as non-root will fail, so ignore it. We ran most
# of the code in the process which is all we really wanted.
raise
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/osutils_unittest b/lib/osutils_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/osutils_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/osutils_unittest.py b/lib/osutils_unittest.py
index 1f78b19be..855f5d20e 100755..100644
--- a/lib/osutils_unittest.py
+++ b/lib/osutils_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,8 @@
from __future__ import print_function
+import mock
import os
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_build_lib
from chromite.lib import cros_build_lib_unittest
@@ -18,9 +15,6 @@ from chromite.lib import cros_test_lib
from chromite.lib import osutils
from chromite.lib import partial_mock
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
class TestOsutils(cros_test_lib.TempDirTestCase):
"""General unittests for the osutils module."""
@@ -550,7 +544,3 @@ class ResolveSymlinkTest(cros_test_lib.TestCase):
self.assertEqual(osutils.ResolveSymlink('link2', '.'), './target')
os.unlink('link2')
os.unlink('link1')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/parallel_unittest b/lib/parallel_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/parallel_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/parallel_unittest.py b/lib/parallel_unittest.py
index a140d565c..25a124f85 100755..100644
--- a/lib/parallel_unittest.py
+++ b/lib/parallel_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -10,6 +9,7 @@ from __future__ import print_function
import contextlib
import cPickle
import logging
+import mock
import multiprocessing
import os
import signal
@@ -25,7 +25,6 @@ except ImportError:
# pylint: disable=F0401
import queue as Queue
-sys.path.insert(0, os.path.abspath('%s/../../..' % __file__))
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
from chromite.lib import osutils
@@ -33,9 +32,6 @@ from chromite.lib import parallel
from chromite.lib import partial_mock
from chromite.lib import timeout_util
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
# pylint: disable=protected-access
@@ -493,6 +489,5 @@ class TestConstants(cros_test_lib.TestCase):
'program has not hung.')
-if __name__ == '__main__':
- # Run the tests.
- cros_test_lib.main(level=logging.INFO)
+def main(_argv):
+ cros_test_lib.main(level=logging.INFO, module=__name__)
diff --git a/lib/parseelf_unittest b/lib/parseelf_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/parseelf_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/parseelf_unittest.py b/lib/parseelf_unittest.py
index f5a938034..daf33bd7b 100755..100644
--- a/lib/parseelf_unittest.py
+++ b/lib/parseelf_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,6 @@
from __future__ import print_function
import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_test_lib
from chromite.lib import osutils
@@ -120,7 +115,3 @@ class ELFParsingTest(cros_test_lib.TempDirTestCase):
# ld dynamic loader.
self.assertTrue(lib[path] == elf['interp'] or
os.path.exists(os.path.join(self.tempdir, lib[path])))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/partial_mock_unittest b/lib/partial_mock_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/partial_mock_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/partial_mock_unittest.py b/lib/partial_mock_unittest.py
index a4f6fd760..f7dc2ad35 100755..100644
--- a/lib/partial_mock_unittest.py
+++ b/lib/partial_mock_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,16 +6,13 @@
from __future__ import print_function
-import os
-import sys
-
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_test_lib
from chromite.lib import partial_mock
+
# pylint: disable=W0212
+
class ComparatorTest(cros_test_lib.TestCase):
"""Test Comparitor functionality."""
TEST_KEY1 = 'monkey'
@@ -211,7 +207,3 @@ class MockedCallResultsTest(cros_test_lib.TestCase):
2, self.mr.LookupResult(self.ARGS, hook_args=self.LIST_ARGS,
hook_kwargs=self.KWARGS))
self.assertEquals(3, self.mr.LookupResult(('test',)))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/patch_unittest b/lib/patch_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/patch_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/patch_unittest.py b/lib/patch_unittest.py
index 521ab4d8b..676c303f4 100755..100644
--- a/lib/patch_unittest.py
+++ b/lib/patch_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,14 +8,11 @@ from __future__ import print_function
import copy
import itertools
+import mock
import os
import shutil
-import sys
import time
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
from chromite.cbuildbot import constants
from chromite.lib import cros_build_lib
from chromite.lib import cros_build_lib_unittest
@@ -26,7 +22,6 @@ from chromite.lib import git
from chromite.lib import osutils
from chromite.lib import patch as cros_patch
-import mock
_GetNumber = iter(itertools.count()).next
@@ -926,7 +921,3 @@ class MockPatchBase(cros_test_lib.MockTestCase):
if how_many == 1 and not always_use_list:
return patches[0]
return patches
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/perf_uploader_unittest b/lib/perf_uploader_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/perf_uploader_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/perf_uploader_unittest.py b/lib/perf_uploader_unittest.py
index 1f926f25c..333eca57b 100755..100644
--- a/lib/perf_uploader_unittest.py
+++ b/lib/perf_uploader_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,12 +8,10 @@ from __future__ import print_function
import json
import os
-import sys
import tempfile
import urllib2
import urlparse
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.lib import cros_test_lib
from chromite.lib import perf_uploader
from chromite.lib import osutils
@@ -225,7 +222,3 @@ class UploadPerfValuesTest(PerfUploadTestCase):
perf_uploader.UploadPerfValues(perf_values, 'platform', 'TestName',
cros_version='cros', chrome_version='chrome',
dry_run=True)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/portage_util_unittest b/lib/portage_util_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/portage_util_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/portage_util_unittest.py b/lib/portage_util_unittest.py
index 5133c9ecc..8483764be 100755..100644
--- a/lib/portage_util_unittest.py
+++ b/lib/portage_util_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -10,10 +9,7 @@ from __future__ import print_function
import fileinput
import mox
import os
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.cbuildbot import constants
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
@@ -879,7 +875,3 @@ class InstalledPackageTest(cros_test_lib.MoxTempDirTestCase):
# Check that doesn't fail when the package name is provided.
pkg = portage_util.InstalledPackage(None, self.tempdir, pf='package-1')
self.assertEquals('package-1', pkg.pf)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/process_util_unittest b/lib/process_util_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/process_util_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/process_util_unittest.py b/lib/process_util_unittest.py
index 50ce6a467..499b28769 100755..100644
--- a/lib/process_util_unittest.py
+++ b/lib/process_util_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,10 +8,6 @@ from __future__ import print_function
import os
import signal
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_test_lib
from chromite.lib import process_util
@@ -121,7 +116,3 @@ class ExitAsStatusTests(cros_test_lib.TestCase):
def testSIGKILL(self):
"""Verify harsh signals get decoded."""
self._Tester(kill_signal=signal.SIGKILL)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/remote_access_unittest b/lib/remote_access_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/remote_access_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/remote_access_unittest.py b/lib/remote_access_unittest.py
index d67078ebf..9a5edccff 100755..100644
--- a/lib/remote_access_unittest.py
+++ b/lib/remote_access_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,18 +6,15 @@
from __future__ import print_function
-import os
import re
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_build_lib
from chromite.lib import cros_build_lib_unittest
from chromite.lib import cros_test_lib
from chromite.lib import partial_mock
from chromite.lib import remote_access
+
# pylint: disable=W0212
@@ -153,7 +149,3 @@ class CheckIfRebootedTest(RemoteAccessTest):
"""Test case of bad error code returned."""
self.MockCheckReboot(2)
self.assertRaises(Exception, self.host._CheckIfRebooted)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/retry_stats_unittest b/lib/retry_stats_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/retry_stats_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/retry_stats_unittest.py b/lib/retry_stats_unittest.py
index 5e9830888..766a4db18 100755..100644
--- a/lib/retry_stats_unittest.py
+++ b/lib/retry_stats_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,12 +6,7 @@
from __future__ import print_function
-import os
import StringIO
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
from chromite.lib import cros_test_lib
from chromite.lib import retry_stats
@@ -230,7 +224,3 @@ class TestRetryStats(cros_test_lib.TestCase):
retry_stats.RetryWithStats,
self.CAT, self.handlerRetry, 3, self.callFailure)
self._verifyStats(self.CAT, failure=2, retry=6)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/stats_unittest b/lib/stats_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/stats_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/stats_unittest.py b/lib/stats_unittest.py
index ebfb8ab8c..4c7bde7aa 100755..100644
--- a/lib/stats_unittest.py
+++ b/lib/stats_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,12 +7,9 @@
from __future__ import print_function
import logging
-import os
-import sys
import time
import urllib2
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.lib import cros_test_lib
from chromite.lib import parallel
from chromite.lib import parallel_unittest
@@ -230,5 +226,5 @@ class UploadContextTest(cros_test_lib.MockLoggingTestCase):
self.assertRaises(e, RaiseContext, e)
-if __name__ == '__main__':
- cros_test_lib.main(level=logging.DEBUG)
+def main(_argv):
+ cros_test_lib.main(level=logging.DEBUG, module=__name__)
diff --git a/lib/table_unittest b/lib/table_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/table_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/table_unittest.py b/lib/table_unittest.py
index 4a652e700..475feb897 100755..100644
--- a/lib/table_unittest.py
+++ b/lib/table_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,12 +7,9 @@
from __future__ import print_function
import cStringIO
-import os
import sys
import tempfile
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_test_lib
from chromite.lib import table
@@ -341,6 +337,3 @@ class TableTest(cros_test_lib.TempDirTestCase):
self.assertRowsEqual(final_row0, self._table[0])
self.assertRowsEqual(final_row1, self._table[1])
self.assertRowsEqual(final_row2, self._table[2])
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/timeout_util_unittest b/lib/timeout_util_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/timeout_util_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/timeout_util_unittest.py b/lib/timeout_util_unittest.py
index 1bb57b6c8..e26c42d3d 100755..100644
--- a/lib/timeout_util_unittest.py
+++ b/lib/timeout_util_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,13 +7,8 @@
from __future__ import print_function
import datetime
-import os
-import sys
import time
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
from chromite.lib import cros_test_lib
from chromite.lib import timeout_util
@@ -165,7 +159,3 @@ class TestWaitFors(cros_test_lib.TestCase):
self.assertRaises(timeout_util.TimeoutError, self._TestWaitForSuccess,
10, 0, period=0.1, side_effect_func=_SideEffect)
self.assertTrue(side_effect_called[0])
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/lib/tracker_access.py b/lib/tracker_access.py
index 735e7b46b..3dda67a71 100644
--- a/lib/tracker_access.py
+++ b/lib/tracker_access.py
@@ -164,6 +164,3 @@ def main():
else:
command_name = sys.argv[1]
commands[command_name](*sys.argv[2:])
-
-if __name__ == "__main__":
- main()
diff --git a/lib/upgrade_table_unittest b/lib/upgrade_table_unittest
new file mode 120000
index 000000000..72196ceea
--- /dev/null
+++ b/lib/upgrade_table_unittest
@@ -0,0 +1 @@
+../scripts/wrapper.py \ No newline at end of file
diff --git a/lib/upgrade_table_unittest.py b/lib/upgrade_table_unittest.py
index 23d061fe9..85a626fa9 100755..100644
--- a/lib/upgrade_table_unittest.py
+++ b/lib/upgrade_table_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,12 +6,6 @@
from __future__ import print_function
-import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
from chromite.lib import cros_test_lib
from chromite.lib import upgrade_table as utable
@@ -88,6 +81,3 @@ class UpgradeTableTest(cros_test_lib.TestCase):
col = t1.COL_UPGRADED
self.assertFalse(t1.HasColumn(col))
self.assertTrue(t2.HasColumn(col))
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/autotest_quickmerge_unittest b/scripts/autotest_quickmerge_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/autotest_quickmerge_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/autotest_quickmerge_unittest.py b/scripts/autotest_quickmerge_unittest.py
index 4eb8c8773..47b9b3928 100755..100644
--- a/scripts/autotest_quickmerge_unittest.py
+++ b/scripts/autotest_quickmerge_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,17 +6,13 @@
from __future__ import print_function
-import os
-import sys
+import mock
import types
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.lib import cros_build_lib_unittest
from chromite.lib import cros_test_lib
from chromite.scripts import autotest_quickmerge
-import mock
-
RSYNC_TEST_OUTPUT = """.d..t...... ./
>f..t...... touched file with spaces
@@ -199,7 +194,3 @@ class PortageAPITest(cros_test_lib.TestCase):
self.assertIsInstance(f, types.UnboundMethodType,
'Required writeContentsToContentsFile is not '
'a function.')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cbuildbot_unittest b/scripts/cbuildbot_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cbuildbot_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cbuildbot_unittest.py b/scripts/cbuildbot_unittest.py
index 4b1947efe..ed368813b 100755..100644
--- a/scripts/cbuildbot_unittest.py
+++ b/scripts/cbuildbot_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,12 +6,6 @@
from __future__ import print_function
-import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
-
from chromite.cbuildbot import constants
from chromite.lib import cros_test_lib
from chromite.scripts import cbuildbot
@@ -63,7 +56,3 @@ class IsDistributedBuilderTest(cros_test_lib.TestCase):
constants.CHROME_REV_LOCAL,
constants.CHROME_REV_SPEC):
_TestConfig(False)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cbuildbot_view_config_unittest b/scripts/cbuildbot_view_config_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cbuildbot_view_config_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cbuildbot_view_config_unittest.py b/scripts/cbuildbot_view_config_unittest.py
index bc5cbefa3..25374e5e6 100755..100644
--- a/scripts/cbuildbot_view_config_unittest.py
+++ b/scripts/cbuildbot_view_config_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,10 +8,6 @@ from __future__ import print_function
import json
import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.cbuildbot import constants
from chromite.lib import cros_test_lib
@@ -103,7 +98,3 @@ class JsonCompareTest(cros_test_lib.TempDirTestCase,
finally:
config[self.TARGET]['name'] = orig_name
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/check_gdata_token_unittest b/scripts/check_gdata_token_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/check_gdata_token_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/check_gdata_token_unittest.py b/scripts/check_gdata_token_unittest.py
index 4ed145329..c0c51f468 100755..100644
--- a/scripts/check_gdata_token_unittest.py
+++ b/scripts/check_gdata_token_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -19,8 +18,6 @@ import gdata.service
from gdata.projecthosting import client as gdata_ph_client
from gdata.spreadsheet import service as gdata_ss_service
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_build_lib as build_lib
from chromite.lib import cros_test_lib
from chromite.lib import gdata_lib
@@ -533,7 +530,3 @@ class InsideChrootTest(cros_test_lib.MoxOutputTestCase):
result = cgt.InsideChroot._ValidateDocsToken(mocked_insidechroot)
self.assertFalse(result, '_ValidateDocsToken should have failed')
self.mox.VerifyAll()
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cros_best_revision_unittest b/scripts/cros_best_revision_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_best_revision_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_best_revision_unittest.py b/scripts/cros_best_revision_unittest.py
index 889f28889..c5188e407 100755..100644
--- a/scripts/cros_best_revision_unittest.py
+++ b/scripts/cros_best_revision_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,6 @@
from __future__ import print_function
import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.cbuildbot import cbuildbot_config
from chromite.cbuildbot import constants
@@ -22,7 +17,6 @@ from chromite.lib import cros_test_lib
from chromite.lib import gs_unittest
from chromite.lib import osutils
from chromite.lib import partial_mock
-
from chromite.scripts import cros_best_revision
@@ -123,7 +117,3 @@ class ChromeCommitterTester(cros_build_lib_unittest.RunCommandTestCase,
# Check the file was actually written out correctly.
self.assertEqual(osutils.ReadFile(self.lkgm_file), self.committer._lkgm)
self.assertCommandContains(['git', 'cl', 'land'])
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cros_generate_breakpad_symbols_unittest b/scripts/cros_generate_breakpad_symbols_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_generate_breakpad_symbols_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_generate_breakpad_symbols_unittest.py b/scripts/cros_generate_breakpad_symbols_unittest.py
index 4380d49b4..2e9d5e0d9 100755..100644
--- a/scripts/cros_generate_breakpad_symbols_unittest.py
+++ b/scripts/cros_generate_breakpad_symbols_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,12 +8,10 @@ from __future__ import print_function
import ctypes
import logging
+import mock
import os
import StringIO
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_build_lib_unittest
from chromite.lib import cros_test_lib
from chromite.lib import osutils
@@ -23,10 +20,6 @@ from chromite.lib import parallel_unittest
from chromite.lib import partial_mock
from chromite.scripts import cros_generate_breakpad_symbols
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
class FindDebugDirMock(partial_mock.PartialMock):
"""Mock out the DebugDir helper so we can point it to a tempdir."""
@@ -381,11 +374,11 @@ class UtilsTest(cros_test_lib.TestCase):
self.assertEquals(expected, result)
-if __name__ == '__main__':
+def main(_argv):
# pylint: disable=W0212
# Set timeouts small so that if the unit test hangs, it won't hang for long.
parallel._BackgroundTask.STARTUP_TIMEOUT = 5
parallel._BackgroundTask.EXIT_TIMEOUT = 5
# Run the tests.
- cros_test_lib.main(level=logging.INFO)
+ cros_test_lib.main(level=logging.INFO, module=__name__)
diff --git a/scripts/cros_generate_sysroot_unittest b/scripts/cros_generate_sysroot_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_generate_sysroot_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_generate_sysroot_unittest.py b/scripts/cros_generate_sysroot_unittest.py
index 50e5e45bd..fcb5e30b3 100755..100644
--- a/scripts/cros_generate_sysroot_unittest.py
+++ b/scripts/cros_generate_sysroot_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,11 +6,9 @@
from __future__ import print_function
+import mock
import os
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.cbuildbot import constants
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
@@ -19,10 +16,6 @@ from chromite.scripts import cros_generate_sysroot as cros_gen
from chromite.lib import osutils
from chromite.lib import partial_mock
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
Dir = cros_test_lib.Directory
@@ -103,7 +96,3 @@ class InterfaceTest(cros_test_lib.TempDirTestCase):
constants.CHROME_CP])
self.assertRaises(cros_build_lib.DieSystemExit,
cros_gen.FinishParsing, options)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cros_install_debug_syms_unittest b/scripts/cros_install_debug_syms_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_install_debug_syms_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_install_debug_syms_unittest.py b/scripts/cros_install_debug_syms_unittest.py
index b1fa3f876..e993f13ae 100755..100644
--- a/scripts/cros_install_debug_syms_unittest.py
+++ b/scripts/cros_install_debug_syms_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,10 +8,6 @@ from __future__ import print_function
from collections import namedtuple
import os
-import sys
-
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_test_lib
from chromite.scripts import cros_install_debug_syms
@@ -82,7 +77,3 @@ class InstallDebugSymsTest(cros_test_lib.MockTestCase):
'/paladin1234/shill-0-r1.debug.tbz2')
self.assertEquals(cros_install_debug_syms.ListBinhost(binhost),
{'chromeos-base/shill-0-r1': debug_symbols_url})
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cros_list_modified_packages_unittest b/scripts/cros_list_modified_packages_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_list_modified_packages_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_list_modified_packages_unittest.py b/scripts/cros_list_modified_packages_unittest.py
index 79e51c625..9f91e6089 100755..100644
--- a/scripts/cros_list_modified_packages_unittest.py
+++ b/scripts/cros_list_modified_packages_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,11 +7,6 @@
from __future__ import print_function
import functools
-import os
-import sys
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_test_lib
from chromite.scripts import cros_list_modified_packages
@@ -36,7 +30,3 @@ class ListModifiedWorkonPackagesTest(cros_test_lib.MockTestCase):
# from it to get it to exercise the code, and we can do that by turning
# it into a list.
list(cros_list_modified_packages.ListModifiedWorkonPackages(None, True))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cros_list_overlays_unittest b/scripts/cros_list_overlays_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_list_overlays_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_list_overlays_unittest.py b/scripts/cros_list_overlays_unittest.py
index a5b49d380..f04bc341d 100755..100644
--- a/scripts/cros_list_overlays_unittest.py
+++ b/scripts/cros_list_overlays_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,11 +7,7 @@
from __future__ import print_function
import logging
-import os
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_test_lib
from chromite.lib import portage_util
from chromite.scripts import cros_list_overlays
@@ -34,5 +29,5 @@ class ListOverlaysTest(cros_test_lib.MockTestCase):
cros_list_overlays.main(['--primary_only', '--board', 'foo'])
-if __name__ == '__main__':
- cros_test_lib.main(level=logging.INFO)
+def main(_argv):
+ cros_test_lib.main(level=logging.INFO, module=__name__)
diff --git a/scripts/cros_mark_as_stable_unittest b/scripts/cros_mark_as_stable_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_mark_as_stable_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_mark_as_stable_unittest.py b/scripts/cros_mark_as_stable_unittest.py
index 5b1329e1d..449cd1856 100755..100644
--- a/scripts/cros_mark_as_stable_unittest.py
+++ b/scripts/cros_mark_as_stable_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,11 +6,8 @@
from __future__ import print_function
-import os
-import sys
+import mock
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_build_lib
from chromite.lib import cros_build_lib_unittest
from chromite.lib import cros_test_lib
@@ -21,10 +17,6 @@ from chromite.lib import parallel_unittest
from chromite.lib import partial_mock
from chromite.scripts import cros_mark_as_stable
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
class RunGitMock(partial_mock.PartialCmdMock):
"""Partial mock for git.RunMock."""
@@ -156,7 +148,3 @@ class GitBranchTest(cros_test_lib.MockTestCase):
result = cros_build_lib.CommandResult(output=self._branch_name + '\n')
self.PatchObject(git, 'RunGit', return_value=result)
self.assertTrue(self._branch.Exists())
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cros_mark_chrome_as_stable_unittest b/scripts/cros_mark_chrome_as_stable_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_mark_chrome_as_stable_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_mark_chrome_as_stable_unittest.py b/scripts/cros_mark_chrome_as_stable_unittest.py
index 946dc8ff3..6580c1ded 100755..100644
--- a/scripts/cros_mark_chrome_as_stable_unittest.py
+++ b/scripts/cros_mark_chrome_as_stable_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,12 +8,10 @@ from __future__ import print_function
import base64
import cStringIO
+import mock
import os
-import sys
from textwrap import dedent
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.cbuildbot import constants
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
@@ -24,10 +21,6 @@ from chromite.lib import osutils
from chromite.lib import portage_util
from chromite.scripts import cros_mark_chrome_as_stable
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
unstable_data = 'KEYWORDS=~x86 ~arm'
stable_data = 'KEYWORDS=x86 arm'
@@ -288,7 +281,3 @@ class CrosMarkChromeAsStable(cros_test_lib.MockTempDirTestCase):
constants.CHROME_REV_TOT,
self.tot_new_version, self.tot_stable,
self.tot_new, 'tot')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cros_mark_mojo_as_stable_unittest b/scripts/cros_mark_mojo_as_stable_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_mark_mojo_as_stable_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_mark_mojo_as_stable_unittest.py b/scripts/cros_mark_mojo_as_stable_unittest.py
index 3884b531f..1427ce51a 100755..100644
--- a/scripts/cros_mark_mojo_as_stable_unittest.py
+++ b/scripts/cros_mark_mojo_as_stable_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,6 +7,7 @@
from __future__ import print_function
import datetime
+import mock
import os
from chromite.lib import cros_test_lib
@@ -17,10 +17,6 @@ from chromite.lib import portage_util
from chromite.scripts import cros_mark_as_stable
from chromite.scripts import cros_mark_mojo_as_stable
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
class CrosMarkChromeAsStableTestCase(cros_test_lib.MockTempDirTestCase):
"""Various test helpers for cros_mark_mojo_as_stable."""
@@ -114,7 +110,3 @@ class UprevStableEBuildTest(CrosMarkChromeAsStableTestCase):
commit_mock.assert_called_once_with(
'Updated dev-libs/mojo to upstream commit 1234ab.',
self.fake_ebuild_dir)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cros_portage_upgrade_unittest b/scripts/cros_portage_upgrade_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_portage_upgrade_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_portage_upgrade_unittest.py b/scripts/cros_portage_upgrade_unittest.py
index b36041533..9cb6e5989 100755..100644
--- a/scripts/cros_portage_upgrade_unittest.py
+++ b/scripts/cros_portage_upgrade_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -13,12 +12,9 @@ import mox
import os
import re
import shutil
-import sys
import tempfile
import unittest
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
from chromite.lib import osutils
@@ -3631,7 +3627,3 @@ class MainTest(CpuTestBase):
'--to-csv=/dev/null', 'any-package'],
expect_zero=True)
self.mox.VerifyAll()
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/cros_unittest b/scripts/cros_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/cros_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/cros_unittest.py b/scripts/cros_unittest.py
index 9d5f7cf4c..20be9a7eb 100755..100644
--- a/scripts/cros_unittest.py
+++ b/scripts/cros_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,10 +6,6 @@
from __future__ import print_function
-import os
-import sys
-
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.lib import cros_test_lib
from chromite.lib import stats
from chromite.lib import stats_unittest
@@ -39,7 +34,3 @@ class RunScriptTest(cros_test_lib.MockTempDirTestCase):
self.stats_module_mock.stats_mock.init_exception = True
with cros_test_lib.LoggingCapturer():
self.testStatsUpload(upload_count=0)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/dep_tracker_unittest b/scripts/dep_tracker_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/dep_tracker_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/dep_tracker_unittest.py b/scripts/dep_tracker_unittest.py
index f4456051b..089fb7e70 100755..100644
--- a/scripts/dep_tracker_unittest.py
+++ b/scripts/dep_tracker_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,7 @@
from __future__ import print_function
import os
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_test_lib
from chromite.lib import osutils
from chromite.lib import unittest_lib
@@ -72,7 +68,3 @@ class DepTrackerTest(cros_test_lib.TempDirTestCase):
dt.ComputeFileTypes()
self.assertTrue('ftype' in dt._files['libabc.so'])
self.assertTrue('ftype' in dt._files['pyscript'])
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/deploy_chrome_unittest b/scripts/deploy_chrome_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/deploy_chrome_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/deploy_chrome_unittest.py b/scripts/deploy_chrome_unittest.py
index f9976ed14..260444c81 100755..100644
--- a/scripts/deploy_chrome_unittest.py
+++ b/scripts/deploy_chrome_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,13 +6,10 @@
from __future__ import print_function
+import mock
import os
-import sys
import time
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
-
from chromite.cros.commands import cros_chrome_sdk_unittest
from chromite.lib import chrome_util
from chromite.lib import cros_build_lib
@@ -24,15 +20,9 @@ from chromite.lib import remote_access
from chromite.lib import remote_access_unittest
from chromite.lib import stats
from chromite.lib import stats_unittest
-
from chromite.scripts import deploy_chrome
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
-import mock
-
-
# pylint: disable=W0212
_REGULAR_TO = ('--to', 'monkey')
@@ -365,6 +355,3 @@ class TestDeploymentType(DeployTestBuildDir):
self.assertTrue(self.getCopyPath('chrome'))
self.assertFalse(self.getCopyPath('app_shell'))
self.assertFalse(self.getCopyPath('envoy_shell'))
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/gather_builder_stats_unittest b/scripts/gather_builder_stats_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/gather_builder_stats_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/gather_builder_stats_unittest.py b/scripts/gather_builder_stats_unittest.py
index cc1eb3c35..a53fb53cb 100755..100644
--- a/scripts/gather_builder_stats_unittest.py
+++ b/scripts/gather_builder_stats_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,11 +8,9 @@ from __future__ import print_function
import datetime
import itertools
-import os
+import mock
import random
-import sys
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.lib import clactions
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
@@ -22,8 +19,6 @@ from chromite.scripts import gather_builder_stats
from chromite.cbuildbot import metadata_lib
from chromite.cbuildbot import constants
-import mock
-
REASON_BAD_CL = gather_builder_stats.CLStats.REASON_BAD_CL
CQ = constants.CQ
@@ -265,7 +260,3 @@ class TestCLActionLogic(cros_test_lib.TestCase):
't/4321']
self.assertEqual(gather_builder_stats.CLStats.ProcessBlameString(blame),
expected)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/generate_delta_sysroot_unittest b/scripts/generate_delta_sysroot_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/generate_delta_sysroot_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/generate_delta_sysroot_unittest.py b/scripts/generate_delta_sysroot_unittest.py
index 96b854dc1..f723e0a0b 100755..100644
--- a/scripts/generate_delta_sysroot_unittest.py
+++ b/scripts/generate_delta_sysroot_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,10 +7,6 @@
from __future__ import print_function
import os
-import sys
-
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
@@ -71,7 +66,3 @@ class TestCreateBatchFile(cros_test_lib.TempDirTestCase):
self.assertRaises2(
cros_build_lib.RunCommandError, gds.CreateBatchFile,
no_source, self.tempdir, os.path.join(self.tempdir, 'batch'))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/merge_package_status_unittest b/scripts/merge_package_status_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/merge_package_status_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/merge_package_status_unittest.py b/scripts/merge_package_status_unittest.py
index c4da1388a..067f90513 100755..100644
--- a/scripts/merge_package_status_unittest.py
+++ b/scripts/merge_package_status_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,11 +8,8 @@ from __future__ import print_function
import exceptions
import os
-import sys
import tempfile
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_test_lib
from chromite.lib import table
from chromite.scripts import merge_package_status as mps
@@ -278,7 +274,3 @@ class MainTest(cros_test_lib.MockOutputTestCase):
mps.main(['--out=any-out', 'any-package'])
m.assert_called_with('csv_table', 'any-out')
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/pushimage_unittest b/scripts/pushimage_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/pushimage_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/pushimage_unittest.py b/scripts/pushimage_unittest.py
index 03a68dd37..e7fb7616f 100755..100644
--- a/scripts/pushimage_unittest.py
+++ b/scripts/pushimage_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -10,10 +9,7 @@ from __future__ import print_function
import logging
import mock
import os
-import sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
from chromite.lib import gs
@@ -232,10 +228,10 @@ class MainTests(cros_test_lib.MockTestCase):
pushimage.main(['--board', 'test.board', '/src', '--yes'])
-if __name__ == '__main__':
+def main(_argv):
# Use our local copy of insns for testing as the main one is not
# available in the public manifest.
signing.INPUT_INSN_DIR = signing.TEST_INPUT_INSN_DIR
# Run the tests.
- cros_test_lib.main(level=logging.INFO)
+ cros_test_lib.main(level=logging.INFO, module=__name__)
diff --git a/scripts/sync_package_status_unittest b/scripts/sync_package_status_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/sync_package_status_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/sync_package_status_unittest.py b/scripts/sync_package_status_unittest.py
index 965f3e3d7..11b080381 100755..100644
--- a/scripts/sync_package_status_unittest.py
+++ b/scripts/sync_package_status_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,11 +6,6 @@
from __future__ import print_function
-import os
-import sys
-
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_test_lib
from chromite.lib import gdata_lib
from chromite.lib import upgrade_table as utable
@@ -544,7 +538,3 @@ class SyncerTest(cros_test_lib.MoxOutputTestCase):
with self.OutputCapturer():
sps.Syncer._ClearRowIssue(mocked_syncer, row_ix, row)
self.mox.VerifyAll()
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/test_image_unittest b/scripts/test_image_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/test_image_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/test_image_unittest.py b/scripts/test_image_unittest.py
index 178dc6b7d..b431d2e43 100755..100644
--- a/scripts/test_image_unittest.py
+++ b/scripts/test_image_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,11 +7,9 @@
from __future__ import print_function
import os
-import sys
import tempfile
import unittest
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import constants
from chromite.cros.tests import image_test
from chromite.lib import cros_build_lib
@@ -166,7 +163,3 @@ class MainTest(TestImageTest):
self.assertEqual('my-board', test._board)
# pylint: disable=W0212
self.assertEqual('your-root', os.path.basename(test._result_dir))
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/upload_command_stats_unittest b/scripts/upload_command_stats_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/upload_command_stats_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/upload_command_stats_unittest.py b/scripts/upload_command_stats_unittest.py
index e7b0ce49c..5a2818aac 100755..100644
--- a/scripts/upload_command_stats_unittest.py
+++ b/scripts/upload_command_stats_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,9 +7,7 @@
from __future__ import print_function
import os
-import sys
-sys.path.insert(0, os.path.abspath('%s/../..' % os.path.dirname(__file__)))
from chromite.cbuildbot import constants
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
@@ -85,7 +82,3 @@ class RunScriptTest(cros_test_lib.MockTempDirTestCase,
stats.StatsUploader._Upload.side_effect = Exception()
# Logging level for the error is logging.ERROR.
self.LogContainsOnError(upload_command_stats.UNCAUGHT_ERROR)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/upload_package_status_unittest b/scripts/upload_package_status_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/upload_package_status_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/upload_package_status_unittest.py b/scripts/upload_package_status_unittest.py
index d8e42b87c..d0dfd3b8f 100755..100644
--- a/scripts/upload_package_status_unittest.py
+++ b/scripts/upload_package_status_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -9,11 +8,7 @@ from __future__ import print_function
import exceptions
import mox
-import os
-import sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__)))))
from chromite.lib import cros_test_lib
from chromite.lib import gdata_lib
from chromite.lib import osutils
@@ -475,7 +470,3 @@ class MainTest(cros_test_lib.MoxOutputTestCase):
])
self.mox.VerifyAll()
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/upload_prebuilts_unittest b/scripts/upload_prebuilts_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/upload_prebuilts_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/upload_prebuilts_unittest.py b/scripts/upload_prebuilts_unittest.py
index 30dad8859..58f530458 100755..100644
--- a/scripts/upload_prebuilts_unittest.py
+++ b/scripts/upload_prebuilts_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -8,14 +7,12 @@
from __future__ import print_function
import copy
+import mock
import mox
import os
import multiprocessing
-import sys
import tempfile
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.scripts import upload_prebuilts as prebuilt
from chromite.lib import cros_test_lib
from chromite.lib import gs
@@ -23,8 +20,6 @@ from chromite.lib import binpkg
from chromite.lib import osutils
from chromite.lib import portage_util
-import mock
-
# pylint: disable=E1120,W0212,R0904
PUBLIC_PACKAGES = [{'CPV': 'gtk+/public1', 'SHA1': '1', 'MTIME': '1'},
@@ -526,7 +521,3 @@ class TestSdk(cros_test_lib.MockTestCase):
)
tc_upload_path = '1994/04/%(target)s-1994.04.02.tar.xz'
self.testSdkUpload(tc_tarballs, tc_upload_path)
-
-
-if __name__ == '__main__':
- cros_test_lib.main()
diff --git a/scripts/upload_symbols_unittest b/scripts/upload_symbols_unittest
new file mode 120000
index 000000000..b7045c598
--- /dev/null
+++ b/scripts/upload_symbols_unittest
@@ -0,0 +1 @@
+wrapper.py \ No newline at end of file
diff --git a/scripts/upload_symbols_unittest.py b/scripts/upload_symbols_unittest.py
index 462ab9be9..38c8c4f1e 100755..100644
--- a/scripts/upload_symbols_unittest.py
+++ b/scripts/upload_symbols_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -11,6 +10,7 @@ import BaseHTTPServer
import ctypes
import errno
import logging
+import mock
import multiprocessing
import os
import signal
@@ -27,8 +27,6 @@ import urllib2
# on the fly :(.
os.environ.pop('http_proxy', None)
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
from chromite.lib import osutils
@@ -38,10 +36,7 @@ from chromite.lib import remote_access
from chromite.scripts import cros_generate_breakpad_symbols
from chromite.scripts import upload_symbols
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
import isolateserver
-import mock
class SymbolServerRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
@@ -527,7 +522,7 @@ class UtilTest(cros_test_lib.TempDirTestCase):
self.assertEquals(exp_list, got_list)
-if __name__ == '__main__':
+def main(_argv):
# pylint: disable=W0212
# Set timeouts small so that if the unit test hangs, it won't hang for long.
parallel._BackgroundTask.STARTUP_TIMEOUT = 5
@@ -537,4 +532,4 @@ if __name__ == '__main__':
upload_symbols.INITIAL_RETRY_DELAY = 0
# Run the tests.
- cros_test_lib.main(level=logging.INFO)
+ cros_test_lib.main(level=logging.INFO, module=__name__)