added documentation to test scripts

This commit is contained in:
adamopolous
2019-08-30 14:12:47 -04:00
parent 20d89792cf
commit 3e96ae0e20
+12 -14
View File
@@ -51,11 +51,17 @@ long getDurationFromTestReportClass(String fileContents, String fileName) {
} }
/* /*
* Creates <fully qualified classname, duration> from JUnit test report * Creates a map of tests to their durations, organized by the type of
* application configuration they require. This gets the mapping from the
* resource file app_config_breakout.txt.
*
* eg: GhidraAppConfiguration -> DiffTestTypeAdapter, 0.135s
*/ */
def Map<String, Map<String, Long>> getTestReport() { def Map<String, Map<String, Long>> getTestReport() {
// populate testReport only once per gradle configuration phase
if (project.testReport == null) { if (project.testReport != null) {
return project.testReport;
}
logger.debug("getTestReport: Populating 'testReport' using '$testTimeParserInputDir'") logger.debug("getTestReport: Populating 'testReport' using '$testTimeParserInputDir'")
@@ -145,7 +151,6 @@ def Map<String, Map<String, Long>> getTestReport() {
totalHtmlFiles++ totalHtmlFiles++
// Only read html file for a Test and not a test Suite // Only read html file for a Test and not a test Suite
if(hasValidTestReportClassName(file.name)) { if(hasValidTestReportClassName(file.name)) {
String fileContents = file.text String fileContents = file.text
/* The fully qualified class name appears in the test report as: /* The fully qualified class name appears in the test report as:
* <h1>Class ghidra.app.plugin.assembler.sleigh.BuilderTest</h1> * <h1>Class ghidra.app.plugin.assembler.sleigh.BuilderTest</h1>
@@ -153,7 +158,6 @@ def Map<String, Map<String, Long>> getTestReport() {
String fqNameFromTestReport = fileContents.find("(?<=<h1>Class\\s).*?(?=</h1>)") String fqNameFromTestReport = fileContents.find("(?<=<h1>Class\\s).*?(?=</h1>)")
int nameIndex = fqNameFromTestReport.lastIndexOf('.') int nameIndex = fqNameFromTestReport.lastIndexOf('.')
String shortName = fqNameFromTestReport.substring(nameIndex+1); String shortName = fqNameFromTestReport.substring(nameIndex+1);
long durationInMillis = getDurationFromTestReportClass(fileContents, file.name) long durationInMillis = getDurationFromTestReportClass(fileContents, file.name)
@@ -186,7 +190,6 @@ def Map<String, Map<String, Long>> getTestReport() {
unknownConfigurationBucket.put(fqNameFromTestReport, durationInMillis); unknownConfigurationBucket.put(fqNameFromTestReport, durationInMillis);
} }
else { else {
if (integrationConfigs.contains(extendsClass)) { if (integrationConfigs.contains(extendsClass)) {
integrationConfigurationBucket.put(fqNameFromTestReport, durationInMillis); integrationConfigurationBucket.put(fqNameFromTestReport, durationInMillis);
} }
@@ -211,12 +214,11 @@ def Map<String, Map<String, Long>> getTestReport() {
testReport.put("ghidra", ghidraConfigurationBucket); testReport.put("ghidra", ghidraConfigurationBucket);
testReport.put("unknown", unknownConfigurationBucket); testReport.put("unknown", unknownConfigurationBucket);
// END TEST
logger.debug("getTestReport: Added to testReport: class name = '" logger.debug("getTestReport: Added to testReport: class name = '"
+ fqNameFromTestReport + "' and durationInMillis = '"+ durationInMillis + fqNameFromTestReport + "' and durationInMillis = '"+ durationInMillis
+"' from " + file.name) +"' from " + file.name)
} else { }
else {
logger.debug("getTestReport: Excluding " + file.name + " from test report parsing.") logger.debug("getTestReport: Excluding " + file.name + " from test report parsing.")
excludedHtmlFileNames += file.name + ", " excludedHtmlFileNames += file.name + ", "
excludedHtmlFiles++ excludedHtmlFiles++
@@ -230,14 +232,11 @@ def Map<String, Map<String, Long>> getTestReport() {
} }
assert totalHtmlFiles != 0 : "getTestReport: Did not parse any valid html files in $testTimeParserInputDir. Directory might be empty" assert totalHtmlFiles != 0 : "getTestReport: Did not parse any valid html files in $testTimeParserInputDir. Directory might be empty"
assert totalHtmlFiles == (processedFiles + excludedHtmlFiles) : "Not all html files processed." assert totalHtmlFiles == (processedFiles + excludedHtmlFiles) : "Not all html files processed."
logger.info("getTestReport:\n" + logger.info("getTestReport:\n" +
"\tIncluded " + testReport.size() + " and excluded " + excludedHtmlFiles "\tIncluded " + testReport.size() + " and excluded " + excludedHtmlFiles
+ " html files out of " + totalHtmlFiles + " in Junit test report.\n" + " html files out of " + totalHtmlFiles + " in Junit test report.\n"
+ "\tExcluded html file names are: " + excludedHtmlFileNames + "\n" + "\tExcluded html file names are: " + excludedHtmlFileNames + "\n"
+ "\tParsed test report located at " + testTimeParserInputDir) + "\tParsed test report located at " + testTimeParserInputDir)
}
return project.testReport return project.testReport
} }
@@ -282,8 +281,6 @@ String constructFullyQualifiedClassName(String fileContents, String fileName) {
*/ */
def Map<String, Map> getTestsForSubProject(SourceDirectorySet sourceDirectorySet) { def Map<String, Map> getTestsForSubProject(SourceDirectorySet sourceDirectorySet) {
assert (getTestReport() != null) : "getTestsForSubProject: testReport should not be null"
def testsForSubProject = new HashMap<String,LinkedHashMap>(); def testsForSubProject = new HashMap<String,LinkedHashMap>();
int includedClassFilesNotInTestReport = 0 // class in sourceSet but not in test report, 'bumped' to first task int includedClassFilesNotInTestReport = 0 // class in sourceSet but not in test report, 'bumped' to first task
@@ -296,6 +293,7 @@ def Map<String, Map> getTestsForSubProject(SourceDirectorySet sourceDirectorySet
+ " file(s) in source set to process.") + " file(s) in source set to process.")
Map<String,Map> testReports = getTestReport(); Map<String,Map> testReports = getTestReport();
assert (testReports != null) : "getTestsForSubProject: testReport should not be null"
for (File file : sourceDirectorySet.getFiles()) { for (File file : sourceDirectorySet.getFiles()) {
logger.debug("getTestsForSubProject: Found file in sourceSet = " + file.name) logger.debug("getTestsForSubProject: Found file in sourceSet = " + file.name)