use of org.evosuite.continuous.job.JobScheduler in project evosuite by EvoSuite.
the class ContinuousTestGeneration method execute.
/**
* Apply CTG, and return a string with some summary
*
* @return
*/
public String execute() {
// init the local storage manager
StorageManager storage = new StorageManager();
if (!storage.isStorageOk()) {
return "Failed to initialize local storage system";
}
if (Properties.CTG_DELETE_OLD_TMP_FOLDERS) {
storage.deleteAllOldTmpFolders();
}
if (!storage.createNewTmpFolders()) {
return "Failed to create tmp folders";
}
// check project
ProjectAnalyzer analyzer = new ProjectAnalyzer(target, prefix, cuts);
ProjectStaticData data = analyzer.analyze();
if (data.getTotalNumberOfTestableCUTs() == 0) {
return "There is no class to test in the chosen project\n" + "Target: " + target + "\n" + "Prefix: '" + prefix + "'\n";
}
if (Properties.CTG_DEBUG_PORT != null && data.getTotalNumberOfTestableCUTs() != 1) {
throw new IllegalStateException("Cannot debug CTG when more than one CUT is selected");
}
if (Properties.CTG_TIME_PER_CLASS != null) {
configuration = configuration.getWithChangedTime(Properties.CTG_TIME_PER_CLASS, data.getTotalNumberOfTestableCUTs());
}
JobScheduler scheduler = new JobScheduler(data, configuration);
JobExecutor executor = new JobExecutor(storage, projectClassPath, configuration);
// loop: define (partial) schedule
while (scheduler.canExecuteMore()) {
List<JobDefinition> jobs = scheduler.createNewSchedule();
executor.executeJobs(jobs, configuration.getNumberOfUsableCores());
executor.waitForJobs();
}
String description = storage.mergeAndCommitChanges(data, cuts);
if (exportFolder != null) {
try {
exportToFolder(".", exportFolder);
} catch (IOException e) {
return "Failed to export tests: " + e.getMessage();
}
}
// call home
if (configuration.callHome) {
// TODO
}
return description;
}
Aggregations