1 2 3 package org.quilt.frontend.ant; 4 5 import org.apache.tools.ant.BuildException; 6 import org.apache.tools.ant.Project; 7 import org.apache.tools.ant.Task; 8 import org.apache.tools.ant.taskdefs.ExecuteWatchdog; 10 import org.quilt.framework.*; 11 import org.quilt.runner.*; 12 13 16 public class TestExec { 17 private Project project = null; 18 private Task task = null; 19 private TaskControl tc = null; 20 private QuiltTest qt = null; 21 22 23 public TestExec() { } 24 25 33 protected void execute(QuiltTest arg, TaskControl tc) { 34 QuiltTest test = (QuiltTest) arg.clone(); 35 this.tc = tc; 36 task = tc.getTask(); 37 project = task.getProject(); 38 39 if (test.getTodir() == null) { 42 test.setTodir(project.resolveFile(".")); 43 } 44 if (test.getOutfile() == null) { 45 test.setOutfile("TEST-" + test.getName()); 46 } 47 49 int exitValue = Runner.ERRORS; 51 boolean timedOut = false; 52 if (!test.getFork()) { 53 CallTest ct = new CallTest(); 54 exitValue = ct.execTest(test, tc); 55 } else { 56 ForkTest ft = new ForkTest(); 57 ExecuteWatchdog watchdog = tc.createWatchdog(); 58 exitValue = ft.execTest(test, tc, watchdog); 59 if (watchdog != null) { 60 timedOut = watchdog.killedProcess(); 61 } 62 } 63 boolean errorOccurredHere 64 = exitValue == Runner.ERRORS; 65 boolean failureOccurredHere 67 = exitValue != Runner.SUCCESS; 68 if (failureOccurredHere) { 70 if ( (errorOccurredHere && test.getHaltOnError ()) 71 || (failureOccurredHere && test.getHaltOnFailure()) ) { 72 throw new BuildException( 73 "Test " + test.getName() + " failed" 74 + (timedOut ? " (timeout)" : ""), task.getLocation()); 75 } else { 76 task.log("TEST " + test.getName() + " FAILED" 77 + (timedOut ? " (timeout)" : ""), 78 Project.MSG_ERR); 79 if (errorOccurredHere 80 && test.getErrorProperty() != null) { 81 project.setNewProperty( 82 test.getErrorProperty(), "true"); 83 } 84 if (failureOccurredHere 85 && test.getFailureProperty() != null) { 86 project.setNewProperty( 87 test.getFailureProperty(), "true"); 88 } 89 } 90 } 91 } 92 } 93 | Popular Tags |