Google Test 1.2.1 amalgamation

168 views
Skip to first unread message

Alexander Demin

unread,
Jan 17, 2009, 2:20:10 PM1/17/09
to Google C++ Testing Framework
Hi,

I have been using gtest a couple of month and I've found it incredible
handy and easy to use. I work on many platforms and compilers in
parallel that's why I prefer to include gtest to the project in
sources rather than pre-compile it to the binary library. Starting
from 1.2.1 there is the gtest-all.cc for that and it's great. But one
thing bothers me -- the necessity to keep in mind all .cc and .h from
the gtest when copying and moving it from one place to another. It's
really annoying because gtest is perfect for any swift hacks and
experiments so I like to have it at hand in a second on for any
machine or compiler. I wanted to have only two files -- gtest.cc and
gtest.h.

Ok, here is the result -- the gtest amalgamation. The idea is exactly
the same as the sqlite distribution does -- all sources in one single
file and the same for the headers. There is nothing special -- just
the careful concatenation of all .cc in to gtest.cc and all into
gtest.h. Also I've cut the duplicated copyright text. Nothing more.
Each .h file is included only once of course.

I agree that for the gtest internal development and when using gtest
by pre-compilation as the pre-compiled binary etc -- it's not so
comfortable to work with an amalgamation and maintain it. But it's
great to have as an option generated automatically. I did it almost
manually but it's possible to automate it when releasing.

I put my stuff there -- http://www.demin.ws/gtest/gtest-amalgamation-1.2.1.zip

Regards,
Alexander

Alexander Demin

unread,
Jan 17, 2009, 7:28:07 PM1/17/09
to Google C++ Testing Framework
By the way I have been using another Google testing framework for C --
cmockery and this library is quite simple for using from the source.
Only two files required: cmockery.c and cmockery.h. Anyway, my point
is that the same option could be great for Google Test too.

Alexander

Zhanyong Wan (λx.x x)

unread,
Jan 18, 2009, 3:06:56 AM1/18/09
to Alexander Demin, Google C++ Testing Framework
Hi Alexander,

I like the idea. Thanks for suggesting it!

I've written a Python script to automate this. Just run
'fuse_gtest.py output_dir' and it will create two files:
output_dir/gtest/gtest.h and output_dir/gtest/gtest-all.cc.

The gtest folder is created such that tests can continue to #include
<gtest/gtest.h>. The .cc file is called gtest-all.cc instead of
gtest.cc for a similar reason.

I'll have the script cleaned up and reviewed next week. It will
probably be part of the next gtest release.

Thanks,

--
Zhanyong

Alexander Demin

unread,
Jan 18, 2009, 4:47:34 AM1/18/09
to Zhanyong Wan (λx.x x), Google C++ Testing Framework
That's great. Thanks.

Zhanyong Wan (λx.x x)

unread,
Jan 21, 2009, 3:03:17 AM1/21/09
to Alexander Demin, Google C++ Testing Framework

I've uploaded the script for review: http://codereview.appspot.com/12476

In addition to the script, there is a Makefile in scripts/test for testing it.

Can someone take a look? Thanks,

> Thanks,
>
> --
> Zhanyong
>

--
Zhanyong

Alexander Demin

unread,
Jan 21, 2009, 6:13:28 AM1/21/09
to Zhanyong Wan (λx.x x), Google C++ Testing Framework
Hi Zhanyong,

I've tried your script and quite frankly it generates almost exactly the same to my hand work ;-) except stripped duplicating copyrights and some extra comments I used during manual cutting. So I definitely have switched to using the gtest amalgamation produced by your script. Thanks.

Regards,
Alexander

Zhanyong Wan (λx.x x)

unread,
Jan 21, 2009, 1:02:10 PM1/21/09
to Alexander Demin, Google C++ Testing Framework
On Wed, Jan 21, 2009 at 3:13 AM, Alexander Demin <ade...@gmail.com> wrote:
> Hi Zhanyong,
>
> I've tried your script and quite frankly it generates almost exactly the
> same to my hand work ;-)

Wow, you were really good at executing recursive algorithms manually. :-)

> except stripped duplicating copyrights and some
> extra comments I used during manual cutting. So I definitely have switched
> to using the gtest amalgamation produced by your script. Thanks.

Thanks for the confirmation!

--
Zhanyong

Reply all
Reply to author
Forward
0 new messages