From 6e8f691b426d85da235e5e6a6968b6a7d07cd7a1 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sun, 17 Mar 2019 15:27:50 +0000 Subject: [PATCH] Add test for #620 with attempted workaround. --- src/nimblepkg/nimscriptsupport.nim | 13 +++++++++++++ tests/tester.nim | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/src/nimblepkg/nimscriptsupport.nim b/src/nimblepkg/nimscriptsupport.nim index 2806251..997f198 100644 --- a/src/nimblepkg/nimscriptsupport.nim +++ b/src/nimblepkg/nimscriptsupport.nim @@ -310,6 +310,7 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym = graph = newModuleGraph(graph.config) let conf = graph.config + conf.searchPaths = @[] when declared(NimCompilerApiVersion): if "nimblepkg/nimscriptapi" notin conf.implicitImports: conf.implicitImports.add("nimblepkg/nimscriptapi") @@ -381,11 +382,20 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym = let pkgName = scriptName.splitFile.name # Ensure that "nimblepkg/nimscriptapi" is in the PATH. + var issue620 = false block: + echo(scriptName.splitFile.dir / "nimblepkg" / "nimscriptapi.nim") + if existsFile(scriptName.splitFile.dir / "nimblepkg" / "nimscriptapi.nim"): + # TODO: hacky workaround for #620. + issue620 = true + conf.disableNimblePath() + break + let t = getTempDir() / "nimblecache" let tmpNimscriptApiPath = t / "nimblepkg" / "nimscriptapi.nim" createDir(tmpNimscriptApiPath.splitFile.dir) writeFile(tmpNimscriptApiPath, nimscriptApi) + echo("before ", conf.searchPaths) when declared(NimCompilerApiVersion): when NimCompilerApiVersion >= 3: conf.searchPaths.add(AbsoluteDir t) @@ -393,6 +403,7 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym = conf.searchPaths.add(t) else: searchPaths.add(t) + echo("after ", conf.searchPaths) when declared(NimCompilerApiVersion): initDefines(conf.symbols) @@ -428,6 +439,8 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym = searchPaths.add(compiler_options.libpath) + echo("after2 ", conf.searchPaths) + when declared(resetAllModulesHard): result = makeModule(scriptName) else: diff --git a/tests/tester.nim b/tests/tester.nim index 372900e..ff44add 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -67,6 +67,15 @@ proc inLines(lines: seq[string], line: string): bool = for i in lines: if line.normalize in i.normalize: return true +suite "Issue 620": + test "install nimble": + cd "..": + check execNimble(["install", "-y"]).exitCode == QuitSuccess + + test "nimble check the installed nimble file": + cd execNimble(["path", "nimble"]).output: + check execNimble(["check"]).exitCode == QuitSuccess + test "picks #head when looking for packages": cd "versionClashes" / "aporiaScenario": let (output, exitCode) = execNimble("install", "-y", "--verbose")