From 5d3e7ac1a3e2e09b885a73c9ba7f5e5e3b7de9ac Mon Sep 17 00:00:00 2001 From: "houssainy@google.com" Date: Mon, 6 Oct 2014 17:21:27 +0000 Subject: [PATCH] Check on the existence of report directory Reports will be written at rtcBot/test/reports/ R=andresp@webrtc.org Review URL: https://webrtc-codereview.appspot.com/26689004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7372 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/tools/rtcbot/test.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/webrtc/tools/rtcbot/test.js b/webrtc/tools/rtcbot/test.js index 7e9c33544..785d5e89d 100644 --- a/webrtc/tools/rtcbot/test.js +++ b/webrtc/tools/rtcbot/test.js @@ -121,9 +121,19 @@ StatisticsReport.prototype = { }, finish: function (doneCallback) { - fs.writeFile("test/reports/" + this.outputFileName_ + "_" + + fs.exists("test/reports/", function (exists) { + if(exists) { + writeFile.bind(this)(); + } else { + fs.mkdir("test/reports/", 0777, writeFile.bind(this)); + } + }.bind(this)); + + function writeFile () { + fs.writeFile("test/reports/" + this.outputFileName_ + "_" + (new Date()).getTime() +".json", JSON.stringify(this.output_), doneCallback); + } }, }