runner icon indicating copy to clipboard operation
runner copied to clipboard

Time critical code times out with test framework showing no details of partially completed tests by default

Open nomennescio opened this issue 3 years ago • 5 comments

When running "performance" Katas, code typically times out repeatedly before arriving at a solution. Now most test frameworks don't print any information on the (partial) completed testcases at all. This is crucial to determine how well you're doing against the goals.

In e.g. Python, you have to force the framework to generate output by sparingly print ('.',flush=True), which runs both the risk of overflowing the output buffer and the risk of needing additional time to execute.

Why not change the test frameworks so that after each test case, output is by default flushed in the CW "terminal".

nomennescio avatar Apr 27 '22 19:04 nomennescio

Since this is not necessarily a language-specific complaint:

can we please have runtimes in Haskell tests? At all?

JohanWiltink avatar Apr 27 '22 19:04 JohanWiltink

Why not change the test frameworks so that after each test case,

PR welcome. For Python, see https://github.com/codewars/python-test-framework . I guess simply adding flush=True will work.

can we please have runtimes in Haskell tests? At all?

If I remember correctly, I had to remove it because it required extra nesting for some reason. I'll try to look for the issue. The source of the formatter is at https://github.com/codewars/hspec-formatters-codewars

kazk avatar May 04 '22 07:05 kazk

For Haskell, I misremembered the few changes I made for https://github.com/codewars/codewars-runner-cli/issues/655 so forget what I wrote above about the nesting.

The completion time for each test case/group is not there because it's not provided by Hspec (at least it didn't back then). https://www.codewars.com/kumite/5c703ea1c447bd4b75bafebf?sel=5c703ea1c447bd4b75bafebf is a hack to add it, but I don't remember the details anymore.

EDIT: Found https://github.com/codewars/codewars-runner-cli/issues/699#issuecomment-466498112

kazk avatar May 04 '22 08:05 kazk

It looks like a newer version of Hspec have some functions to get time since the test started, so maybe it's possible once we update. Not sure if there's a Hspec version compatible with the current one though. We might need to wait until we add a new Haskell version.

kazk avatar May 04 '22 08:05 kazk

This mostly has to do with stdout flushing, and is universal across languages. If you manually flush stdout whenever control enters user function, it works fine again.

Voileexperiments avatar Jul 10 '23 16:07 Voileexperiments