tcunit / TcUnit-Runner

Program that makes it possible to automate runs of TcUnit unit tests
Other
34 stars 17 forks source link

Implement timeout (or react to exceptions) #10

Closed stefanbesler closed 3 years ago

stefanbesler commented 3 years ago

Sometimes - shit happens ;-) - somebody commits code to a project that causes a runtime exception in TwinCAT, most commonly this occurs with div0 or pointers to NULL. TcUnit-Runner should check the TwinCAT state and if an Exception occurs it should end. Another option would be to timeout after X minutes, where X is provided as a command line argument.

System.Timers.Timer timeout = new System.Timers.Timer(options.timeout);
timeout.Elapsed += KillProcess;
timeout.AutoReset = false; //One-shot-timer
timeout.Start();

static private void KillProcess(Object source, System.Timers.ElapsedEventArgs e)
{
    Console.WriteLine($"timeout occured ... killing processes");
    Environment.Exit(-1);
}

what do you think about this?

sagatowski commented 3 years ago

Great idea. I think the check for exception is great. Is there any easy way to tell the TwinCAT run-state through the automation interface? If the target (after execution of the tests) is not CONFIG or RUN, we should abort.

stefanbesler commented 3 years ago

I try to look into it next week

sagatowski commented 3 years ago

Solved in PR #13.