libroach: use gtest in unitests#20594
Conversation
|
Shoot, we duplicated some work here. I've got a PR that adds some tests for our C++ encoding (8aa8ce9) that's been sidelined on other, unrelated changes in the PR. My bad! The good news is that our approach is more or less the same. I'd love to get those encoding tests merged, though, while we're adding libroach tests. @mberhault how do you want to proceed? |
|
Extracted and rebased here: #20595 |
|
Ah! funny! Let's get yours in, the main difference is in |
|
Added googletest for unittests, this should be more pleasant. |
c-deps/libroach/encoding_test.cc
Outdated
c-deps/libroach/encoding_test.cc
Outdated
There was a problem hiding this comment.
If you're bored, would be nice to let clang format handle these, but it totally mangles cases64 IMO.
c-deps/libroach/encoding_test.cc
Outdated
There was a problem hiding this comment.
Should be able to drop this variable now!
f96bb11 to
4e57fc7
Compare
4e57fc7 to
6ad711f
Compare
|
@benesch: rebased on your change, PTAL. Not much to be done about clang formatting I'm afraid. We can change some of the line merging things (eg: no one-line functions), but ultimately it parses everything then re-generates it from the AST so any arbitrary whitespace formatting is lost. |
4bf9684 to
3b7880c
Compare
Makefile
Outdated
There was a problem hiding this comment.
this is weird, Cmake fails when cross-compiling (acceptance tests for some reason). This is kind of the accepted answer (mentioned in the failure itself). I need the absolute path as we're running cmake from the temp build dir.
There was a problem hiding this comment.
Ugh, what a pain! I think we can at least avoid some of the complexity, though, by dropping
set(THREADS_PTHREAD_ARG "2" CACHE STRING "Forcibly set by CMakeLists.txt." FORCE)
into libroach's CMakeLists.txt instead of introducing the whole cachefile kit and caboodle.
Could you also add a comment linking to https://gitlab.kitware.com/cmake/cmake/issues/16920? Looks like this is fixed in CMake 3.10 and so this workaround should eventually become unnecessary.
benesch
left a comment
There was a problem hiding this comment.
I think you're doing too much work! Both CMake and the top-level Makefile are building googletest AFAICT.
There are two options I see:
- Let CMake handle building libgtest by simply removing all references to googletest from the top-level Makefile. In this case I think we should move the submodule to c-deps/libroach/googletest.
- Let top-level Make handle building libgtest, and set the library search paths appropriately for libroach, and potentially other libraries whose tests need libgtest, like Snappy.
I have a slight preference for the first option since it's simpler and we don't actually care about running Snappy's tests, but I don't have strong feelings.
| CXX_STANDARD_REQUIRED YES | ||
| CXX_EXTENSIONS NO | ||
| COMPILE_OPTIONS "-Werror;-Wall;-Wno-sign-compare" | ||
| ) |
There was a problem hiding this comment.
Shoot, I wish there were some way to share these properties across all targets. I don't know enough CMake to suggest a better alternative, though.
There was a problem hiding this comment.
yeah, I'm still fuzzy here, I've been meaning to check the rules for non-target properties. Is it "everything" after this point?
Makefile
Outdated
|
|
||
| PHONY: check-libroach | ||
| check-libroach: $(LIBROACH_DIR)/Makefile | ||
| check-libroach: $(LIBROACH_DIR)/Makefile libgtest |
There was a problem hiding this comment.
By my read, this libgtest is built into ~/go/native/TRIPLE/googletest and is actually entirely ignored by libroach's CMake, which builds its own version at ~/go/native/TRIPLE/libroach/googletest thanks to the magic of add_subdirectory.
There was a problem hiding this comment.
See main comment: our cmake doesn't build googletest, it just needs a built library it can link in. This is what add_subdirectory does.
|
Our cmake uses the built googletest by calling |
|
Now I’m terribly confused. add_subdirctory instructs CMake to build from
the sources in the subdirectory AIUI. I checked out your branch locally and
reverted all the changes to the top-level Makefile and `make
check-libroach` still worked just fine. What gives?
…On Sun, Dec 10, 2017 at 2:54 PM marc ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In Makefile
<#20594 (comment)>
:
> @@ -620,9 +630,13 @@ libroachccl: $(LIBROACH_DIR)/Makefile libroach
@$(MAKE) --no-print-directory -C $(LIBROACH_DIR) roachccl
PHONY: check-libroach
-check-libroach: $(LIBROACH_DIR)/Makefile
+check-libroach: $(LIBROACH_DIR)/Makefile libgtest
See main comment: our cmake doesn't build googletest, it just needs a
built library it can link in. This is what add_subdirectory does.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20594 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA15IKptZq0ER83ID8EoKCRSlmzHRXpaks5s_Db4gaJpZM4Q8J34>
.
|
|
Ok, ditto. I'm also very very confused, but that summarizes my week-end pretty well. |
|
Ok, all green. Damn, I need to read up on cmake I guess. |
36e0ddb to
55747d6
Compare
build/cmake_cache.txt
Outdated
| @@ -0,0 +1,3 @@ | |||
| # Cross-compilation does strange things with CMake. Tell it the pthreads check passes. | |||
| set(THREADS_PTHREAD_ARG "0" CACHE STRING "Result from TRY_RUN" FORCE) | |||
There was a problem hiding this comment.
By my read of https://github.com/Kitware/CMake/blob/v3.9.0/Modules/FindThreads.cmake, don't you want to set this to "2", not "0"?
There was a problem hiding this comment.
yeah, I've tried a number of things, including setting it in the libroach cmake only. The only thing that's worked so far is setting it as a cache preset using -C. I honestly don't want to play with this crap again. It's broken, and this fixes it.
There was a problem hiding this comment.
ugh, now it works. Let's see if TC agrees.
Makefile
Outdated
There was a problem hiding this comment.
Ugh, what a pain! I think we can at least avoid some of the complexity, though, by dropping
set(THREADS_PTHREAD_ARG "2" CACHE STRING "Forcibly set by CMakeLists.txt." FORCE)
into libroach's CMakeLists.txt instead of introducing the whole cachefile kit and caboodle.
Could you also add a comment linking to https://gitlab.kitware.com/cmake/cmake/issues/16920? Looks like this is fixed in CMake 3.10 and so this workaround should eventually become unnecessary.
benesch
left a comment
There was a problem hiding this comment.
Amazing, LGTM! Sorry this was such a chore.
Probably worth getting someone else to buy in on the googletest dependency too.
|
TFTR! @bdarnell: any thoughts? |
|
No no, I don’t feel strongly about its location! Happy with it where it is.
I mean the fact that we’re bringing in the dependency at all. If there’s a
policy on adding new C/C++ dependencies I don’t know it.
…On Mon, Dec 11, 2017 at 10:23 AM marc ***@***.***> wrote:
TFTR!
You mean the location of the googletest tree? I think keeping the
submodule in the same place as all the others is least surprising. But a
point could be made for sticking it in libroach/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20594 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA15IJ9qsQ-qQgKQ8BM2AyzVOCK_iiZeks5s_Uj7gaJpZM4Q8J34>
.
|
|
I don't think there is, and anything that can make unit testing easier is good in my book. |
|
Mk, SGTM. |
|
Peter doesn't care. Squashing and rebuilding. |
Release note: None Add new `googletest` c-dep and use it for libroach unitests. Add support for many unittests in libroach, with naming scheme based on the dir and filename. (eg: `ccl_libroach_ccl_test` for `ccl/libroach_ccl_test.cc`)
c1a74d1 to
2d310c7
Compare
We don't need it anymore. We originally introduced it to support tests in libroach (cockroachdb#20594), which has since been pared down to something much simpler (cockroachdb#55509, just DBDumpThreadStacks). Release note: None
55900: c-deps: remove googletest r=irfansharif a=irfansharif We don't need it anymore. We originally introduced it to support tests in libroach (#20594), which has since been pared down to something much simpler (#55509, just DBDumpThreadStacks). Release note: None Co-authored-by: irfan sharif <irfanmahmoudsharif@gmail.com>
Release Note: none.
Add new
googletestc-dep and use it for libroach unitests.Add support for many unittests in libroach, with naming scheme based on
the dir and filename. (eg:
ccl_libroach_ccl_testforccl/libroach_ccl_test.cc)