# std.Build: implement unit test timeouts · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/7e7d7875b9af97bd04ca03a98b2e4188d57e3c13)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 7e7d7875b9af97bd04ca03a98b2e4188d57e3c13

Requested commit: 7e7d7875b9af97bd04ca03a98b2e4188d57e3c13

Commit: 7e7d7875b9af97bd04ca03a98b2e4188d57e3c13

Tree: 59d1f3ebe4d23a4c92fee31a5a2c763de7a9012e

Author: mlugg

Committer: Matthew Lugg

## Message

```
std.Build: implement unit test timeouts

For now, there is a flag to `zig build` called `--test-timeout-ms` which
accepts a value in milliseconds. If the execution time of any individual
unit test exceeds that number of milliseconds, the test is terminated
and marked as timed out.

In the future, we may want to increase the granularity of this feature
by allowing timeouts to be specified per-step or even per-test. However,
a global option is actually very useful. In particular, it can be used
in CI scripts to ensure that no individual unit test exceeds some
reasonable limit (e.g. 60 seconds) without having to assign limits to
every individual test step in the build script.

Also, individual unit test durations are now shown in the time report
web interface -- this was fairly trivial to add since we're timing tests
(to check for timeouts) anyway.

This commit makes progress on #19821, but does not close it, because
that proposal includes a more sophisticated mechanism for setting
timeouts.

Co-Authored-By: David Rubin <david@vortan.dev>

```

## Parents

- [337762114f575824a1ab793dca41a3d073aa17cd](https://git.cafe/gitcafe/zig/commit/337762114f575824a1ab793dca41a3d073aa17cd?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/7e7d7875b9af97bd04ca03a98b2e4188d57e3c13?format=markdown)
