public void processInputDir()

in java/src/org/apache/qetest/xsl/StylesheetTestletDriver.java [308:399]


    public void processInputDir()
    {
        // Ensure the inputDir is there - we must have a valid location for input files
        File testDirectory = new File(inputDir);

        if (!testDirectory.exists())
        {
            // Try a default inputDir
            String oldInputDir = inputDir; // cache for potential error message
            testDirectory = new File((inputDir = getDefaultInputDir()));
            if (!testDirectory.exists())
            {
                // No inputDir, can't do any tests!
                // @todo check if this is the best way to express this
                reporter.checkErr("inputDir(" + oldInputDir
                                  + ", or " + inputDir + ") does not exist, aborting!");
                return;
            }
        }

        reporter.logInfoMsg("inputDir(" + testDirectory.getPath()
                            + ") looking for subdirs with: " + dirFilter);

        // Use our filter to get a list of directories to process
        String subdirs[] = testDirectory.list(getDirFilter());

        // Validate that we have some valid directories to process
        if ((null == subdirs) || (subdirs.length <= 0))
        {
            reporter.checkErr("inputDir(" + testDirectory.getPath()
                               + ") no valid subdirs found!");
            return;
        }

        int numSubdirs = subdirs.length;

        // For every subdirectory, check if we should run tests in it
        for (int i = 0; i < numSubdirs; i++)
        {
            File subTestDir = new File(testDirectory, subdirs[i]);

            if ((null == subTestDir) || (!subTestDir.exists()))
            {
                // Just log it and continue; presumably we'll find 
                //  other directories to test
                reporter.logWarningMsg("subTestDir(" + subTestDir.getPath() 
                                       + ") does not exist, skipping!");
                continue;
            }

            // Construct matching directories for outputs and golds
            File subOutDir = new File(outputDir, subdirs[i]);
            File subGoldDir = new File(goldDir, subdirs[i]);

            // Validate that each of the specified dirs exists
            // Returns directory references like so:
            //  testDirectory = 0, outDirectory = 1, goldDirectory = 2
            File[] dirs = validateDirs(new File[] { subTestDir }, 
                                       new File[] { subOutDir, subGoldDir });

            if (null == dirs)  // also ensures that dirs[0] is non-null
            {
                // Just log it and continue; presumably we'll find 
                //  other directories to test
                reporter.logWarningMsg("subTestDir(" + subTestDir.getPath() 
                                       + ") or associated dirs does not exist, skipping!");
                continue;
            }

            // Call worker method to process the individual directory
            //  and get a list of .xsl files to test
            Vector files = getFilesFromDir(subTestDir, getFileFilter(), embedded);
            Hashtable goldFiles = getGoldsFromDir(subGoldDir, getGoldFileFilter(), processor);

            // 'Transform' the list of individual test files into a 
            //  list of Datalets with all fields filled in
            //@todo should getFilesFromDir and buildDatalets be combined?
            Vector datalets = buildDatalets(files, subTestDir, subOutDir, subGoldDir, goldFiles);

            if ((null == datalets) || (0 == datalets.size()))
            {
                // Just log it and continue; presumably we'll find 
                //  other directories to test
                reporter.logWarningMsg("subTestDir(" + subTestDir.getPath() 
                                       + ") did not contain any tests, skipping!");
                continue;
            }

            // Now process the list of files found in this dir
            processFileList(datalets, "Conformance test of: " + subdirs[i]);
        } // end of for...
    }