From 93c791eb2729da00755826051258c2b63faeca5d Mon Sep 17 00:00:00 2001 From: Bung Date: Sat, 16 Sep 2023 02:45:22 +0800 Subject: [PATCH] build `nimsuggest_testing` for local testing (#900) ## Summary Make local nimsuggest testing easier by having the nimsuggest `tester` build the `nimsuggest_testing` binary as part of the run. ## Details Previous `nimsuggest_testing` is built in CI environment which meant it is not available when running tests locally. Now if `tester` can't find the `nimsuggest_testing` binary, it's built before running any tests. To test locally, as per the module comments: > When debugging, to run a single test, use for e.g.: > `nim r nimsuggest/tester.nim nimsuggest/tests/tsug_accquote.nim` --------- Co-authored-by: Saem Ghani --- nimsuggest/tester.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nimsuggest/tester.nim b/nimsuggest/tester.nim index 96473fe52d4..2d30e8797b1 100644 --- a/nimsuggest/tester.nim +++ b/nimsuggest/tester.nim @@ -26,7 +26,6 @@ import std/compilesettings proc parseTest(filename: string; epcMode=false): Test = const cursorMarker = "#[!]#" let nimsug = "bin" / addFileExt("nimsuggest_testing", ExeExt) - doAssert nimsug.fileExists, nimsug const libpath = querySetting(libPath) result.filename = filename result.dest = getTempDir() / extractFilename(filename) @@ -345,6 +344,14 @@ proc runTest(filename: string): int = result = report.len proc main() = + let nimsug = "bin" / addFileExt("nimsuggest_testing", ExeExt) + if not nimsug.fileExists(): + # xxx: ideally compiling a test binary should be done in `koch` + const args = "c -o:bin/nimsuggest_testing -d:release nimsuggest/nimsuggest" + let cmd = getCurrentCompilerExe() & " " & args + doAssert execShellCmd(getCurrentCompilerExe() & " " & args) == 0, cmd + + doAssert nimsug.fileExists, nimsug var failures = 0 if os.paramCount() > 0: let x = os.paramStr(1)