diff --git a/nimsuggest/tester.nim b/nimsuggest/tester.nim index b69569288d..46471b756c 100644 --- a/nimsuggest/tester.nim +++ b/nimsuggest/tester.nim @@ -74,6 +74,18 @@ proc parseTest(filename: string; epcMode=false): Test = # else: ignore empty lines for better readability of the specs inc i tmp.close() + # Give every run a private, freshly-wiped NIF cache. Under IC nimsuggest reuses + # the on-disk NIFs of a previous session, but per-symbol usage counts are not + # serialized, so a warm start ranks `sug`/`con` results differently than a cold + # one (e.g. `string` outranks `int` because `system` was loaded, not re-walked). + # The tester runs the stdio and EPC variants of a test as two processes sharing + # the same temp project name — without isolation the second inherits the first's + # NIFs and the result order flips. A dedicated, cleared cache keeps both cold and + # deterministic. + let nimcache = getTempDir() / ("nimsuggest_cache_" & + extractFilename(result.dest).changeFileExt("") & (if epcMode: "_epc" else: "_stdin")) + removeDir(nimcache) + result.cmd.add " --nimcache:" & nimcache # now that we know the markers, substitute them: for a in mitems(result.script): a[0] = a[0] % markers