Bug 559681 - [Windows, Packaged] xpcshell-tests: "Exception / NS_ERROR_FILE_NOT_FOUND / nsIProcess.init / test_largeOfflineStore.js :: run_test :: line 59". LargeOfflineStoreHelper.exe is not packaged; (Av2) Copy Windows helper executable to xpcshell(-tests) directory, Unify dump()/do_throw() calls.
authorSerge Gautherie <sgautherie.bz@free.fr>
Tue, 20 Apr 2010 12:20:52 +0200
changeset 5478 3bea8332b591a27892ec6de140e5b5c3b01c4282
parent 5477 48a4baab97babe7c19b50eae3b78fc2ca1201783
child 5479 fb85020c2128b97bc22cd7f3fe1f23a7985a6cf0
push idunknown
push userunknown
push dateunknown
bugs559681
Bug 559681 - [Windows, Packaged] xpcshell-tests: "Exception / NS_ERROR_FILE_NOT_FOUND / nsIProcess.init / test_largeOfflineStore.js :: run_test :: line 59". LargeOfflineStoreHelper.exe is not packaged; (Av2) Copy Windows helper executable to xpcshell(-tests) directory, Unify dump()/do_throw() calls. r=standard8.
mailnews/imap/test/unit/test_largeOfflineStore.js
mailnews/test/Makefile.in
--- a/mailnews/imap/test/unit/test_largeOfflineStore.js
+++ b/mailnews/imap/test/unit/test_largeOfflineStore.js
@@ -37,87 +37,91 @@ function run_test()
 
   // On Windows, check whether the drive is NTFS. If it is, mark the file as
   // sparse. If it isn't, then bail out now, because in all probability it is
   // FAT32, which doesn't support file sizes greater than 4 GB.
   if ("@mozilla.org/windows-registry-key;1" in Cc)
   {
     // Figure out the name of the IMAP inbox
     let file = gIMAPIncomingServer.rootMsgFolder.filePath.clone();
-
     file.append("INBOX");
     if (!file.exists())
       file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
 
     // Now call upon our helper
-    let args = [file.path];
-    let helper = Cc["@mozilla.org/file/directory_service;1"]
-                   .getService(Ci.nsIProperties)
-                   .get("CurProcD", Ci.nsIFile);
+    let helper = do_get_cwd().clone();
+    // '../../mailnews/LargeOfflineStoreHelper.exe'.
+    helper = helper.parent.parent;
+    helper.normalize();
+    helper.append("mailnews");
+    helper.append("LargeOfflineStoreHelper.exe");
+    if (!helper.exists()) {
+      do_throw(helper.leafName + " not found");
+    }
 
-    helper.append("LargeOfflineStoreHelper.exe");
     let helperProc = Cc["@mozilla.org/process/util;1"]
                        .createInstance(Ci.nsIProcess);
     helperProc.init(helper);
+    let args = [file.path];
     // XXX This needs to be fixed to use runw once it lands (bug 411511)
     helperProc.run(true, args, args.length);
+    let exitValue = helperProc.exitValue;
 
-    let exitValue = helperProc.exitValue;
     // 0 is success, 1 is "unable to run," and any other value is failure
     if (exitValue == 1)
     {
       dump("On Windows, this test only works on NTFS volumes.\n");
       endTest();
       return;
     }
 
     if (exitValue != 0)
     {
-      throw new Error("Helper failed with exit value " + exitValue +
-                      ", see above for details");
+      do_throw(helper.leafName + " failed with exit value " + exitValue +
+                 ", see above for details");
     }
   }
 
   let inbox = gIMAPDaemon.getMailbox("INBOX");
 
   let ioService = Cc["@mozilla.org/network/io-service;1"]
-      .getService(Ci.nsIIOService);
+                    .getService(Ci.nsIIOService);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
   do_test_pending();
 
   // Create a couple test messages.
   let messages = [];
   let messageGenerator = new MessageGenerator();
   let scenarioFactory = new MessageScenarioFactory(messageGenerator);
 
   messages = messages.concat(scenarioFactory.directReply(2));
   let dataUri = ioService.newURI("data:text/plain;base64," +
                    btoa(messages[0].toMessageString()),
-                   null, null);
+                        null, null);
   let imapMsg = new imapMessage(dataUri.spec, inbox.uidnext++, []);
   inbox.addMessage(imapMsg);
 
   dataUri = ioService.newURI("data:text/plain;base64," +
                    btoa(messages[1].toMessageString()),
-                   null, null);
+                        null, null);
   imapMsg = new imapMessage(dataUri.spec, inbox.uidnext++, []);
   inbox.addMessage(imapMsg);
 
   // Get the IMAP inbox...
   let rootFolder = gIMAPIncomingServer.rootFolder;
   let freeDiskSpace = rootFolder.filePath.diskSpaceAvailable;
 
   // On Windows, the file is marked as sparse above. Linux file systems
   // generally support sparse files automatically. OS X's HFS+, however, doesn't
   // support sparse files, so check for at least 8 GB of free disk space before
   // consuming 4 GB.
   if ("nsILocalFileMac" in Ci && freeDiskSpace < 0x200000000) {
-    dump("not enough free disk space\n");
+    dump("On MacOSX, this test needs 8 GB of free disk space.\n");
     endTest();
     return;
   }
 
   gIMAPInbox = rootFolder.getFolderWithFlags(Ci.nsMsgFolderFlags.Inbox);
   let outputStream = gIMAPInbox.offlineStoreOutputStream
                                .QueryInterface(Ci.nsISeekableStream);
   // seek to 15 bytes past 4GB.
@@ -151,29 +155,33 @@ var UrlListener =
       {
         let header = msgEnumerator.getNext();
         // Verify that each message has been downloaded and looks OK.
         if (header instanceof Components.interfaces.nsIMsgDBHdr &&
             (header.flags & Ci.nsMsgMessageFlags.Offline))
           gIMAPInbox.getOfflineFileStream(header.messageKey, offset, size).close();
         else
           do_throw("Message not downloaded for offline use");
+
         dump("msg hdr offset = " + offset.value + "\n");
       }
       let offlineStoreSize = gIMAPInbox.filePath.fileSize;
       dump("offline store size = " + offlineStoreSize + "\n");
       // Make sure offline store grew (i.e., we're not writing over data).
       do_check_true(offlineStoreSize > gOfflineStoreSize);
       // free up disk space - if you want to look at the file after running
       // this test, comment out this line.
       gIMAPInbox.filePath.remove(false);
     }
+
     try {
-    do_timeout(1000, endTest);
-    } catch(ex) {dump(ex);}
+      do_timeout(1000, endTest);
+    } catch(ex) {
+      do_throw(ex);
+    }
   }
 };
 
 function endTest()
 {
   gIMAPIncomingServer.closeCachedConnections();
   gServer.stop();
 
--- a/mailnews/test/Makefile.in
+++ b/mailnews/test/Makefile.in
@@ -16,16 +16,17 @@
 # The Initial Developer of the Original Code is
 # Mozilla Messaging, Inc.
 #
 # Portions created by the Initial Developer are Copyright (C) 2010
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Siddharth Agarwal <sid.bugzilla@gmail.com>
+#   Serge Gautherie <sgautherie.bz@free.fr>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either of the GNU General Public License Version 2 or later (the "GPL"),
 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -39,20 +40,22 @@
 DEPTH     = ../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 ifeq ($(OS_ARCH),WINNT)
-
 CPPSRCS = \
   LargeOfflineStoreHelper.cpp \
   $(NULL)
 
-SIMPLE_PROGRAMS = \
-  LargeOfflineStoreHelper$(BIN_SUFFIX) \
-  $(NULL)
-
+SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
 endif # ifeq ($(OS_ARCH),WINNT)
 
 include $(topsrcdir)/config/rules.mk
+
+ifeq ($(OS_ARCH),WINNT)
+# need the executable for running the xpcshell unit tests
+libs::
+	$(INSTALL) $(SIMPLE_PROGRAMS) $(DEPTH)/mozilla/_tests/xpcshell/mailnews
+endif # ifeq ($(OS_ARCH),WINNT)