fix make test <test> issue

This commit is contained in:
Ivan FB 2026-04-02 23:34:57 +02:00
parent f613f0a301
commit ccfe59b247
No known key found for this signature in database
GPG Key ID: DF0C67A04C543270
2 changed files with 10 additions and 12 deletions

View File

@ -270,8 +270,8 @@ build/%: | $(NIMBLEDEPS_STAMP) build deps librln
compile-test: | $(NIMBLEDEPS_STAMP) build deps librln
echo -e $(BUILD_MSG) "$(TEST_FILE)" "\"$(TEST_NAME)\"" && \
nimble buildTest $(TEST_FILE) && \
nimble execTest $(TEST_FILE) "\"$(TEST_NAME)\""
TEST_FILE="$(TEST_FILE)" nimble buildTest && \
TEST_FILE="$(TEST_FILE)" TEST_NAME="$(TEST_NAME)" nimble execTest
################
## Waku tools ##

View File

@ -80,10 +80,7 @@ proc getNimParams(): string =
proc buildModule(filePath, params = "", lang = "c"): bool =
if not dirExists "build":
mkDir "build"
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
var extra_params = params
for i in 2 ..< paramCount() - 1:
extra_params &= " " & paramStr(i)
if not fileExists(filePath):
echo "File to build not found: " & filePath
@ -447,20 +444,21 @@ task lightpushwithmix, "Build lightpushwithmix":
buildBinary name, "examples/lightpush_mix/"
task buildTest, "Test custom target":
let filepath = paramStr(paramCount())
let filepath = getEnv("TEST_FILE")
if filepath == "":
quit "Missing TEST_FILE environment variable"
discard buildModule(filepath)
import std/strutils
task execTest, "Run test":
# Expects to be parameterized with test case name in quotes
# preceded with the nim source file name and path
# If no test case name is given still it requires empty quotes `""`
let filepath = paramStr(paramCount() - 1)
var testSuite = paramStr(paramCount()).strip(chars = {'\"'})
let filepath = getEnv("TEST_FILE")
if filepath == "":
quit "Missing TEST_FILE environment variable"
var testSuite = getEnv("TEST_NAME").strip(chars = {'\"'})
if testSuite != "":
testSuite = " \"" & testSuite & "\""
exec "build/" & filepath & ".bin " & testSuite
exec "build/" & filepath & ".bin" & testSuite
### C Bindings
let chroniclesParams =