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
|
2022-06-17 00:53:33 +00:00
|
|
|
failingCases*: seq[string]
|
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
|
2022-06-17 00:53:33 +00:00
|
|
|
stat.failingCases.add name
|
2021-05-17 11:35:16 +00:00
|
|
|
|
2022-04-20 07:57:50 +00:00
|
|
|
proc `$`*(stat: SimStat): string =
|
2022-07-04 05:35:03 +00:00
|
|
|
if stat.failingCases.len > 0:
|
|
|
|
result.add " - Failing Cases:\n"
|
|
|
|
for c in stat.failingCases:
|
|
|
|
result.add " - $1 \n" % [c]
|
|
|
|
|
2022-06-17 00:53:33 +00:00
|
|
|
result.add "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()
|