summaryrefslogtreecommitdiffstats
path: root/src/subprocess_test.cc
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 /src/subprocess_test.cc
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 'src/subprocess_test.cc')
-rw-r--r--src/subprocess_test.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/subprocess_test.cc b/src/subprocess_test.cc
index 775a13a..fe53748 100644
--- a/src/subprocess_test.cc
+++ b/src/subprocess_test.cc
@@ -18,6 +18,7 @@
#ifndef _WIN32
// SetWithLots need setrlimit.
+#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
@@ -92,7 +93,7 @@ TEST_F(SubprocessTest, InterruptParent) {
return;
}
- ADD_FAILURE() << "We should have been interrupted";
+ ASSERT_FALSE("We should have been interrupted");
}
TEST_F(SubprocessTest, Console) {
@@ -176,9 +177,10 @@ TEST_F(SubprocessTest, SetWithLots) {
// Make sure [ulimit -n] isn't going to stop us from working.
rlimit rlim;
ASSERT_EQ(0, getrlimit(RLIMIT_NOFILE, &rlim));
- ASSERT_GT(rlim.rlim_cur, kNumProcs)
- << "Raise [ulimit -n] well above " << kNumProcs
- << " to make this test go";
+ if (!EXPECT_GT(rlim.rlim_cur, kNumProcs)) {
+ printf("Raise [ulimit -n] well above %u to make this test go\n", kNumProcs);
+ return;
+ }
vector<Subprocess*> procs;
for (size_t i = 0; i < kNumProcs; ++i) {