1 5 package polyglot.pth; 6 7 import java.io.PrintStream ; 8 import java.text.DateFormat ; 9 import java.util.Calendar ; 10 import java.util.Date ; 11 import java.util.Iterator ; 12 import java.util.regex.Pattern ; 13 14 import polyglot.util.ErrorQueue; 15 16 19 public class QuietOutputController extends StdOutputController{ 20 private final boolean showStartScript; 21 private final boolean showFinishScript; 22 private final boolean showScriptProgress; 23 private final boolean showStartFile; 24 private final boolean showFinishFile; 25 private int count = 0; 26 27 private static final char PROGRESS_PASS_CHAR = '.'; 28 private static final char PROGRESS_FAIL_CHAR = '!'; 29 private static final int PROGRESS_LIMIT = 50; 30 31 public QuietOutputController(PrintStream out, 32 boolean showStartScript, 33 boolean showFinishScript, 34 boolean showStartFile, 35 boolean showFinishFile, 36 boolean showScriptProgress) { 37 super(out); 38 this.showStartScript = showStartScript; 39 this.showFinishScript = showFinishScript; 40 this.showScriptProgress = showScriptProgress; 41 this.showStartFile = showStartFile; 42 this.showFinishFile = showFinishFile; 43 } 44 45 protected void finishScriptTestSuite(ScriptTestSuite sts) { 46 if (showScriptProgress) { 47 out.println(); 48 } 49 if (showFinishScript) { 50 super.finishScriptTestSuite(sts); 51 } 52 } 53 54 protected void finishSourceFileTest(SourceFileTest sft, ErrorQueue eq) { 55 if (showFinishFile) { 56 super.finishSourceFileTest(sft, eq); 57 } 58 else if (showScriptProgress) { 59 out.print(sft.success() ? PROGRESS_PASS_CHAR : PROGRESS_FAIL_CHAR); 60 if (count++ >= PROGRESS_LIMIT) { 61 out.println(); 62 count = 0; 63 } 64 } 65 } 66 67 protected void startScriptTestSuite(ScriptTestSuite sts) { 68 if (showStartScript) { 69 super.startScriptTestSuite(sts); 70 } 71 } 72 73 protected void startSourceFileTest(SourceFileTest sft) { 74 if (showStartFile) { 75 super.startSourceFileTest(sft); 76 } 77 } 78 79 } 80 | Popular Tags |