logos-storage-nim/tests/imports.nim
Arnaud a5d6569876
feat: nat traversal relay (#1417)
Signed-off-by: Arnaud <arno.deville@gmail.com>
Signed-off-by: Giuliano Mega <giuliano.mega@gmail.com>
Co-authored-by: Giuliano Mega <giuliano.mega@gmail.com>
2026-07-23 13:10:36 +00:00

30 lines
770 B
Nim

import std/macros
import std/os
import std/strutils
macro importTests*(dir: static string, exclude: static string): untyped =
## imports every test*.nim file under `dir` (recursively).
## `exclude`, when non-empty, skips files whose path contains it.
let imports = newStmtList()
for file in walkDirRec(dir):
let (_, name, ext) = splitFile(file)
if not (name.startsWith("test") and ext == ".nim"):
continue
if exclude.len > 0 and exclude in file:
continue
imports.add(
quote do:
import `file`
)
imports
macro importAll*(paths: static seq[string]): untyped =
## imports all specified paths
let imports = newStmtList()
for path in paths:
imports.add(
quote do:
import `path`
)
imports