[C++] Check testdir before chdir
So there will be no unnecessary error messages.
diff --git a/find.cc b/find.cc
index 9f5332d..75db6d9 100644
--- a/find.cc
+++ b/find.cc
@@ -674,6 +674,19 @@
is_initialized_ = true;
}
+ if (!fc.testdir.empty()) {
+ if (!CanHandle(fc.testdir)) {
+ LOG("FindEmulator: Cannot handle test dir (%.*s): %s",
+ SPF(fc.testdir), cmd.c_str());
+ return false;
+ }
+ if (!root_->FindDir(fc.testdir)) {
+ LOG("FindEmulator: Test dir (%.*s) not found: %s",
+ SPF(fc.testdir), cmd.c_str());
+ return true;
+ }
+ }
+
if (!fc.chdir.empty()) {
if (!CanHandle(fc.chdir)) {
LOG("FindEmulator: Cannot handle chdir (%.*s): %s",
@@ -688,19 +701,6 @@
}
}
- if (!fc.testdir.empty()) {
- if (!CanHandle(fc.testdir)) {
- LOG("FindEmulator: Cannot handle test dir (%.*s): %s",
- SPF(fc.testdir), cmd.c_str());
- return false;
- }
- if (!root_->FindDir(fc.testdir)) {
- LOG("FindEmulator: Test dir (%.*s) not found: %s",
- SPF(fc.testdir), cmd.c_str());
- return true;
- }
- }
-
const size_t orig_out_size = out->size();
for (StringPiece finddir : fc.finddirs) {
const string dir = ConcatDir(fc.chdir, finddir);