Pass flag '--keep-going=y' running unit test for coverage.
By default 'parallel-emerge' will exit when run into certain package
failure, this causes fragile workflow for code coverage generation where
we should tolerent such failures and keep going.
This change check 'USE' vironment flags when running 'cros_run_unit_tests.py',
and pass extra '--keep-going=y' flags to parallel-emerge to avoid
fail-fast when detect we are running unit tests for code coverage
generation.
BUG=b:213941781
TEST=Check unit tests with 'cros_run_unit_tests.py' and
'parallel-emerge.py' respectively
Change-Id: I21c5027729ff72b495abb8dfdd4b7c348584cb7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3416103
Reviewed-by: David Welling <davidwelling@google.com>
Reviewed-by: Alex Klein <saklein@chromium.org>
Tested-by: Hengxiang Hu <hengxianghu@google.com>
Commit-Queue: Hengxiang Hu <hengxianghu@google.com>
diff --git a/scripts/cros_run_unit_tests_unittest.py b/scripts/cros_run_unit_tests_unittest.py
index 29e17a9..9d773c9 100644
--- a/scripts/cros_run_unit_tests_unittest.py
+++ b/scripts/cros_run_unit_tests_unittest.py
@@ -4,6 +4,8 @@
"""Unit tests for cros_run_unit_tests.py."""
+import os
+
from chromite.lib import cros_test_lib
from chromite.scripts import cros_run_unit_tests
@@ -11,10 +13,16 @@
pytestmark = cros_test_lib.pytestmark_inside_only
-class DetermineBoardPackagesTest(cros_test_lib.TestCase):
- """Tests that package determination returns a non-empty set"""
+class CrosRunUnitTestsTest(cros_test_lib.MockTestCase):
+ """Tests for cros_run_unit_tests functions."""
def testNonEmptyPackageSet(self):
"""Asserts that the deps of a known package are non-empty"""
self.assertTrue(cros_run_unit_tests.determine_packages(
'/', ('virtual/implicit-system',)))
+
+ def testGetKeepGoing(self):
+ """Tests set keep_going option based on env virables"""
+ self.PatchObject(os, 'environ', new={'USE': 'chrome_internal coverage'})
+ keep_going = cros_run_unit_tests.get_keep_going()
+ self.assertEqual(keep_going, True)