From 8cf97e0e0682f72181d8c2f2b142dcb582584a50 Mon Sep 17 00:00:00 2001 From: Ivan Bobev Date: Sun, 28 Jul 2019 00:12:46 +0300 Subject: [PATCH] Add an unit test for #678 This is an unit test for the issue with multiple downloads and installs of the same dependency package. Related to #678 --- tests/issue678/issue678.nimble | 12 ++++++++++++ tests/issue678/packages.json | 19 +++++++++++++++++++ tests/tester.nim | 16 ++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 tests/issue678/issue678.nimble create mode 100644 tests/issue678/packages.json diff --git a/tests/issue678/issue678.nimble b/tests/issue678/issue678.nimble new file mode 100644 index 0000000..20239e7 --- /dev/null +++ b/tests/issue678/issue678.nimble @@ -0,0 +1,12 @@ +# Package + +version = "0.1.0" +author = "Ivan Bobev" +description = "Package for ensuring that issue #678 is resolved." +license = "MIT" + +# Dependencies + +requires "nim >= 0.19.6" +# to reproduce dependency 2 must be before 1 +requires "issue678_dependency_2", "issue678_dependency_1" diff --git a/tests/issue678/packages.json b/tests/issue678/packages.json new file mode 100644 index 0000000..25338c9 --- /dev/null +++ b/tests/issue678/packages.json @@ -0,0 +1,19 @@ +[ + { + "name": "issue678_dependency_1", + "url": "https://github.com/bobeff/issue678?subdir=dependency_1", + "method": "git", + "tags": [ "test" ], + "description": + "Both first and second level dependency of the issue678 package.", + "license": "MIT" + }, + { + "name": "issue678_dependency_2", + "url": "https://github.com/bobeff/issue678?subdir=dependency_2", + "method": "git", + "tags": [ "test" ], + "description": "First level dependency of the issue678 package.", + "license": "MIT" + } +] diff --git a/tests/tester.nim b/tests/tester.nim index 2a1bb00..b08d0cf 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -844,3 +844,19 @@ test "remove skips packages with revDeps (#504)": test "pass options to the compiler with `nimble install`": cd "passNimFlags": check execNimble("install", "--passNim:-d:passNimIsWorking").exitCode == QuitSuccess + +test "do not install single dependency multiple times (#678)": + # for the test to be correct, the tested package and its dependencies must not + # exist in the local cache + removeDir("nimbleDir") + cd "issue678": + testRefresh(): + writeFile(configFile, """ + [PackageList] + name = "local" + path = "$1" + """.unindent % (getCurrentDir() / "packages.json").replace("\\", "\\\\")) + check execNimble(["refresh"]).exitCode == QuitSuccess + let (output, exitCode) = execNimble("install", "-y") + check exitCode == QuitSuccess + check output.find("issue678_dependency_1@0.1.0 already exists") == -1