2021-05-17 11:35:16 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2021 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
# at your option.
|
|
|
|
# This file may not be copied, modified, or distributed except according to
|
|
|
|
# those terms.
|
|
|
|
|
|
|
|
import
|
2022-04-20 07:57:50 +00:00
|
|
|
std/[tables, strutils, times],
|
|
|
|
unittest2
|
2021-05-17 11:35:16 +00:00
|
|
|
|
|
|
|
export
|
2022-04-20 07:57:50 +00:00
|
|
|
tables, strutils, unittest2
|
2021-05-17 11:35:16 +00:00
|
|
|
|
2022-04-20 07:57:50 +00:00
|
|
|
type
|
|
|
|
SimStat* = object
|
|
|
|
ok*: int
|
|
|
|
skipped*: int
|
|
|
|
failed*: int
|
2021-06-18 07:37:59 +00:00
|
|
|
|
2022-04-20 07:57:50 +00:00
|
|
|
proc inc*(stat: var SimStat, name: string, status: TestStatus) =
|
|
|
|
echo name, ", ", status
|
|
|
|
if status == OK:
|
|
|
|
inc stat.ok
|
|
|
|
elif status == SKIPPED:
|
|
|
|
inc stat.skipped
|
|
|
|
else:
|
|
|
|
inc stat.failed
|
2021-05-17 11:35:16 +00:00
|
|
|
|
2022-04-20 07:57:50 +00:00
|
|
|
proc `$`*(stat: SimStat): string =
|
|
|
|
"ok: $1, skipped: $2, failed: $3" % [$stat.ok, $stat.skipped, $stat.failed]
|
2021-05-17 11:35:16 +00:00
|
|
|
|
2022-04-20 07:57:50 +00:00
|
|
|
proc print*(stat: SimStat, dur: Duration, name: string) =
|
|
|
|
var f = open(name & ".md", fmWrite)
|
|
|
|
f.write("* " & name)
|
|
|
|
f.write("\n")
|
|
|
|
f.write(" - " & $stat)
|
|
|
|
f.write("\n")
|
|
|
|
f.write(" - " & $dur)
|
|
|
|
f.write("\n")
|
|
|
|
f.close()
|