-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance Test Framework to be able to run a single test. #391
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,12 @@ public static List<DrillTestCase> getDrillTestCases() throws IOException { | |
LOG.error("Directory " + testDefSourceFile.getAbsolutePath() + " does not exist!"); | ||
System.exit(-1); | ||
} | ||
if (testDefSourceFile.isFile()) { | ||
// Single test execution | ||
singleTestCase(testDefSourceFile, testGroups, drillTestCases); | ||
continue; | ||
} | ||
|
||
List<File> testDefFiles = searchFiles(testDefSourceFile, ".*.json"); | ||
for (File testDefFile : testDefFiles) { | ||
// try { | ||
|
@@ -747,4 +753,60 @@ public static String removeNewLines(String input) { | |
return builder.toString(); | ||
} | ||
|
||
/* Get DrillTestCase for a single query file */ | ||
public static void singleTestCase(File singleTestFile, | ||
String[] testGroups, | ||
List<DrillTestCase> drillTestCases) | ||
throws IOException { | ||
List<File> jsonFiles = searchFiles(singleTestFile.getParentFile(), ".*.json"); | ||
if (jsonFiles.isEmpty()) { | ||
String updir = ""; | ||
while (jsonFiles.isEmpty()) { | ||
updir = updir + "/.."; | ||
File singleTestFileParent = new File(singleTestFile.getParent() + updir); | ||
jsonFiles = searchFiles(singleTestFileParent, ".*.json"); | ||
} | ||
} | ||
for (File jsonFile : jsonFiles) { | ||
TestCaseModeler modeler; | ||
try { | ||
modeler = getTestCaseModeler(jsonFile.getAbsolutePath()); | ||
} catch (JsonParseException e) { | ||
LOG.warn("Caught exception parsing " + jsonFile + ". This test will not be executed.", e); | ||
continue; | ||
} | ||
|
||
String queryFileExtension = modeler.matrices.get(0).inputFile; | ||
Pattern pattern = Pattern.compile(queryFileExtension + "$"); | ||
Matcher matcher = pattern.matcher(singleTestFile.getName()); | ||
if (matcher.find()) { | ||
List<String> categories = modeler.categories; | ||
boolean foundTests = false; | ||
for (String testGroup : testGroups) { | ||
if (categories != null && !categories.contains(testGroup)) { | ||
continue; | ||
} else { | ||
foundTests = true; | ||
break; | ||
} | ||
} | ||
if (!foundTests) {continue;} | ||
String expectedFileExtension = modeler.matrices.get(0).expectedFile; | ||
boolean skipSuite = false; | ||
if (modeler.dependencies != null) { | ||
for (String dependency : modeler.dependencies) { | ||
if (TestDriver.cmdParam.excludeDependenciesAsList().contains(dependency)) { | ||
skipSuite = true; | ||
} | ||
} | ||
} | ||
if (skipSuite) {continue;} | ||
String expectedFileName = getExpectedFile(singleTestFile.getAbsolutePath(), | ||
queryFileExtension, expectedFileExtension); | ||
drillTestCases.add(new DrillTestCase(modeler, singleTestFile.getAbsolutePath(), expectedFileName)); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you test the following scenarios:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to specify the relative path to the test, including the file extension? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does the "..." do?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @agirish. Yes. Previously we would say |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you never encounter a test definition file in any of the upstream directories?