Search in sources :

Example 1 with JobScheduler

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;
}
Also used : JobScheduler(org.evosuite.continuous.job.JobScheduler) JobExecutor(org.evosuite.continuous.job.JobExecutor) StorageManager(org.evosuite.continuous.persistency.StorageManager) IOException(java.io.IOException) ProjectAnalyzer(org.evosuite.continuous.project.ProjectAnalyzer) ProjectStaticData(org.evosuite.continuous.project.ProjectStaticData) JobDefinition(org.evosuite.continuous.job.JobDefinition)

Aggregations

IOException (java.io.IOException)1 JobDefinition (org.evosuite.continuous.job.JobDefinition)1 JobExecutor (org.evosuite.continuous.job.JobExecutor)1 JobScheduler (org.evosuite.continuous.job.JobScheduler)1 StorageManager (org.evosuite.continuous.persistency.StorageManager)1 ProjectAnalyzer (org.evosuite.continuous.project.ProjectAnalyzer)1 ProjectStaticData (org.evosuite.continuous.project.ProjectStaticData)1