You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ga...@apache.org on 2012/10/16 01:23:22 UTC

svn commit: r1398574 - in /pig/trunk: CHANGES.txt test/org/apache/pig/test/Util.java

Author: gates
Date: Mon Oct 15 23:23:22 2012
New Revision: 1398574

URL: http://svn.apache.org/viewvc?rev=1398574&view=rev
Log:
PIG-2794 Pig test: add utils to simplify testing on Windows

Modified:
    pig/trunk/CHANGES.txt
    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=1398574&r1=1398573&r2=1398574&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Mon Oct 15 23:23:22 2012
@@ -24,6 +24,8 @@ INCOMPATIBLE CHANGES
 
 IMPROVEMENTS
 
+PIG-2793: Pig test: add utils to simplify testing on Windows (jgordon via gates)
+
 PIG-2908: Fix unit tests to work with jdk7 (rohini via dvryaboy) 
 
 OPTIMIZATIONS

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=1398574&r1=1398573&r2=1398574&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/Util.java (original)
+++ pig/trunk/test/org/apache/pig/test/Util.java Mon Oct 15 23:23:22 2012
@@ -112,8 +112,14 @@ public class Util {
     private static BagFactory mBagFactory = BagFactory.getInstance();
     private static TupleFactory mTupleFactory = TupleFactory.getInstance();
 
+    // Commonly-checked system state
+    // =================
+    public static final boolean WINDOWS /* borrowed from Path.WINDOWS, Shell.WINDOWS */
+                  = System.getProperty("os.name").startsWith("Windows");
+
     // Helper Functions
     // =================
+
     static public Tuple loadFlatTuple(Tuple t, int[] input) throws ExecException {
         for (int i = 0; i < input.length; i++) {
             t.set(i, new Integer(input[i]));
@@ -258,6 +264,19 @@ public class Util {
     }
 
     /**
+     * Helper to remove colons (if any exist) from paths to sanitize them for
+     * consumption by hdfs.
+     *
+     * @param origPath original path name
+     * @return String  sanitized path with anything prior to : removed
+     * @throws IOException
+     */
+    static public String removeColon(String origPath)
+    {
+       return origPath.replaceAll(":", "");
+    }
+
+    /**
      * Helper to create a temporary file with given input data for use in test cases.
      *  
      * @param tmpFilenamePrefix file-name prefix