hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r683432 - in /hadoop/core/trunk: CHANGES.txt src/ant/org/apache/hadoop/ant/DfsTask.java src/core/org/apache/hadoop/fs/FsShell.java src/test/org/apache/hadoop/hdfs/TestDFSShell.java
Date Wed, 06 Aug 2008 22:30:47 GMT
Author: cdouglas
Date: Wed Aug  6 15:30:47 2008
New Revision: 683432

URL: http://svn.apache.org/viewvc?rev=683432&view=rev
Log:
HADOOP-3792. Make FsShell -test consistent with unix semantics, returning
zero for true and non-zero for false. Contributed by Ben Slusky.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/ant/org/apache/hadoop/ant/DfsTask.java
    hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java
    hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDFSShell.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=683432&r1=683431&r2=683432&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Aug  6 15:30:47 2008
@@ -34,6 +34,9 @@
 
     HADOOP-1700.  Support appending to file in HDFS. (dhruba)
 
+    HADOOP-3792. Make FsShell -test consistent with unix semantics, returning
+    zero for true and non-zero for false. (Ben Slusky via cdouglas)
+
   NEW FEATURES
 
     HADOOP-3341. Allow streaming jobs to specify the field separator for map

Modified: hadoop/core/trunk/src/ant/org/apache/hadoop/ant/DfsTask.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/ant/org/apache/hadoop/ant/DfsTask.java?rev=683432&r1=683431&r2=683432&view=diff
==============================================================================
--- hadoop/core/trunk/src/ant/org/apache/hadoop/ant/DfsTask.java (original)
+++ hadoop/core/trunk/src/ant/org/apache/hadoop/ant/DfsTask.java Wed Aug  6 15:30:47 2008
@@ -158,7 +158,7 @@
 
   // in case DfsTask is overridden
   protected int postCmd(int exit_code) {
-    if ("-test".equals(cmd) && exit_code == 0)
+    if ("-test".equals(cmd) && exit_code != 0)
       outprop = null;
     return exit_code;
   }

Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java?rev=683432&r1=683431&r2=683432&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java Wed Aug  6 15:30:47 2008
@@ -746,11 +746,11 @@
     FileSystem srcFs = f.getFileSystem(getConf());
     switch(flag) {
       case 'e':
-        return srcFs.exists(f) ? 1 : 0;
+        return srcFs.exists(f) ? 0 : 1;
       case 'z':
-        return srcFs.getFileStatus(f).getLen() == 0 ? 1 : 0;
+        return srcFs.getFileStatus(f).getLen() == 0 ? 0 : 1;
       case 'd':
-        return srcFs.getFileStatus(f).isDir() ? 1 : 0;
+        return srcFs.getFileStatus(f).isDir() ? 0 : 1;
       default:
         throw new IOException("Unknown flag: " + flag);
     }
@@ -1356,7 +1356,7 @@
       "\t\tin a file at <path>. An error is returned if the file exists with non-zero
length\n";
 
     String test = "-test -[ezd] <path>: If file { exists, has zero length, is a directory\n"
+
-      "\t\tthen return 1, else return 0.\n";
+      "\t\tthen return 0, else return 1.\n";
 
     String stat = "-stat [format] <path>: Print statistics about the file/directory
at <path>\n" +
       "\t\tin the specified format. Format accepts filesize in blocks (%b), filename (%n),\n"
+

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDFSShell.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDFSShell.java?rev=683432&r1=683431&r2=683432&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDFSShell.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDFSShell.java Wed Aug  6 15:30:47
2008
@@ -1017,9 +1017,13 @@
         }
         assertTrue(val == 0);
 
+        args = new String[3];
         args[0] = "-test";
-        args[1] = "-e " + args[1];
+        args[1] = "-e";
+        args[2] = "/test/mkdirs/noFileHere";
+        val = -1;
         try {
+          val = shell.run(args);
         } catch (Exception e) {
           System.err.println("Exception raised from DFSShell.run " +
                              e.getLocalizedMessage());



Mime
View raw message