Bug 1063635 Part 3 - Fix tests for native writeAtomic. r=Yoric
☠☠ backed out by a747bd83f52e ☠ ☠
authorMilindL <i.milind.luthra@gmail.com>
Tue, 29 Aug 2017 20:20:26 +0530
changeset 378211 61a23e8fbf542270c5d796d321f28d368341672a
parent 378210 0d9eb13ac53e266dfd2f7b83fb8afe91961ea837
child 378212 36071efc126c4a7b06bfd43f685e9a4504324df3
push id50214
push userdteller@mozilla.com
push dateFri, 01 Sep 2017 12:31:22 +0000
treeherderautoland@61a23e8fbf54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1063635
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1063635 Part 3 - Fix tests for native writeAtomic. r=Yoric MozReview-Commit-ID: 94lNCMUEg7c
toolkit/components/osfile/tests/xpcshell/test_duration.js
--- a/toolkit/components/osfile/tests/xpcshell/test_duration.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_duration.js
@@ -52,22 +52,22 @@ add_task(async function duration() {
     outExecutionDuration: null
   };
   let contents = await OS.File.read(pathSource, undefined, readOptions);
   testOptions(readOptions, "OS.File.read", ["outExecutionDuration"]);
   // Options structure passed to a OS.File writeAtomic method.
   let writeAtomicOptions = {
     // This field should be first initialized with the actual
     // duration measurement then progressively incremented.
-    outSerializationDuration: null,
     outExecutionDuration: null,
     tmpPath
   };
+  // Note that |contents| cannot be reused after this call since it is detached.
   await OS.File.writeAtomic(pathDest, contents, writeAtomicOptions);
-  testOptions(writeAtomicOptions, "OS.File.writeAtomic");
+  testOptions(writeAtomicOptions, "OS.File.writeAtomic", ["outExecutionDuration"]);
   await OS.File.remove(pathDest);
 
   do_print(`Ensuring that we can use ${availableDurations.join(", ")} to accumulate durations`);
 
   let ARBITRARY_BASE_DURATION = 5;
   copyOptions = {
     // This field should now be incremented with the actual duration
     // measurement.
@@ -83,20 +83,25 @@ add_task(async function duration() {
   testOptionIncrements(copyOptions, "copy", backupDuration);
 
   backupDuration = Object.assign({}, copyOptions);
   await OS.File.remove(copyFile, copyOptions);
   testOptionIncrements(copyOptions, "remove", backupDuration);
 
   // Trying an operation where options are cloned.
   // Options structure passed to a OS.File writeAtomic method.
-  writeAtomicOptions = copyOptions;
+  writeAtomicOptions = {
+    // We do not check for |outSerializationDuration| since |Scheduler.post|
+    // may not be called whenever |writeAtomic| is called.
+    outExecutionDuration: ARBITRARY_BASE_DURATION
+  };
   writeAtomicOptions.tmpPath = tmpPath;
-  backupDuration = Object.assign({}, copyOptions);
+  backupDuration = Object.assign({}, writeAtomicOptions);
+  contents = await OS.File.read(pathSource, undefined, readOptions);
   await OS.File.writeAtomic(pathDest, contents, writeAtomicOptions);
-  testOptionIncrements(writeAtomicOptions, "writeAtomicOptions", backupDuration);
+  testOptionIncrements(writeAtomicOptions, "writeAtomicOptions", backupDuration, ["outExecutionDuration"]);
   OS.File.remove(pathDest);
 
   // Testing an operation that doesn't take arguments at all
   let file = await OS.File.open(pathSource);
   await file.stat();
   await file.close();
 });