Skip to content

Commit

Permalink
build nimsuggest_testing for local testing (nim-works#900)
Browse files Browse the repository at this point in the history
<!--- The Pull Request (=PR) message is what will get automatically used
as
the commit message when the PR is merged. Make sure that no line is
longer
than 72 characters -->

## 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 <saemghani+github@gmail.com>
  • Loading branch information
bung87 and saem committed Sep 16, 2023
1 parent 0b5235a commit 70fd72e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nimsuggest/tester.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 70fd72e

Please sign in to comment.