The current TAP output in CheckDetail looks something like the following example from rpmlint:
CheckDetail
TAP version 13 1..1 not ok - $CHECKNAME for Koji build btrfs-progs-devel-3.14-1.fc20.x86_64.rpm # FAIL --- details:
Using $CHECKNAME looks bad and really needs to be a better indication of the check/task that has been run. The following needs to be done: * add a concept of "name" to CheckDetail stored as a class data member * change TAP output such that it uses this name instead of the dummy $CHECKNAME placeholder
$CHECKNAME
This ticket had assigned some Differential requests: D150 D130
$CHECKNAME is a placeholder waiting for us to add the needed bits in order to replace it with the actual name. I don't think we need to have CheckDetail.name - that would indicate that the user need to fill in that variable, or they he might change it. I would rather do all of that automatically. The runner already passes check name into directives; why shouldn't it make it available also for CheckDetail?
CheckDetail.name
My idea is to have a Context class that is a globally available singleton and contains important information, like the check name (and possibly other). I know that you don't like this approach, but I see no better way how to pass that information from the runner to the check to the libtaskotron library. And unless we need a single runner to execute multiple checks (which is not supported at the moment), it should work well.
Context
With this approach, we would have a proper check name filled in only when the check was run through the runner (with no yaml to parse, the check name is unknown and the context is empty). But still, I think that's acceptable and it's better than to require the user to manually fill the variable. The simpler for the user, the better. Moreoever, when not run through the runner, the result won't be sent to ResultsDB anyway. We could implement a fallback for this case based on sys.argv[0] or sys.modules['__main__'].__file__ or similar, just for the sole purpose of TAP output looking good.
sys.argv[0]
sys.modules['__main__'].__file__
So, the CheckDetail.export_TAP() would call:
CheckDetail.export_TAP()
checkname = Context.getInstance().checkname or sys.argv[0]
For the check developer, everything would be automagical.
Since we seem to be at an impasse in D130, are there any other solutions you'd be willing to consider, even if they're temporary.
I really don't want to have '$CHECKNAME' in the TAP output when we deploy to production
Fixed in D150.