From 62005c1a3cad1afb4945b8c81eb3b7ab070cdbca Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Mon, 17 Jul 2023 16:22:21 -0700 Subject: [PATCH] setup getPathsClause and parallels --- build.nims | 15 ++++++++++----- tests/testAllParallel.nim | 23 +++++++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/build.nims b/build.nims index b4c5d7f..1c4117d 100644 --- a/build.nims +++ b/build.nims @@ -1,18 +1,23 @@ -import std / [os, strutils, sequtils] +import std / [os, strutils, sequtils, osproc] + +when declared(getPathsClause): + proc nimc(): string = "nim c " & getPathsClause() +else: + proc nimc(): string = "nim c" switch("define", "libp2p_pki_schemes=secp256k1") task testAll, "Run DHT tests": - exec "nim c -r tests/testAll.nim" + exec nimc() & " -r tests/testAll.nim" task test, "Run DHT tests": - exec "nim c -r -d:testsAll --verbosity:0 tests/testAllParallel.nim" + exec nimc() & " -r -d:testsAll --verbosity:0 tests/testAllParallel.nim" task testPart1, "Run DHT tests A": - exec "nim c -r -d:testsPart1 tests/testAllParallel.nim" + exec nimc() & " -r -d:testsPart1 tests/testAllParallel.nim" task testPart2, "Run DHT tests B": - exec "nim c -r -d:testsPart2 tests/testAllParallel.nim" + exec nimc() & " -r -d:testsPart2 tests/testAllParallel.nim" task coverage, "generates code coverage report": var (output, exitCode) = gorgeEx("which lcov") diff --git a/tests/testAllParallel.nim b/tests/testAllParallel.nim index 7bff2e1..0589148 100644 --- a/tests/testAllParallel.nim +++ b/tests/testAllParallel.nim @@ -2,21 +2,24 @@ # ./dht/[test_providers, test_providermngr], # ./discv5/[test_discoveryv5, test_discoveryv5_encoding] -import osproc +import std/[os, osproc, strutils] + +when declared(getPathsClause): + proc nimc(): string = "nim c -r " & getPathsClause() +else: + proc nimc(): string = "nim c -r " var cmds: seq[string] +for d in walkDirRec("tests", {pcDir}): + for (kind, file) in walkDir(d): + if kind == pcFile and file.endswith(".nim") and file.startsWith("t"): + cmds.add nimc() & file.absolutePath.quoteShell() when defined(testsPart1) or defined(testsAll): - cmds.add [ - "nim c -r tests/dht/test_providers.nim", - "nim c -r tests/dht/test_providermngr.nim", - ] + cmds = cmds[0..cmds.len div 2] when defined(testsPart2) or defined(testsAll): - cmds.add [ - "nim c -r tests/discv5/test_discoveryv5.nim", - "nim c -r tests/discv5/test_discoveryv5_encoding.nim", - ] + cmds = cmds[cmds.len div 2..