How can I run busted tests in a while loop until a fastest time is found? #746
Unanswered
ColinKennedy
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to use busted to profile unittests. But variation can cause tests to perform differently across runs (for example a cold cache vs a warm cache).
What I'd like to do is be able to run busted in a while loop that goes something like this
In the above example, a run that is the fastest of 10 consecutive runs is considered "probably the best time we're going to get". And then I'd use the profile results of that fastest run.
How can I achieve that easily with busted? I checked around it seems like busted isn't like other testing frameworks where you can call the test suite runner directly with lua.
I tried a real example using this:
Because runner takes a combination of
arg
andoptions
, the interface for this gets hacky. And then there's thisif loaded then return function() end else loaded = true end that prevents me from calling the runner more than once. I tried to get around it by forcing the file to reload with
package.loaded["busted.runner"] = nil
but it isn't working just yet.Anyway I'm struggling to achieve the effect I'm looking for. Any advice would be appreciated. Maybe I'm just looking in the wrong place and there's an easy way to do this?
Beta Was this translation helpful? Give feedback.
All reactions