Internal fixes for code coverage testing.

PiperOrigin-RevId: 306261564
Change-Id: I8a2a1e867036f4678812025a504dfa684693c3a4
This commit is contained in:
Amit Patankar 2020-04-13 10:41:55 -07:00 committed by TensorFlower Gardener
parent da4fba5d6d
commit 056c2058c3
2 changed files with 2 additions and 18 deletions

View File

@ -19,7 +19,6 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
import collections import collections
import os
import sys import sys
from tensorflow.python.distribute import strategy_combinations from tensorflow.python.distribute import strategy_combinations
@ -36,12 +35,7 @@ _strategies = [
# The presence of GPU strategies upsets TPU initialization, # The presence of GPU strategies upsets TPU initialization,
# despite their test instances being skipped early. This is a workaround # despite their test instances being skipped early. This is a workaround
# for b/145386854. # for b/145386854.
# if "test_tpu" in sys.argv[0]:
# See comments in TestCase.assertCommandSucceeded for background on these
# sys.executable and TEST_BINARY checks.
if ("test_tpu" in sys.argv[0] or
(sys.executable is None and os.environ["TEST_BINARY"] is not None and
"test_tpu" in os.environ["TEST_BINARY"])):
_strategies = [s for s in _strategies if "GPU" not in str(s)] _strategies = [s for s in _strategies if "GPU" not in str(s)]

View File

@ -46,17 +46,7 @@ class TestCase(tf.test.TestCase):
def assertCommandSucceeded(self, script_name, **flags): def assertCommandSucceeded(self, script_name, **flags):
"""Runs an integration test script with given flags.""" """Runs an integration test script with given flags."""
run_script = sys.argv[0] run_script = sys.argv[0]
if run_script.endswith(".py"):
# sys.executable may be None in hermetic Python builds
# (go/hermeticpython#sysexecutable).
#
# TEST_BINARY is an undocumented part of the test environment, but it
# appears to be the only way to recover the path to the test binary under
# coverage runs - the coverage launcher script rewrites argv[0]
# (b/23027507).
if sys.executable is None and os.environ["TEST_BINARY"] is not None:
command_parts = [os.environ["TEST_BINARY"]]
elif run_script.endswith(".py"):
command_parts = [sys.executable, run_script] command_parts = [sys.executable, run_script]
else: else:
command_parts = [run_script] command_parts = [run_script]