use of org.apache.sysml.conf.DMLConfig in project incubator-systemml by apache.
the class DataTypeChangeTest method runValidateTest.
private void runValidateTest(String fullTestName, boolean expectedException) {
boolean raisedException = false;
try {
// Tell the superclass about the name of this test, so that the superclass can
// create temporary directories.
TestConfiguration testConfig = new TestConfiguration(TEST_CLASS_DIR, fullTestName, new String[] {});
addTestConfiguration(fullTestName, testConfig);
loadTestConfiguration(testConfig);
DMLConfig conf = new DMLConfig(getCurConfigFile().getPath());
ConfigurationManager.setLocalConfig(conf);
String dmlScriptString = "";
HashMap<String, String> argVals = new HashMap<String, String>();
//read script
try (BufferedReader in = new BufferedReader(new FileReader(fullTestName))) {
String s1 = null;
while ((s1 = in.readLine()) != null) dmlScriptString += s1 + "\n";
}
//parsing and dependency analysis
ParserWrapper parser = ParserFactory.createParser(org.apache.sysml.api.mlcontext.ScriptType.DML);
DMLProgram prog = parser.parse(DMLScript.DML_FILE_PATH_ANTLR_PARSER, dmlScriptString, argVals);
DMLTranslator dmlt = new DMLTranslator(prog);
dmlt.liveVariableAnalysis(prog);
dmlt.validateParseTree(prog);
} catch (LanguageException ex) {
raisedException = true;
if (raisedException != expectedException)
ex.printStackTrace();
} catch (Exception ex2) {
ex2.printStackTrace();
throw new RuntimeException(ex2);
//Assert.fail( "Unexpected exception occured during test run." );
}
//check correctness
Assert.assertEquals(expectedException, raisedException);
}
Aggregations