public void Runner(object o) { ScriptPath path = (ScriptPath)o; if (!Single) { ForwardOutput("# " + path.ToString(), false, true, Client.OutputReceived); } try { int exit = 1; string exe = Compile(path, Client.TapWasUpdated); if (exe != null) { exit = Run(exe); } TAPApp.VLog(2, "Exit code from {0}: {1}", path, exit); } catch (Exception e) { TAPApp.ELog("Exception running {0}: {1}", path, e.ToString()); } finally { TAPApp.DLog(3, "{0} done.", path); TAPParser.End(); Running = false; Done.Set(); } }
public override void OutputReceived(string s, bool force) { if (s != null) { TAPApp.DLog(4, "received {0}.", s); if (force || TAPApp.Verbose > 0) { TAPApp.Log(s); } } }
void AddTask(ScriptPath sp, bool single) { TAPApp.DLog(3, "Add task {0}", sp); var task = new Task(TaskDone, Client, sp, single); if (Tasks.Count == 0) { task.Head = true; } task.Run(); Tasks.Enqueue(task); }
void ReapHead() { TAPApp.DLog(3, "ReapHead {0} tasks active", Tasks.Count); while (Tasks.Count != 0) { var task = Tasks.Peek(); task.Head = true; if (task.Running) { break; } TAPApp.DLog(3, "finish task {0}", task.ScriptPath); task.WriteBuffered(); task.TaskComplete(); Tasks.Dequeue(); } }
static public void ShowTotals(List <string> paths) { if (Total.NScripts == 0) { string instr = ""; if (paths.Count != 0) { instr = string.Join(", ", paths.ToArray()); } TAPApp.Log("not ok 1 - No matching test scripts. Paths: {0}.", instr); Exit = 1; } else if (Total.NScripts > 1) { TAPApp.Log("# result after {0} scripts:", Total.NScripts); UpdateExit(Total.Show()); TAPApp.DLog(2, "exit is {0}", Exit); } }
public void Run(ScriptPath[] srcs) { int maxtasks = TAPApp.MaxTasks; TAPApp.VLog(3, "Max. {0} {1}.", maxtasks, maxtasks == 1?"task":"parallel tasks"); int k = 0; bool single = srcs.Length == 1; do { bool waiting = k != srcs.Length; int running = CountRunningTasks(); if (!waiting && running == 0) { TAPParser.EndTotal(); } ReapHead(); if (waiting) { running = CountRunningTasks(); while (running < maxtasks) { if (k != srcs.Length) { AddTask(srcs[k], single); ++k; ++running; } else { break; } } } if (Tasks.Count == 0) { break; } TaskDone.WaitOne(); } while(true); TAPApp.DLog(3, "TaskMgr done."); }
static public void EndTotal() { Total.End = DateTime.UtcNow; TAPApp.DLog(3, "Stopped the clock."); }