summaryrefslogtreecommitdiffstats
path: root/configure.py
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2014-09-18 02:48:26 (GMT)
committerNico Weber <nicolasweber@gmx.de>2014-09-18 02:48:26 (GMT)
commitb2fe56caaf0bed497ee480003f10486c18d8de9a (patch)
tree8d32bf2472cb6fd4344650f24b38421221fcc738 /configure.py
parent1d9184c3adbfabacb844b0a715a64b08998c204f (diff)
downloadNinja-b2fe56caaf0bed497ee480003f10486c18d8de9a.zip
Ninja-b2fe56caaf0bed497ee480003f10486c18d8de9a.tar.gz
Ninja-b2fe56caaf0bed497ee480003f10486c18d8de9a.tar.bz2
Use a small, standalone testing framework instead of googletest.
Ninja currently uses googletest for testing. That makes building ninja_test somewhat annoying since it requires that one passes --with-gtest PATH to configure. It turns out just implementing the bits of googletest that ninja uses needs about the same amount of code than making the --with-gtest flag in configure.py work and making googletest print test results in a way we want (!) In addition to making configuration simpler, this also makes compiling tests much faster: On my system, touching src/build_test.cc (the slowest file to build in ninja) and rebuilding ninja_tests is twice as fast than without this patch. Building all is noticeably faster too: 5.6s with this patch, 9.1s without this patch (38% faster). The most noticeable things missing: EXPECT_* and ASSERT_* don't support streaming notes to them with operator<<, and for failing tests the lhs and rhs are not printed. That's so that this header does not have to include sstream, which slows down building ninja_test almost 20%. If this turns out to be annoying, we can maybe add it.
Diffstat (limited to 'configure.py')
-rwxr-xr-xconfigure.py31
1 files changed, 3 insertions, 28 deletions
diff --git a/configure.py b/configure.py
index 64123a0..a307043 100755
--- a/configure.py
+++ b/configure.py
@@ -44,8 +44,7 @@ parser.add_option('--debug', action='store_true',
parser.add_option('--profile', metavar='TYPE',
choices=profilers,
help='enable profiling (' + '/'.join(profilers) + ')',)
-parser.add_option('--with-gtest', metavar='PATH',
- help='use gtest unpacked in directory PATH')
+parser.add_option('--with-gtest', metavar='PATH', help='ignored')
parser.add_option('--with-python', metavar='EXE',
help='use EXE as the Python interpreter',
default=os.path.basename(sys.executable))
@@ -319,34 +318,10 @@ all_targets += ninja
n.comment('Tests all build into ninja_test executable.')
variables = []
-test_cflags = cflags + ['-DGTEST_HAS_RTTI=0']
test_ldflags = None
test_libs = libs
objs = []
-if options.with_gtest:
- path = options.with_gtest
- gtest_all_incs = '-I%s -I%s' % (path, os.path.join(path, 'include'))
- if platform.is_msvc():
- gtest_cflags = '/nologo /EHsc /Zi /D_VARIADIC_MAX=10 '
- if platform.msvc_needs_fs():
- gtest_cflags += '/FS '
- gtest_cflags += gtest_all_incs
- else:
- gtest_cflags = '-fvisibility=hidden ' + gtest_all_incs
- objs += n.build(built('gtest-all' + objext), 'cxx',
- os.path.join(path, 'src', 'gtest-all.cc'),
- variables=[('cflags', gtest_cflags)])
-
- test_cflags.append('-I%s' % os.path.join(path, 'include'))
-else:
- # Use gtest from system.
- if platform.is_msvc():
- test_libs.extend(['gtest_main.lib', 'gtest.lib'])
- else:
- test_libs.extend(['-lgtest_main', '-lgtest'])
-
-n.variable('test_cflags', test_cflags)
for name in ['build_log_test',
'build_test',
'clean_test',
@@ -362,10 +337,10 @@ for name in ['build_log_test',
'subprocess_test',
'test',
'util_test']:
- objs += cxx(name, variables=[('cflags', '$test_cflags')])
+ objs += cxx(name)
if platform.is_windows():
for name in ['includes_normalize_test', 'msvc_helper_test']:
- objs += cxx(name, variables=[('cflags', '$test_cflags')])
+ objs += cxx(name)
if not platform.is_windows():
test_libs.append('-lpthread')