Commit c58f562f authored by Derek Mauro's avatar Derek Mauro Committed by Copybara-Service
Browse files

Makes the Python imports consistently use full paths from the repository root,

unifying the behavior between Bazel and CMake

This fixes one of the CI failures on Windows

PiperOrigin-RevId: 417872531
Change-Id: I156989323b7e6d4a4420f4f9691b078829db933d
parent 71d4e2f7
......@@ -31,7 +31,7 @@
"""Tests that leaked mock objects can be caught be Google Mock."""
import gmock_test_utils
from googlemock.test import gmock_test_utils
PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_leak_test_')
TEST_WITH_EXPECT_CALL = [PROGRAM_PATH, '--gtest_filter=*ExpectCall*']
......
......@@ -43,7 +43,7 @@ from io import open # pylint: disable=redefined-builtin, g-importing-member
import os
import re
import sys
import gmock_test_utils
from googlemock.test import gmock_test_utils
# The flag for generating the golden file
......
......@@ -30,21 +30,9 @@
"""Unit test utilities for Google C++ Mocking Framework."""
import os
import sys
# Determines path to gtest_test_utils and imports it.
SCRIPT_DIR = os.path.dirname(__file__) or '.'
# isdir resolves symbolic links.
gtest_tests_util_dir = os.path.join(SCRIPT_DIR, '../../googletest/test')
if os.path.isdir(gtest_tests_util_dir):
GTEST_TESTS_UTIL_DIR = gtest_tests_util_dir
else:
GTEST_TESTS_UTIL_DIR = os.path.join(SCRIPT_DIR, '../../googletest/test')
sys.path.append(GTEST_TESTS_UTIL_DIR)
# pylint: disable=C6204
import gtest_test_utils
from googletest.test import gtest_test_utils
def GetSourceDir():
......
......@@ -304,6 +304,8 @@ function(py_test name)
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN})
endif()
# Make the Python import path consistent between Bazel and CMake.
set_tests_properties(${name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR})
endif(PYTHONINTERP_FOUND)
endfunction()
......
......@@ -39,7 +39,7 @@ Google Test) with different environments and command line flags.
"""
import os
import gtest_test_utils
from googletest.test import gtest_test_utils
# Constants.
......
......@@ -35,7 +35,7 @@ googletest-catch-exceptions-ex-test_ (programs written with
Google Test) and verifies their output.
"""
import gtest_test_utils
from googletest.test import gtest_test_utils
# Constants.
FLAG_PREFIX = '--gtest_'
......
......@@ -32,7 +32,7 @@
"""Verifies that Google Test correctly determines whether to use colors."""
import os
import gtest_test_utils
from googletest.test import gtest_test_utils
IS_WINDOWS = os.name == 'nt'
......
......@@ -32,7 +32,7 @@
"""Verifies that Google Test correctly parses environment variables."""
import os
import gtest_test_utils
from googletest.test import gtest_test_utils
IS_WINDOWS = os.name == 'nt'
......
......@@ -41,7 +41,7 @@ line flags.
"""
import os
import gtest_test_utils
from googletest.test import gtest_test_utils
# Constants.
......
......@@ -47,7 +47,7 @@ try:
except ImportError:
pass
import sys
import gtest_test_utils
from googletest.test import gtest_test_utils
# Constants.
......
......@@ -36,7 +36,7 @@ googletest-global-environment-unittest_ (a program written with Google Test).
"""
import re
import gtest_test_utils
from googletest.test import gtest_test_utils
def RunAndReturnOutput(args=None):
......
......@@ -32,8 +32,8 @@
import json
import os
import gtest_json_test_utils
import gtest_test_utils
from googletest.test import gtest_json_test_utils
from googletest.test import gtest_test_utils
GTEST_OUTPUT_SUBDIR = 'json_outfiles'
GTEST_OUTPUT_1_TEST = 'gtest_xml_outfile1_test_'
......
......@@ -37,8 +37,8 @@ import os
import re
import sys
import gtest_json_test_utils
import gtest_test_utils
from googletest.test import gtest_json_test_utils
from googletest.test import gtest_test_utils
GTEST_FILTER_FLAG = '--gtest_filter'
GTEST_LIST_TESTS_FLAG = '--gtest_list_tests'
......
......@@ -38,7 +38,7 @@ Google Test) the command line flags.
"""
import re
import gtest_test_utils
from googletest.test import gtest_test_utils
# Constants.
......
......@@ -42,7 +42,7 @@ import difflib
import os
import re
import sys
import gtest_test_utils
from googletest.test import gtest_test_utils
# The flag for generating the golden file
......
......@@ -30,7 +30,7 @@
"""Verifies that Google Test warns the user when not initialized properly."""
import gtest_test_utils
from googletest.test import gtest_test_utils
binary_name = 'googletest-param-test-invalid-name1-test_'
COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name)
......
......@@ -30,7 +30,7 @@
"""Verifies that Google Test warns the user when not initialized properly."""
import gtest_test_utils
from googletest.test import gtest_test_utils
binary_name = 'googletest-param-test-invalid-name2-test_'
COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name)
......
......@@ -31,7 +31,7 @@
"""Verifies that SetUpTestSuite and TearDownTestSuite errors are noticed."""
import gtest_test_utils
from googletest.test import gtest_test_utils
COMMAND = gtest_test_utils.GetTestExecutablePath(
'googletest-setuptestsuite-test_')
......
......@@ -31,7 +31,7 @@
"""Verifies that test shuffling works."""
import os
import gtest_test_utils
from googletest.test import gtest_test_utils
# Command to run the googletest-shuffle-test_ program.
COMMAND = gtest_test_utils.GetTestExecutablePath('googletest-shuffle-test_')
......
......@@ -36,7 +36,7 @@ Google Test) with different environments and command line flags.
"""
import os
import gtest_test_utils
from googletest.test import gtest_test_utils
# Constants.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment