mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-04-14 12:13:11 +00:00
fix test compilation in waku.nimble test conf and test peers
This commit is contained in:
parent
d01d92d7cd
commit
97ef267f39
@ -19,7 +19,7 @@ type TestConf = object
|
||||
Option[InputFile]
|
||||
|
||||
listenAddress* {.
|
||||
defaultValue: parseIpAddress("127.0.0.1"),
|
||||
defaultValue: IpAddress(family: IpAddressFamily.IPv4, address_v4: [127u8, 0, 0, 1]),
|
||||
desc: "Listening address",
|
||||
name: "listen-address"
|
||||
.}: IpAddress
|
||||
@ -62,9 +62,15 @@ suite "nim-confutils - envvar":
|
||||
## Then
|
||||
check confLoadRes.isOk()
|
||||
|
||||
let parsedIpAddress =
|
||||
try:
|
||||
parseIpAddress(listenAddress)
|
||||
except ValueError:
|
||||
IpAddress(family: IpAddressFamily.IPv4, address_v4: [0u8, 0, 0, 0])
|
||||
|
||||
let conf = confLoadRes.get()
|
||||
check:
|
||||
conf.listenAddress == parseIpAddress(listenAddress)
|
||||
conf.listenAddress == parsedIpAddress
|
||||
conf.tcpPort == Port(8080)
|
||||
|
||||
conf.configFile.isSome()
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{.used.}
|
||||
|
||||
import std/options
|
||||
import
|
||||
results,
|
||||
testutils/unittests,
|
||||
|
||||
30
waku.nimble
30
waku.nimble
@ -10,7 +10,7 @@ description = "Waku, Private P2P Messaging for Resource-Restricted Devices"
|
||||
license = "MIT or Apache License 2.0"
|
||||
#bin = @["build/waku"]
|
||||
|
||||
requires "nim == 2.2.6"
|
||||
requires "nim == 2.2.4"
|
||||
requires "nimble == 0.22.3"
|
||||
|
||||
### Dependencies
|
||||
@ -80,10 +80,11 @@ 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)
|
||||
let nimParams = getEnv("NIM_PARAMS")
|
||||
if nimParams.len > 0:
|
||||
extra_params &= " " & nimParams
|
||||
|
||||
if not fileExists(filePath):
|
||||
echo "File to build not found: " & filePath
|
||||
@ -447,17 +448,26 @@ task lightpushwithmix, "Build lightpushwithmix":
|
||||
buildBinary name, "examples/lightpush_mix/"
|
||||
|
||||
task buildTest, "Test custom target":
|
||||
let filepath = paramStr(paramCount())
|
||||
let args = commandLineParams()
|
||||
if args.len == 0:
|
||||
quit "Missing test file"
|
||||
|
||||
let filepath = args[^1]
|
||||
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 args = commandLineParams()
|
||||
if args.len == 0:
|
||||
quit "Missing arguments"
|
||||
# expects: <file> "<test name>"
|
||||
let filepath =
|
||||
if args.len >= 2: args[^2]
|
||||
else: args[^1]
|
||||
var testSuite =
|
||||
if args.len >= 1: args[^1].strip(chars = {'\"'})
|
||||
else: ""
|
||||
if testSuite != "":
|
||||
testSuite = " \"" & testSuite & "\""
|
||||
exec "build/" & filepath & ".bin " & testSuite
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user