gtest + ekam

18 views
Skip to first unread message

Aaron Jacobs

unread,
Nov 21, 2010, 3:57:06 PM11/21/10
to Ekam
What's the proper way to include gtest in my source tree so that I can
write tests that use it?

I got it to work by downloading the released version and putting these
files from its fused-src/ directory into my project's src/gtest/
directory:

gtest-all.cc
gtest.h
gtest_main.cc

As I said that did work, but I'm sure I'm missing out on some
parallelization in my build by using the "one gigantic source file"
distribution. Since the proto buffer project builds and its test's run
I tried copying its gtest/ directory, but with that setup I get lots
of errors, not the least of which is

Undefined symbols:
"testing::Test::~Test()", referenced from:
[...]

Is this a known issue, or have I done it wrong?

Aaron

Kenton Varda

unread,
Nov 21, 2010, 4:22:55 PM11/21/10
to Aaron Jacobs, Ekam
Hmm.  It appears that if gtest is placed at src/gtest, it doesn't fully compile, but if it is placed at src/foo/gtest, then it works great.

Ah, I see, this is because of a temporary hack in include.ekam-rule that I added to make gtest work:
  # HACK:  gtest likes to include things from its top-level directory.
  # TODO:  Come up with a more general way for dealing with this.
  INCLUDE_NAME=${INPUT##*/gtest/}
  if test "$INCLUDE_NAME" != "$INPUT"; then
    echo provide "$INPUT" "c++header:$INCLUDE_NAME"
  fi

The problem is that "*/gtest/" doesn't match "gtest/".  It would be easy to fix the hack, but it's still a hack.  The "correct" solution will take longer.  For now, can you just put gtest into a sub-directory?  And do use the gtest that came with protobuf 1.3.0 since that's the one that I've tested.


--
You received this message because you are subscribed to the Google Groups "Ekam" group.
To post to this group, send email to ekam...@googlegroups.com.
To unsubscribe from this group, send email to ekam-tool+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ekam-tool?hl=en.


Aaron Jacobs

unread,
Nov 22, 2010, 3:20:17 AM11/22/10
to Kenton Varda, Ekam
Thanks, putting it in src/third_party/gtest eventually worked, though
for the record I deleted the following things before it compiled
without error:

codegear/
samples/
src/gtest-all.cc
test/
xcode/

Aaron

Aaron Jacobs

unread,
Nov 22, 2010, 7:34:15 AM11/22/10
to Kenton Varda, Ekam
...on a related note, I don't suppose you've had any luck with getting
googlemock to work? I've tried several different configurations, each
with their own problems.

Kenton Varda

unread,
Nov 22, 2010, 2:08:38 PM11/22/10
to Aaron Jacobs, Ekam
Yep, that makes sense.  For the moment there are still some peripheral compile errors in gtest, but the core library compiles fine.

Haven't tried it, sorry.  It may require more temporary hacks.

Aaron Jacobs

unread,
Nov 22, 2010, 3:58:31 PM11/22/10
to Kenton Varda, Ekam
On Tue, Nov 23, 2010 at 6:08 AM, Kenton Varda <temp...@gmail.com> wrote:
> Haven't tried it, sorry.  It may require more temporary hacks.

FYI, I got it to work by switching to the gtest version that comes
with gmock (away from the protobuf one). Not sure where each comes
from, but the headers are significantly different.

Reply all
Reply to author
Forward
0 new messages