aboutsummaryrefslogtreecommitdiff
path: root/ninja_test.cc
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-07-14 03:36:34 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-07-14 03:36:34 +0900
commit2c9fcbefbc4162759c1c09fa655cdf77420ba38c (patch)
tree714e4f5fd5c086bfcfc476ee4d8fb6a4e9e5a950 /ninja_test.cc
parente08e9ee8144a4de8faab210e56a56519b5c7fa96 (diff)
[C++] Handle command lines with ccache
Diffstat (limited to 'ninja_test.cc')
-rw-r--r--ninja_test.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/ninja_test.cc b/ninja_test.cc
index a83dca5..8c82ede 100644
--- a/ninja_test.cc
+++ b/ninja_test.cc
@@ -24,11 +24,18 @@ namespace {
#define ASSERT_EQ(a, b) \
do { \
if ((a) != (b)) { \
- fprintf(stderr, "Assertion failure at %s:%d: %s (which is %s) vs %s", \
- __FILE__, __LINE__, #a, a.c_str(), #b); \
+ fprintf(stderr, "Assertion failure at %s:%d: %s (which is %s) vs %s\n", \
+ __FILE__, __LINE__, #a, c_str(a), #b); \
} \
} while(0)
+const char* c_str(const string& s) { return s.c_str(); }
+const char* c_str(size_t v) {
+ static char buf[64];
+ sprintf(buf, "%zd", v);
+ return buf;
+}
+
string GetDepfile(string cmd, string* new_cmd) {
new_cmd->clear();
string r;
@@ -69,9 +76,16 @@ void TestGetDepfile() {
assert(!g_last_error);
}
+static void TestGetGomaccPosForAndroidCompileCommand() {
+ ASSERT_EQ(GetGomaccPosForAndroidCompileCommand("prebuilts/clang/linux-x86/host/3.6/bin/clang++ -c foo.c "), 0);
+ ASSERT_EQ(GetGomaccPosForAndroidCompileCommand("prebuilts/misc/linux-x86/ccache/ccache prebuilts/clang/linux-x86/host/3.6/bin/clang++ -c foo.c "), 39);
+ ASSERT_EQ(GetGomaccPosForAndroidCompileCommand("echo foo "), string::npos);
+}
+
} // namespace
int main() {
g_log_no_exit = true;
TestGetDepfile();
+ TestGetGomaccPosForAndroidCompileCommand();
}