Kaynağa Gözat

HADOOP-7357. hadoop.io.compress.TestCodec#main() should exit with non-zero exit code if test failed. Contributed by Philip Zeyliger

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1156839 13f79535-47bb-0310-9956-ffa450edef68
Eli Collins 13 yıl önce
ebeveyn
işleme
7528853197

+ 3 - 0
hadoop-common/CHANGES.txt

@@ -481,6 +481,9 @@ Trunk (unreleased changes)
     HADOOP-7512. Fix example mistake in WritableComparable javadocs.
     (Harsh J via eli)
 
+    HADOOP-7357. hadoop.io.compress.TestCodec#main() should exit with
+    non-zero exit code if test failed. (Philip Zeyliger via eli)
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 12 - 17
hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java

@@ -501,7 +501,7 @@ public class TestCodec {
     LOG.info("SUCCESS! Completed SequenceFileCodecTest with codec \"" + codecClass + "\"");
   }
   
-  public static void main(String[] args) {
+  public static void main(String[] args) throws IOException {
     int count = 10000;
     String codecClass = "org.apache.hadoop.io.compress.DefaultCodec";
 
@@ -511,25 +511,20 @@ public class TestCodec {
       System.exit(-1);
     }
 
-    try {
-      for (int i=0; i < args.length; ++i) {       // parse command line
-        if (args[i] == null) {
-          continue;
-        } else if (args[i].equals("-count")) {
-          count = Integer.parseInt(args[++i]);
-        } else if (args[i].equals("-codec")) {
-          codecClass = args[++i];
-        }
+    for (int i=0; i < args.length; ++i) {       // parse command line
+      if (args[i] == null) {
+        continue;
+      } else if (args[i].equals("-count")) {
+        count = Integer.parseInt(args[++i]);
+      } else if (args[i].equals("-codec")) {
+        codecClass = args[++i];
       }
-
-      Configuration conf = new Configuration();
-      int seed = 0;
-      codecTest(conf, seed, count, codecClass);
-    } catch (Exception e) {
-      System.err.println("Caught: " + e);
-      e.printStackTrace();
     }
 
+    Configuration conf = new Configuration();
+    int seed = 0;
+    // Note that exceptions will propagate out.
+    codecTest(conf, seed, count, codecClass);
   }
 
   @Test