Change result listener parameters on the fly

@connospp I’ve bumped into these same challenges. The ResultTable class is limited, as it’s essentially a collection of name (string) and value (IConvertible) pairs. There doesn’t seem to be a built-in way to attach other metadata (e.g. a file path) to a result parameter.

This was actually the very first thing I worked on when I began OpenTAP development several years ago. I spent a couple months extending the results architecture.

In my case, I ended up formatting several pieces of metadata (e.g. units) into the result name string. All my test steps call a common function for adding metadata to the result name using a fixed format. I used a simple homemade format, but something like JSON might have been a better choice. The formatted name+metadata strings then get passed into ResultSource.Publish as the columnNames argument.

Then on the receiving end, my Result Listeners parse the name and metadata from each column name in the ResultTable, and act accordingly.

I’m not saying this is necessarily the best way to do this, it’s just what I arrived at. Rolf’s recommendation seems like a reasonable alternative.

Your existing solution also seems reasonable, although I might worry about race conditions. If my memory serves me correctly, the order in which a Result Listener receives results is not always guaranteed, due to the multi-threaded nature of the system. If that’s true, I’d worry there might be occasions where your result listener receives “changeResultDir” later than expected, so some of your results might end up in the wrong directory. Just something to watch out for.

1 Like