pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject svn commit: r1148564 - in /pig/trunk: CHANGES.txt test/org/apache/pig/test/TestScriptLanguage.java test/org/apache/pig/test/Util.java
Date Tue, 19 Jul 2011 21:49:33 GMT
Author: thejas
Date: Tue Jul 19 21:49:32 2011
New Revision: 1148564

URL: http://svn.apache.org/viewvc?rev=1148564&view=rev
Log:
PIG-2171: TestScriptLanguage is broken on trunk (daijy and thejas)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java
    pig/trunk/test/org/apache/pig/test/Util.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1148564&r1=1148563&r2=1148564&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Tue Jul 19 21:49:32 2011
@@ -89,6 +89,8 @@ PIG-2011: Speed up TestTypedMap.java (dv
 
 BUG FIXES
 
+PIG-2171: TestScriptLanguage is broken on trunk (daijy and thejas)
+
 PIG-2172: Fix test failure for ant 1.8.x (daijy)
 
 PIG-2162: bin/pig should not modify user args (rangadi via thejas)

Modified: pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java?rev=1148564&r1=1148563&r2=1148564&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java Tue Jul 19 21:49:32 2011
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.io.File;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -545,7 +546,7 @@ public class TestScriptLanguage {
                 "result = P.bind().runSingle()"
         };
 
-        Util.createLocalInputFile( "testScript.py", script);
+        File pyFile = Util.createLocalInputFile( "testScript.py", script);
         
         String[] args = { "-x", "local", "testScript.py"};
         PigStats stats = PigRunner.run(args, null);
@@ -554,10 +555,11 @@ public class TestScriptLanguage {
         assertTrue(stats.getReturnCode() == PigRunner.ReturnCode.PIG_EXCEPTION);
         
         String expected = "Python Error. Traceback (most recent call last):\n" +
-            "  File \"testScript.py\", line 7";
+            "  File \"" + pyFile.getAbsolutePath() + "\", line 7";
 
         String msg = stats.getErrorMessage();
-        assertEquals(expected, msg.substring(0, expected.length()));
+        Util.checkErrorMessageContainsExpected(msg, expected);
+        
     }
     
     @Test

Modified: pig/trunk/test/org/apache/pig/test/Util.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/Util.java?rev=1148564&r1=1148563&r2=1148564&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/Util.java (original)
+++ pig/trunk/test/org/apache/pig/test/Util.java Tue Jul 19 21:49:32 2011
@@ -504,13 +504,20 @@ public class Util {
      public static void checkMessageInException(FrontendException e,
              String expectedErr) {
          PigException pigEx = LogUtils.getPigException(e);
-         if(!pigEx.getMessage().contains(expectedErr)){
-             String msg = "Expected exception message matching '" 
-                 + expectedErr + "' but got '" + pigEx.getMessage() + "'" ;
-             fail(msg);
-         }
+         String message = pigEx.getMessage();
+         checkErrorMessageContainsExpected(message, expectedErr);
+        
      }
 
+     public static void checkErrorMessageContainsExpected(String message, String expectedMessage){
+         if(!message.contains(expectedMessage)){
+             String msg = "Expected error message containing '" 
+                 + expectedMessage + "' but got '" + message + "'" ;
+             fail(msg);
+         } 
+     }
+     
+     
     /**
 	 * Utility method to copy a file form local filesystem to the dfs on
 	 * the minicluster for testing in mapreduce mode



Mime
View raw message