summaryrefslogtreecommitdiffstats
path: root/src/manifest_parser_perftest.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-03-31 15:12:12 (GMT)
committerNico Weber <nicolasweber@gmx.de>2015-03-31 19:21:57 (GMT)
commit3beebde51a2089ecb01820f1428efe0263deaeea (patch)
tree55aec535c37434dbe5893e8ed37c69891b6d4b74 /src/manifest_parser_perftest.cc
parenta88b75d9a9df1b3722ad649ae275d342f3b57b22 (diff)
downloadNinja-3beebde51a2089ecb01820f1428efe0263deaeea.zip
Ninja-3beebde51a2089ecb01820f1428efe0263deaeea.tar.gz
Ninja-3beebde51a2089ecb01820f1428efe0263deaeea.tar.bz2
Let Stat() have an err outparam instead of writing to stderr.
Also check for Stat() failure in a few more places. This way, ninja doesn't print two "ninja: error: " lines if stat() fails during a build. It also makes it easier to keep the stat tests quiet. Every caller of Stat() needs to explicitly log the error string if that's desired.
Diffstat (limited to 'src/manifest_parser_perftest.cc')
-rw-r--r--src/manifest_parser_perftest.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/manifest_parser_perftest.cc b/src/manifest_parser_perftest.cc
index ca62fb2..6b56ab0 100644
--- a/src/manifest_parser_perftest.cc
+++ b/src/manifest_parser_perftest.cc
@@ -42,15 +42,19 @@ struct RealFileReader : public ManifestParser::FileReader {
}
};
-bool WriteFakeManifests(const string& dir) {
+bool WriteFakeManifests(const string& dir, string* err) {
RealDiskInterface disk_interface;
- if (disk_interface.Stat(dir + "/build.ninja") > 0)
- return true;
+ TimeStamp mtime = disk_interface.Stat(dir + "/build.ninja", err);
+ if (mtime != 0) // 0 means that the file doesn't exist yet.
+ return mtime != -1;
+ string command = "python misc/write_fake_manifests.py " + dir;
printf("Creating manifest data..."); fflush(stdout);
- int err = system(("python misc/write_fake_manifests.py " + dir).c_str());
+ int exit_code = system(command.c_str());
printf("done.\n");
- return err == 0;
+ if (exit_code != 0)
+ *err = "Failed to run " + command;
+ return exit_code == 0;
}
int LoadManifests(bool measure_command_evaluation) {
@@ -93,8 +97,9 @@ int main(int argc, char* argv[]) {
const char kManifestDir[] = "build/manifest_perftest";
- if (!WriteFakeManifests(kManifestDir)) {
- fprintf(stderr, "Failed to write test data\n");
+ string err;
+ if (!WriteFakeManifests(kManifestDir, &err)) {
+ fprintf(stderr, "Failed to write test data: %s\n", err.c_str());
return 1;
}