Make sure the gradient_input_output_exclusions_test is resilient to windows line endings.

PiperOrigin-RevId: 294928721
Change-Id: Iee085bd4d2fcb0a050be178663f0ef7d495d5211
This commit is contained in:
Gunhan Gulsoy 2020-02-13 09:10:01 -08:00 committed by TensorFlower Gardener
parent dd73c93fd0
commit bf2dda9d90

View File

@ -34,8 +34,14 @@ class GradientInputOutputExclusionsTest(test.TestCase):
resource_loader.get_root_dir_with_all_resources(),
resource_loader.get_path_to_datafile("pywrap_gradient_exclusions.cc"))
actual_contents = file_io.read_file_to_string(filename)
# On windows, one or both of these strings may have CRLF line endings.
# To make sure, sanitize both:
sanitized_actual_contents = actual_contents.replace("\r", "")
sanitized_expected_contents = expected_contents.replace("\r", "")
self.assertEqual(
actual_contents, expected_contents, """
sanitized_actual_contents, sanitized_expected_contents, """
pywrap_gradient_exclusions.cc needs to be updated.
Please regenerate using:
bazel run tensorflow/python/eager:gradient_input_output_exclusions -- $PWD/tensorflow/python/eager/pywrap_gradient_exclusions.cc"""