From fff29f7a6a0787a2245513d6fe12888f90d90c2b Mon Sep 17 00:00:00 2001 From: Zed Date: Tue, 10 Mar 2020 12:30:27 +0100 Subject: [PATCH] Replace markdown report code with testutils --- .gitmodules | 5 +++++ tests/test_helpers.nim | 38 ++------------------------------------ vendor/nim-testutils | 1 + 3 files changed, 8 insertions(+), 36 deletions(-) create mode 160000 vendor/nim-testutils diff --git a/.gitmodules b/.gitmodules index 63dafad21..f1615bc4d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -163,3 +163,8 @@ url = https://github.com/status-im/nim-libbacktrace.git ignore = dirty branch = master +[submodule "vendor/nim-testutils"] + path = vendor/nim-testutils + url = https://github.com/status-im/nim-testutils.git + ignore = dirty + branch = master diff --git a/tests/test_helpers.nim b/tests/test_helpers.nim index 0fcb10489..f86a719f6 100644 --- a/tests/test_helpers.nim +++ b/tests/test_helpers.nim @@ -8,6 +8,7 @@ import os, macros, json, strformat, strutils, parseutils, os, tables, stew/byteutils, stew/ranges/typedranges, net, eth/[common, keys, rlp, p2p], unittest2, + testutils/markdown_reports, ../nimbus/[vm_state, config, transaction, utils, errors], ../nimbus/db/[db_chain, state_db], ../nimbus/vm/interpreter/vm_forks @@ -40,9 +41,6 @@ const nameToFork* = revmap(forkNames) -type - Status* {.pure.} = enum OK, Fail, Skip - func skipNothing*(folder: string, name: string): bool = false proc lacksSupportedForks*(fixtures: JsonNode): bool = @@ -112,39 +110,7 @@ macro jsonTest*(s: static[string], handler: untyped, skipTest: untyped = skipNot status.sort do (a: (string, OrderedTable[string, Status]), b: (string, OrderedTable[string, Status])) -> int: cmp(a[0], b[0]) - let `symbol`: array[Status, string] = ["+", "-", " "] - var raw = "" - var okCountTotal = 0 - var failCountTotal = 0 - var skipCountTotal = 0 - raw.add(`s` & "\n") - raw.add("===\n") - for folder, statuses in status: - raw.add("## " & folder & "\n") - raw.add("```diff\n") - var sortedStatuses = statuses - sortedStatuses.sort do (a: (string, Status), b: (string, Status)) -> int: - cmp(a[0], b[0]) - var okCount = 0 - var failCount = 0 - var skipCount = 0 - for `name`, `final` in sortedStatuses: - raw.add(&`formatted`) - case `final`: - of Status.OK: okCount += 1 - of Status.Fail: failCount += 1 - of Status.Skip: skipCount += 1 - raw.add("```\n") - let sum = okCount + failCount + skipCount - okCountTotal += okCount - failCountTotal += failCount - skipCountTotal += skipCount - raw.add("OK: " & $okCount & "/" & $sum & " Fail: " & $failCount & "/" & $sum & " Skip: " & $skipCount & "/" & $sum & "\n") - - let sumTotal = okCountTotal + failCountTotal + skipCountTotal - raw.add("\n---TOTAL---\n") - raw.add("OK: $1/$4 Fail: $2/$4 Skip: $3/$4\n" % [$okCountTotal, $failCountTotal, $skipCountTotal, $sumTotal]) - writeFile(`s` & ".md", raw) + generateReport(`s`, status) status.clear() func ethAddressFromHex*(s: string): EthAddress = hexToByteArray(s, result) diff --git a/vendor/nim-testutils b/vendor/nim-testutils new file mode 160000 index 000000000..b3b7074e3 --- /dev/null +++ b/vendor/nim-testutils @@ -0,0 +1 @@ +Subproject commit b3b7074e395bdbc6820860955ebbc2556a9386a0