diff options
author | Tom Craig <tommycraig@gmail.com> | 2022-03-23 18:44:55 -0700 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-03-25 16:24:25 +0000 |
commit | b894ed693733c9a24fd14f926e395717769e788f (patch) | |
tree | f0d7dd719b433dbab657677a18008054338756bf | |
parent | 1425cfb38a13dc1e3a01adfffee2565bc5e9b83a (diff) | |
download | pigweed-b894ed693733c9a24fd14f926e395717769e788f.tar.gz |
pw_package: Add googletest
Adds a googletest plugin to pw_package for users who want the full
googletest/googlemock featureset.
Change-Id: I06102da6f175690d6238a1817b0a85d2c7843513
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/88934
Reviewed-by: Rob Mohr <mohrr@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Armando Montanez <amontanez@google.com>
-rw-r--r-- | pw_package/py/BUILD.gn | 1 | ||||
-rw-r--r-- | pw_package/py/pw_package/packages/googletest.py | 40 | ||||
-rw-r--r-- | pw_package/py/pw_package/pigweed_packages.py | 1 | ||||
-rw-r--r-- | pw_unit_test/docs.rst | 20 |
4 files changed, 62 insertions, 0 deletions
diff --git a/pw_package/py/BUILD.gn b/pw_package/py/BUILD.gn index 3f86f8709..03d49e746 100644 --- a/pw_package/py/BUILD.gn +++ b/pw_package/py/BUILD.gn @@ -32,6 +32,7 @@ pw_python_package("py") { "pw_package/packages/chromium_verifier.py", "pw_package/packages/crlset.py", "pw_package/packages/freertos.py", + "pw_package/packages/googletest.py", "pw_package/packages/mbedtls.py", "pw_package/packages/micro_ecc.py", "pw_package/packages/nanopb.py", diff --git a/pw_package/py/pw_package/packages/googletest.py b/pw_package/py/pw_package/packages/googletest.py new file mode 100644 index 000000000..adfb4e8d8 --- /dev/null +++ b/pw_package/py/pw_package/packages/googletest.py @@ -0,0 +1,40 @@ +# Copyright 2022 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +"""Install and check status of googletest.""" + +import pathlib +from typing import Sequence + +import pw_package.git_repo +import pw_package.package_manager + + +class Googletest(pw_package.git_repo.GitRepo): + """Install and check status of googletest.""" + def __init__(self, *args, **kwargs): + super().__init__(*args, + name='googletest', + url='https://github.com/google/googletest', + commit='073293463e1733c5e931313da1c3f1de044e1db3', + **kwargs) + + def info(self, path: pathlib.Path) -> Sequence[str]: + return ( + f'{self.name} installed in: {path}', + "Enable by running 'gn args out' and adding this line:", + f' dir_pw_third_party_googletest = "{path}"', + ) + + +pw_package.package_manager.register(Googletest) diff --git a/pw_package/py/pw_package/pigweed_packages.py b/pw_package/py/pw_package/pigweed_packages.py index de4a9e0f7..98c3a8210 100644 --- a/pw_package/py/pw_package/pigweed_packages.py +++ b/pw_package/py/pw_package/pigweed_packages.py @@ -21,6 +21,7 @@ from pw_package.packages import boringssl # pylint: disable=unused-import from pw_package.packages import chromium_verifier # pylint: disable=unused-import from pw_package.packages import crlset # pylint: disable=unused-import from pw_package.packages import freertos # pylint: disable=unused-import +from pw_package.packages import googletest # pylint: disable=unused-import from pw_package.packages import mbedtls # pylint: disable=unused-import from pw_package.packages import micro_ecc # pylint: disable=unused-import from pw_package.packages import nanopb diff --git a/pw_unit_test/docs.rst b/pw_unit_test/docs.rst index 492a92e28..f96c56abc 100644 --- a/pw_unit_test/docs.rst +++ b/pw_unit_test/docs.rst @@ -43,6 +43,9 @@ the Google Test documentation for examples of to define unit test cases. To request a feature addition, please `let us know <mailto:pigweed@googlegroups.com>`_. + See `Using upstream Googletest and Googlemock` below for information + about using upstream Googletest instead. + ------------------------ Using the test framework ------------------------ @@ -387,3 +390,20 @@ this module. The size of the memory pool to use for test fixture instances. By default this is set to 16K. + +Using upstream Googletest and Googlemock +======================================== + +If you want to use the full upstream Googletest/Googlemock, you must do the +following: + +* Set the GN var ``dir_pw_third_party_googletest`` to the location of the + googletest source. You can use ``pw package install googletest`` to fetch the + source if desired. +* Set the GN var ``pw_unit_test_MAIN = "//third_party/googletest:gmock_main"`` +* Set the GN var ``pw_unit_test_PUBLIC_DEPS = [ "//third_party/googletest" ]`` + +.. note:: + + Not all unit tests build properly with upstream Googletest yet. This is a + work in progress. |