I am writing a scripting language for test automation of a certain product for a certain company.
One of the features of the language is that every function, whether or not it is executed should output something so it can be correctly audited by a test auditor.
So there may be situations such as
if(condition1){
doAction(1);
}
now in this situation, even if condition1 is not true, I still need doAction to print something out saying that it is not running because of condition1.
I know I could do
...
else{
print "Not doing doAction(1) because of condition1\n";
}
but that is not sufficient for what I need. It's not standard, not auditable, and leaves the output up to the scripter (the language is supposed to be usable by non scripters)
Hope that kinda explains my problem | [reply] [Watch: Dir/Any] |
if ($condition) {
&doAction;
} else {
print "doAction not executed due to a failure of $condition\n";
}
if you have a whole bunch of $conditions then you could easily pregenerate the codeblock. cool, dynamic code... ! | [reply] [Watch: Dir/Any] [d/l] |
I did discuss that in my reply.
That solution is not enough, because the print statement is generated by the script writer, and therefore could be diffrent every time. I need a system where the output is generated automatically, so it is repeatable and auditable 100% of the time
| [reply] [Watch: Dir/Any] |
If you're writing a scripting language, then it's easy.
Just write your if keyword in such a way that when a condition is not true you walk the AST of the then block and dump it as 'Not doing this, that or the other because of condition1', or whatever you need.
But, more generally, this seems to be a barking mad thing to want to do. What are you going to do about nested ifs? Case statements? Loops? "None of these functions got executed because the loop terminated". If you continue down that road you could well end up with a situation where the audit information swamps the test output, which is in nobody's best interest. Any auditor worth their pay is going to be able to do a far better job of auditing by reading the code than they are by examining the entrails of a run trace.
How about "None of these functions got run, because nobody executed the script"?
| [reply] [Watch: Dir/Any] [d/l] [select] |