compile_build_api_proto: add compiles test.
Add a test that runs the compile script and verifies it produces
*something* as a quick verification it's working.
BUG=b:187795298
TEST=./run_pytest
Change-Id: I262e5c7485b0b5a06b9585112336ae8ffd164402
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2717371
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
diff --git a/scripts/run_tests.py b/scripts/run_tests.py
index d7fa566..0dfdb01 100644
--- a/scripts/run_tests.py
+++ b/scripts/run_tests.py
@@ -26,6 +26,7 @@
import pytest # pylint: disable=import-error
+from chromite.api import compile_build_api_proto
from chromite.lib import commandline
from chromite.lib import constants
from chromite.lib import cros_build_lib
@@ -54,9 +55,7 @@
if opts.network:
pytest_args += ['-m', 'not network_test or network_test']
- # This is a cheesy hack to make sure gsutil is populated in the cache before
- # we run tests. This is a partial workaround for crbug.com/468838.
- gs.GSContext.InitializeCache()
+ precache()
if opts.quick:
logging.info('Skipping test namespacing due to --quickstart.')
@@ -83,6 +82,16 @@
sys.exit(pytest.main(pytest_args))
+def precache():
+ """Do some network-dependent stuff before we disallow network access."""
+ # This is a cheesy hack to make sure gsutil is populated in the cache before
+ # we run tests. This is a partial workaround for crbug.com/468838.
+ gs.GSContext.InitializeCache()
+ # Ensure protoc is installed for api/compile_build_api_proto_unittest.
+ compile_build_api_proto.InstallProtoc(
+ compile_build_api_proto.ProtocVersion.CHROMITE)
+
+
def re_execute_with_namespace(argv, network=False):
"""Re-execute as root so we can unshare resources."""
if osutils.IsNonRootUser():