Browse Source

HADOOP-1714. Fix TestDFSUpgradeFromImage to work on Windows. Contributed by Raghu.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@565940 13f79535-47bb-0310-9956-ffa450edef68
Nigel Daley 18 năm trước cách đây
mục cha
commit
c0ada1332a

+ 3 - 0
CHANGES.txt

@@ -526,6 +526,9 @@ Branch 0.14 (unreleased changes)
 154. HADOOP-1716.  Fix a Pipes wordcount example to remove the 'file:'
      schema from its output path.  (omalley via cutting)
 
+155. HADOOP-1714.  Fix TestDFSUpgradeFromImage to work on Windows.
+     (Raghu Angadi via nigel)
+
 
 Release 0.13.0 - 2007-06-08
 

+ 15 - 5
src/java/org/apache/hadoop/fs/FileUtil.java

@@ -316,16 +316,26 @@ public class FileUtil {
 
   /**
    * Convert a os-native filename to a path that works for the shell.
-   * @param file The filename to convert
+   * @param filename The filename to convert
    * @return The unix pathname
    * @throws IOException on windows, there can be problems with the subprocess
    */
-  public static String makeShellPath(File file) throws IOException {
+  public static String makeShellPath(String filename) throws IOException {
     if (Path.WINDOWS) {
-      return new CygPathCommand(file.toString()).getResult();
+      return new CygPathCommand(filename).getResult();
     } else {
-      return file.toString();
-    }
+      return filename;
+    }    
+  }
+  
+  /**
+   * Convert a os-native filename to a path that works for the shell.
+   * @param file The filename to convert
+   * @return The unix pathname
+   * @throws IOException on windows, there can be problems with the subprocess
+   */
+  public static String makeShellPath(File file) throws IOException {
+    return makeShellPath(file.toString());
   }
 
   /**

+ 2 - 1
src/test/org/apache/hadoop/dfs/TestDFSUpgradeFromImage.java

@@ -70,7 +70,8 @@ public class TestDFSUpgradeFromImage extends TestCase {
     }
     
     LOG.info("Unpacking the tar file " + tarFile);
-    String[] cmd = { "tar", "-zxf", tarFile, "-C", dataDir };
+    String[] cmd = { "tar", "-zxf", FileUtil.makeShellPath(tarFile), 
+                     "-C", FileUtil.makeShellPath(dataDir) };
     Command.execCommand(cmd);
     
     //Now read the reference info