Changeset 3457


Ignore:
Timestamp:
12/10/07 14:47:13 (12 years ago)
Author:
melissa
Message:

Make sure that only one file from each dataset is placed in the list of files to test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/test/ReaderTest.java

    r3149 r3457  
    5555 
    5656  /** List of files to test. */ 
    57   private static Vector toTest; 
     57  private String[][] toTest; 
    5858 
    5959  /** List of configuration files. */ 
     
    7373  public Object[][] createData() { 
    7474    if (isFirstTime) { 
    75       toTest = new Vector(); 
    76       getFiles(System.getProperty("testng.directory"), toTest); 
     75      Vector v = new Vector(); 
     76      getFiles(System.getProperty("testng.directory"), v); 
     77      v = removeDuplicates(v); 
    7778      isFirstTime = false; 
    78     } 
    79     String[] o = (String[]) toTest.toArray(new String[0]); 
    80     String[][] rtn = new String[o.length][1]; 
    81     for (int i=0; i<o.length; i++) { rtn[i][0] = o[i]; } 
    82     return rtn; 
     79      String[] o = (String[]) v.toArray(new String[0]); 
     80      toTest = new String[o.length][1]; 
     81      for (int i=0; i<o.length; i++) { 
     82        toTest[i][0] = o[i]; 
     83      } 
     84    } 
     85    return toTest; 
    8386  } 
    8487 
     
    790793  } 
    791794 
     795  /** Remove duplicates from a file list. */ 
     796  private static Vector removeDuplicates(Vector files) { 
     797    Vector rtn = new Vector(); 
     798    try { 
     799      for (int i=0; i<files.size(); i++) { 
     800        if (files.get(i) == null) continue; 
     801        FileStitcher f = new FileStitcher(); 
     802        f.setId((String) files.get(i)); 
     803        String[] used = f.getUsedFiles(); 
     804        rtn.add(used[0]); 
     805        for (int q=1; q<used.length; q++) { 
     806          int ndx = files.indexOf(used[q]); 
     807          if (ndx > -1) files.setElementAt(null, ndx); 
     808          if (used[q].indexOf(File.separator) != -1) { 
     809            String s = 
     810              used[q].substring(used[q].lastIndexOf(File.separator) + 1); 
     811            ndx = files.indexOf(s); 
     812            if (ndx > -1) files.setElementAt(null, ndx); 
     813          } 
     814        } 
     815        f.close(); 
     816      } 
     817    } 
     818    catch (FormatException e) { e.printStackTrace(); } 
     819    catch (IOException e) { e.printStackTrace(); } 
     820    files = rtn; 
     821    return rtn; 
     822  } 
     823 
    792824  // -- Helper class -- 
    793825 
Note: See TracChangeset for help on using the changeset viewer.