nimbus-eth1/hive_integration/nodocker/sim_utils.nim

49 lines
1.2 KiB
Nim
Raw Normal View History

# 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
export
2022-04-20 07:57:50 +00:00
tables, strutils, unittest2
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]
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
2022-04-20 07:57:50 +00:00
proc `$`*(stat: SimStat): string =
2022-06-17 00:53:33 +00:00
result.add "Failing Cases:\n"
for c in stat.failingCases:
result.add "- $1 \n" % [c]
result.add "ok: $1, skipped: $2, failed: $3" % [$stat.ok, $stat.skipped, $stat.failed]
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()