-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build googletest only if testing or basic benchmarking are enabled #1666
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loos good to me.
@amitkdutta thanks for the review. Looks like there are a couple of more |
cb8f53d
to
6d6beb9
Compare
6d6beb9
to
d586cf6
Compare
@amitkdutta can you take another look? The S3 test failure is unrelated. |
@kgpai @amitkdutta can you take another look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@majetideepak Nice.
@@ -292,6 +292,14 @@ if(VELOX_BUILD_TESTING AND NOT VELOX_ENABLE_DUCKDB) | |||
) | |||
endif() | |||
|
|||
# Benchmarks and tests at some places are coupled which is not great. See | |||
# velox/vector/CMakeLists.txt. TODO: Decouple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, file an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
velox/common/base/GTestMacros.h
Outdated
#ifdef VELOX_ENABLE_GOOGLETEST | ||
#include <gtest/gtest_prod.h> | ||
#else | ||
#define FRIEND_TEST(X, Y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Perhaps, add a comment to explain why is it Ok to replace this macro with "nothing".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. Thanks.
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks Deepak.
I'm getting errors:
|
@mbasmanova Can you share some more context from the error log. Does it see the previous definition from the gtest header? Thanks. |
@majetideepak Here is what I get:
|
I assume something else is including gtest_prod.h |
Maybe add an #ifndef guard? |
Getting more errors
|
I wonder if we end up having one definition is some cases and another in other cases. |
velox/common/base/GTestMacros.h
Outdated
|
||
#pragma once | ||
|
||
#ifdef VELOX_ENABLE_GOOGLETEST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? Shouldn't we just not compile the code that includes gtest unless a specific variable is set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you observed, FRIEND_TEST is coupled with non-test code.
third_party/CMakeLists.txt
Outdated
@@ -11,5 +11,9 @@ | |||
# 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. | |||
add_subdirectory(googletest) | |||
|
|||
if(VELOX_ENABLE_GOOGLETEST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use VELOX_BUILD_TESTING here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since googletest is needed by both VELOX_BUILD_TESTING
and VELOX_ENABLE_BENCHMARKS_BASIC
as some of the benchmarks are coupled with the test classes.
So VELOX_ENABLE_GOOGLETEST
is a proxy for either.
I wonder if we could get rid of usages of FRIEND_TEST macro altogether. |
Tight coupling that is created by using FRIEND_TEST macro doesn't feel quite right. |
One option might be to introduce a new macro VELOX_FRIEND_TEST and define it as nothing if VELOX_BUILD_TESTING is off and FRIEND_TEST if on. |
FRIEND_TEST macro is really simple (see below) and I don't think https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest_prod.h#L57
|
I see your point. Then changing |
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
velox/common/base/GTestMacros.h
Outdated
|
||
#pragma once | ||
|
||
#ifdef VELOX_ENABLE_GOOGLETEST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it is possible to have this ON by default. Otherwise, I'll need to figure out how too enable this for all the libraries that use it internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this. Let me know if it does not work.
velox/common/base/GTestMacros.h
Outdated
|
||
#pragma once | ||
|
||
#ifdef VELOX_ENABLE_GOOGLETEST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I should have been clearer. I think I need #include <gtest/gtest_prod.h> to happen by default, e.g. without setting any variable as I don't have these variables in the internal build files. Is this possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. maybe we could have VELOX_DISABLE_GOOGLETEST variable instead of VELOX_ENABLE_GOOGLETEST
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change. I realized it should work for non-CMake systems as well by default.
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
TorchArrow build starts to fail after submodule update to this commit: https://github.com/facebookresearch/torcharrow/runs/6605394261?check_suite_focus=true (Velox submodule commit: 118feb5), since
Build succeed with the previous commit (3591bbe) : https://github.com/facebookresearch/torcharrow/runs/6604765945?check_suite_focus=true Looks like cc @kgpai |
@majetideepak @kgpai Presto CPP builds are failing as well.
|
@amitkdutta I found manually set compiler flag Basically there is
(it needs #1745 to avoid linker error) My guess (I am a CMake noob so I can be totally wrong) the compiler flag set at Line 317 in 118feb5
presto-cpp and torcharrow use Velox as submodule, thus their compiler flag doesn't get VELOX_DISABLE_GOOGLETEST set on )
Update: never mind, presto-cpp indeed needs GTest; this is different from TorchArrow |
@amitkdutta #1738 should fix the presto_cpp failure |
…acebookincubator#1666) Summary: Also, adds a dummy definition for`FRIEND_TEST` when googletest is disabled. Resolves facebookincubator#1654 Pull Request resolved: facebookincubator#1666 Reviewed By: kgpai Differential Revision: D36664732 Pulled By: mbasmanova fbshipit-source-id: a08859f96f68d5bc9d2c5092be6f7f397508706f
…acebookincubator#1666) Summary: Also, adds a dummy definition for`FRIEND_TEST` when googletest is disabled. Resolves facebookincubator#1654 Pull Request resolved: facebookincubator#1666 Reviewed By: kgpai Differential Revision: D36664732 Pulled By: mbasmanova fbshipit-source-id: a08859f96f68d5bc9d2c5092be6f7f397508706f
Also, adds a dummy definition for
FRIEND_TEST
when googletest is disabled.Resolves #1654