[Groonga-commit] groonga/gcs [master] Don't overwrite saved responses if new responses are not changed from saved one

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Nov 15 10:57:01 JST 2012


YUKI Hiroshi	2012-11-15 10:57:01 +0900 (Thu, 15 Nov 2012)

  New Revision: 56023a34de7fe0a3837448fe459061b3a457651f
  https://github.com/groonga/gcs/commit/56023a34de7fe0a3837448fe459061b3a457651f

  Log:
    Don't overwrite saved responses if new responses are not changed from saved one

  Modified files:
    tools/run-scenarios
    tools/scenario-runner.js

  Modified: tools/run-scenarios (+7 -0)
===================================================================
--- tools/run-scenarios    2012-11-15 10:54:49 +0900 (bf2d66c)
+++ tools/run-scenarios    2012-11-15 10:57:01 +0900 (9536991)
@@ -118,6 +118,13 @@ runner.on('scenario', function(event) {
   event.runner.on('request:end', function(event) {
     var filename = ScenariosRunner.toSafeName(event.request.name) + '.txt';
     var responsePath = path.resolve(event.scenario.responsesDir, filename);
+    if (path.existsSync(responsePath)) {
+      var previousResponse = fs.readFileSync(responsePath).toString();
+      previousResponse = new ScenarioResponse(previousResponse);
+      var newResponse = new ScenarioResponse(event.request.response);
+      if (newResponse.equals(previousResponse))
+        return;
+    }
     fs.writeFile(responsePath, event.request.response);
     console.log('  Wrote ' + responsePath);
   });

  Modified: tools/scenario-runner.js (+7 -0)
===================================================================
--- tools/scenario-runner.js    2012-11-15 10:54:49 +0900 (cfab4f8)
+++ tools/scenario-runner.js    2012-11-15 10:57:01 +0900 (cce0c4a)
@@ -263,6 +263,13 @@ Response.prototype = {
         }, this);
         return format;
     }
+  },
+
+  equals: function(anotherResponse) {
+    if (!anotherResponse) return false;
+    var normalizedSelf = JSON.stringify(this.normalizedBody);
+    var normalizedAnother = JSON.stringify(anotherResponse.normalizedBody);
+    return normalizedSelf == normalizedAnother;
   }
 };
 
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index