Skip to content

Commit

Permalink
Makes the Python imports consistently use full paths from the reposit…
Browse files Browse the repository at this point in the history
…ory root,

unifying the behavior between Bazel and CMake

This fixes one of the CI failures on Windows

PiperOrigin-RevId: 417872531
Change-Id: I156989323b7e6d4a4420f4f9691b078829db933d
  • Loading branch information
derekmauro authored and copybara-github committed Dec 22, 2021
1 parent 71d4e2f commit c58f562
Show file tree
Hide file tree
Showing 29 changed files with 34 additions and 44 deletions.
2 changes: 1 addition & 1 deletion googlemock/test/gmock_leak_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*']
Expand Down
2 changes: 1 addition & 1 deletion googlemock/test/gmock_output_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import os
import re
import sys
import gmock_test_utils
from googlemock.test import gmock_test_utils


# The flag for generating the golden file
Expand Down
14 changes: 1 addition & 13 deletions googlemock/test/gmock_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 2 additions & 0 deletions googletest/cmake/internal_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-break-on-failure-unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"""

import os
import gtest_test_utils
from googletest.test import gtest_test_utils

# Constants.

Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-catch-exceptions-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Google Test) and verifies their output.
"""

import gtest_test_utils
from googletest.test import gtest_test_utils

# Constants.
FLAG_PREFIX = '--gtest_'
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-color-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-env-var-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-failfast-unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"""

import os
import gtest_test_utils
from googletest.test import gtest_test_utils

# Constants.

Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-filter-unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
except ImportError:
pass
import sys
import gtest_test_utils
from googletest.test import gtest_test_utils

# Constants.

Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-global-environment-unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"""

import re
import gtest_test_utils
from googletest.test import gtest_test_utils


def RunAndReturnOutput(args=None):
Expand Down
4 changes: 2 additions & 2 deletions googletest/test/googletest-json-outfiles-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_'
Expand Down
4 changes: 2 additions & 2 deletions googletest/test/googletest-json-output-unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
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'
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-list-tests-unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"""

import re
import gtest_test_utils
from googletest.test import gtest_test_utils

# Constants.

Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-output-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import os
import re
import sys
import gtest_test_utils
from googletest.test import gtest_test_utils


# The flag for generating the golden file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-setuptestsuite-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_')
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-shuffle-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_')
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-throw-on-failure-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"""

import os
import gtest_test_utils
from googletest.test import gtest_test_utils


# Constants.
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-uninitialized-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

"""Verifies that Google Test warns the user when not initialized properly."""

import gtest_test_utils
from googletest.test import gtest_test_utils

COMMAND = gtest_test_utils.GetTestExecutablePath('googletest-uninitialized-test_')

Expand Down
2 changes: 1 addition & 1 deletion googletest/test/gtest_help_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

import os
import re
import gtest_test_utils
from googletest.test import gtest_test_utils


IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/gtest_list_output_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

import os
import re
import gtest_test_utils
from googletest.test import gtest_test_utils

GTEST_LIST_TESTS_FLAG = '--gtest_list_tests'
GTEST_OUTPUT_FLAG = '--gtest_output'
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/gtest_skip_check_output_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import re

import gtest_test_utils
from googletest.test import gtest_test_utils

# Path to the gtest_skip_in_environment_setup_test binary
EXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_skip_test')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
output.
"""

import gtest_test_utils
from googletest.test import gtest_test_utils

# Path to the gtest_skip_in_environment_setup_test binary
EXE_PATH = gtest_test_utils.GetTestExecutablePath(
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/gtest_testbridge_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import os

import gtest_test_utils
from googletest.test import gtest_test_utils

binary_name = 'gtest_testbridge_test_'
COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name)
Expand Down
4 changes: 2 additions & 2 deletions googletest/test/gtest_xml_outfiles_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

import os
from xml.dom import minidom, Node
import gtest_test_utils
import gtest_xml_test_utils
from googletest.test import gtest_test_utils
from googletest.test import gtest_xml_test_utils

GTEST_OUTPUT_SUBDIR = "xml_outfiles"
GTEST_OUTPUT_1_TEST = "gtest_xml_outfile1_test_"
Expand Down
4 changes: 2 additions & 2 deletions googletest/test/gtest_xml_output_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
import sys
from xml.dom import minidom, Node

import gtest_test_utils
import gtest_xml_test_utils
from googletest.test import gtest_test_utils
from googletest.test import gtest_xml_test_utils

GTEST_FILTER_FLAG = '--gtest_filter'
GTEST_LIST_TESTS_FLAG = '--gtest_list_tests'
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/gtest_xml_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import re
from xml.dom import minidom, Node
import gtest_test_utils
from googletest.test import gtest_test_utils

GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml'

Expand Down

0 comments on commit c58f562

Please sign in to comment.