Author: [log in to unmask] Date: Mon Apr 13 22:58:20 2015 New Revision: 2689 Log: Exclude some steering files that do not initialize properly in test environment (missing 3D field map). Modified: java/trunk/integration-tests/src/test/java/org/hps/SteeringFilesTest.java Modified: java/trunk/integration-tests/src/test/java/org/hps/SteeringFilesTest.java ============================================================================= --- java/trunk/integration-tests/src/test/java/org/hps/SteeringFilesTest.java (original) +++ java/trunk/integration-tests/src/test/java/org/hps/SteeringFilesTest.java Mon Apr 13 22:58:20 2015 @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -18,44 +19,78 @@ import org.hps.steering.SteeringFileCatalog; /** - * Perform a dry run on all steering files to make sure they are valid - * and do not reference non-existent Drivers or define invalid parameters. - * + * Perform a dry run on all steering files to make sure they are valid and do not reference non-existent Drivers or + * define invalid parameters. + * * @author Jeremy McCormick <[log in to unmask]> */ public class SteeringFilesTest extends TestCase { - + /** * Dummy job manager. */ static class DummyJobManager extends JobManager { + @Override protected void setupInputFiles() { // We don't actually want this to happen, as dummy variables are being used! } } - + + static final List<String> SKIP_STEERING_FILES = new ArrayList<String>(); + + static final Pattern varPattern = Pattern.compile("[$][{][a-zA-Z_-]*[}]"); + + static { + // FIXME: These all reference the field map which is not found. + SKIP_STEERING_FILES.add("/org/hps/steering/readout/EngineeringRun2014PrescaledTriggers.lcsim"); + SKIP_STEERING_FILES.add("/org/hps/steering/readout/EngineeringRun2014PresTrigPairs0.lcsim"); + SKIP_STEERING_FILES.add("/org/hps/steering/readout/EngineeringRun2014PresTrigPairs1.lcsim"); + SKIP_STEERING_FILES.add("/org/hps/steering/readout/EngineeringRun2014PresTrigSingles0.lcsim"); + SKIP_STEERING_FILES.add("/org/hps/steering/readout/EngineeringRun2014PresTrigSingles1.lcsim"); + SKIP_STEERING_FILES.add("/org/hps/steering/users/holly/EcalSimReadout.lcsim"); + } + /** - * Perform a dry run job on every steering file in the steering-files module. - * @throws Exception If there was an error initializing from one of the steering files. + * Find the variable names in an lcsim steering file. + * + * @param resourcePath The resource path to the file. + * @return The set of variable names. + * @throws IOException If there was an file IO error. */ - public void testSteeringFiles() throws Exception { - DatabaseConditionsManager.getInstance().setLogLevel(Level.SEVERE); - List<String> steeringResources = SteeringFileCatalog.find(); - for (String steeringResource : steeringResources) { - steeringFileCheck(steeringResource); + private static Set<String> findVariableNames(final String resourcePath) throws IOException { + final Set<String> variableNames = new HashSet<String>(); + final InputStream inputStream = SteeringFileCatalog.class.getResourceAsStream(resourcePath); + final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + String line; + while ((line = reader.readLine()) != null) { + final Matcher match = varPattern.matcher(line); + while (match.find()) { + + // Variable string with ${...} enclosure included. + final String variable = match.group(); + + // The name of the variable for lookup. + final String variableName = variable.substring(2, variable.length() - 1); + + variableNames.add(variableName); + } } + reader.close(); + inputStream.close(); + return variableNames; } - + /** * Perform a dry run job on a steering file with the given resource path. + * * @param resourcePath The resource path in the jar. * @throws Exception If there was an error initializing from this steering file. */ - private static void steeringFileCheck(String resourcePath) throws Exception { - System.out.println("running steering file check on " + resourcePath); - JobManager job = new DummyJobManager(); - Set<String> variableNames = findVariableNames(resourcePath); - for (String variableName : variableNames) { + private static void steeringFileCheck(final String resourcePath) throws Exception { + System.out.println("running steering file check on " + resourcePath); + final JobManager job = new DummyJobManager(); + final Set<String> variableNames = findVariableNames(resourcePath); + for (final String variableName : variableNames) { String value = "dummy"; if (variableName.equals("runNumber")) { value = "1"; @@ -66,35 +101,19 @@ job.setPerformDryRun(true); job.run(); } - - static final Pattern varPattern = Pattern.compile("[$][{][a-zA-Z_-]*[}]"); /** - * Find the variable names in an lcsim steering file. - * @param resourcePath The resource path to the file. - * @return The set of variable names. - * @throws IOException If there was an file IO error. + * Perform a dry run job on every steering file in the steering-files module. + * + * @throws Exception If there was an error initializing from one of the steering files. */ - private static Set<String> findVariableNames(String resourcePath) throws IOException { - Set<String> variableNames = new HashSet<String>(); - InputStream inputStream = SteeringFileCatalog.class.getResourceAsStream(resourcePath); - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - String line; - while((line = reader.readLine()) != null) { - Matcher match = varPattern.matcher(line); - while (match.find()) { - - // Variable string with ${...} enclosure included. - String variable = match.group(); - - // The name of the variable for lookup. - String variableName = variable.substring(2, variable.length() - 1); - - variableNames.add(variableName); + public void testSteeringFiles() throws Exception { + DatabaseConditionsManager.getInstance().setLogLevel(Level.SEVERE); + final List<String> steeringResources = SteeringFileCatalog.find(); + for (final String steeringResource : steeringResources) { + if (!SKIP_STEERING_FILES.contains(steeringResource)) { + steeringFileCheck(steeringResource); } - } - reader.close(); - inputStream.close(); - return variableNames; - } + } + } }