Search in sources :

Example 1 with Sequential

use of org.apache.tools.ant.taskdefs.Sequential in project cassandra by apache.

the class TestHelper method execute.

public void execute() {
    Project project = getProject();
    String sep = project.getProperty("path.separator");
    String[] allTestClasses = project.getProperty("all-test-classes").split(sep);
    Sequential seqTask = (Sequential) project.createTask("sequential");
    for (int i = 0; i < allTestClasses.length; i++) {
        if (allTestClasses[i] == null)
            continue;
        MacroInstance task = (MacroInstance) project.createTask(property);
        task.setDynamicAttribute("test.file.list", ' ' + allTestClasses[i]);
        seqTask.addTask(task);
    }
    seqTask.perform();
}
Also used : Project(org.apache.tools.ant.Project) Sequential(org.apache.tools.ant.taskdefs.Sequential) MacroInstance(org.apache.tools.ant.taskdefs.MacroInstance)

Example 2 with Sequential

use of org.apache.tools.ant.taskdefs.Sequential in project ant by apache.

the class Funtest method execute.

/**
 * Run the functional test sequence.
 * <p>
 * This is a fairly complex workflow -what is going on is that we try to clean up
 * no matter how the run ended, and to retain the innermost exception that got thrown
 * during cleanup. That is, if teardown fails after the tests themselves failed, it is the
 * test failing that is more important.
 * @throws BuildException if something was caught during the run or teardown.
 */
@Override
public void execute() throws BuildException {
    // validation
    validateTask(setup, "setup");
    validateTask(application, "application");
    validateTask(tests, "tests");
    validateTask(reporting, "reporting");
    validateTask(teardown, "teardown");
    // and bail out if it is defined but not true
    if (condition != null && !condition.eval()) {
        // we are skipping the test
        log(SKIPPING_TESTS);
        return;
    }
    long timeoutMillis = timeout * timeoutUnitMultiplier;
    // set up the application to run in a separate thread
    Parallel applicationRun = newParallel(timeoutMillis);
    // with a worker which we can use to manage it
    WorkerAnt worker = new WorkerAnt(applicationRun, null);
    if (application != null) {
        applicationRun.addTask(application);
    }
    // The test run consists of the block followed by the tests.
    long testRunTimeout = 0;
    Sequential testRun = new Sequential();
    bind(testRun);
    if (block != null) {
        // waitfor is not a task, it needs to be adapted
        TaskAdapter ta = new TaskAdapter(block);
        ta.bindToOwner(this);
        validateTask(ta, "block");
        testRun.addTask(ta);
        // add the block time to the total test run timeout
        testRunTimeout = block.calculateMaxWaitMillis();
    }
    // add the tests and more delay
    if (tests != null) {
        testRun.addTask(tests);
        testRunTimeout += timeoutMillis;
    }
    // add the reporting and more delay
    if (reporting != null) {
        testRun.addTask(reporting);
        testRunTimeout += timeoutMillis;
    }
    // wrap this in a parallel purely to set up timeouts for the
    // test run
    timedTests = newParallel(testRunTimeout, testRun);
    try {
        // run any setup task
        if (setup != null) {
            Parallel setupRun = newParallel(timeoutMillis, setup);
            setupRun.execute();
        }
        // start the worker thread and leave it running
        worker.start();
        // start the probe+test sequence
        timedTests.execute();
    } catch (BuildException e) {
        // Record the exception and continue
        testException = e;
    } finally {
        // teardown always runs; its faults are filed away
        if (teardown != null) {
            try {
                Parallel teardownRun = newParallel(timeoutMillis, teardown);
                teardownRun.execute();
            } catch (BuildException e) {
                teardownException = e;
            }
        }
    }
    try {
        // wait for the worker to have finished
        long shutdownTimeMillis = shutdownTime * shutdownUnitMultiplier;
        worker.waitUntilFinished(shutdownTimeMillis);
        if (worker.isAlive()) {
            // then, if it is still running, interrupt it a second time.
            log(APPLICATION_FORCIBLY_SHUT_DOWN, Project.MSG_WARN);
            worker.interrupt();
            worker.waitUntilFinished(shutdownTimeMillis);
        }
    } catch (InterruptedException e) {
        // success, something interrupted the shutdown. There may be a leaked
        // worker;
        log(SHUTDOWN_INTERRUPTED, e, Project.MSG_VERBOSE);
    }
    applicationException = worker.getBuildException();
    // Now faults are analysed
    processExceptions();
}
Also used : Sequential(org.apache.tools.ant.taskdefs.Sequential) TaskAdapter(org.apache.tools.ant.TaskAdapter) Parallel(org.apache.tools.ant.taskdefs.Parallel) BuildException(org.apache.tools.ant.BuildException) WorkerAnt(org.apache.tools.ant.util.WorkerAnt)

Aggregations

Sequential (org.apache.tools.ant.taskdefs.Sequential)2 BuildException (org.apache.tools.ant.BuildException)1 Project (org.apache.tools.ant.Project)1 TaskAdapter (org.apache.tools.ant.TaskAdapter)1 MacroInstance (org.apache.tools.ant.taskdefs.MacroInstance)1 Parallel (org.apache.tools.ant.taskdefs.Parallel)1 WorkerAnt (org.apache.tools.ant.util.WorkerAnt)1