Skip to content

Commit 533af85

Browse files
committed
Add a test case for nimble develop --global
Related to #948
1 parent 81a1b62 commit 533af85

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/nimble.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ proc saveLinkFile(pkgInfo: PackageInfo, options: Options) =
11511151

11521152
pkgLinkDir.createDir
11531153
writeFile(pkgLinkFilePath, pkgLinkFileContent)
1154-
displaySuccess(&"Package link file saved to \"{pkgLinkFilePath}\".")
1154+
displaySuccess(pkgLinkFileSavedMsg(pkgLinkFilePath))
11551155

11561156
proc developFromDir(pkgInfo: PackageInfo, options: var Options) =
11571157
assert options.action.typ == actionDevelop,

src/nimblepkg/displaymessages.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,6 @@ proc pkgAlreadyExistsInTheCacheMsg*(pkgInfo: PackageInfo): string =
157157
proc skipDownloadingInAlreadyExistingDirectoryMsg*(dir, name: string): string =
158158
&"The download directory \"{dir}\" already exists.\n" &
159159
&"Skipping the download of \"{name}\"."
160+
161+
proc pkgLinkFileSavedMsg*(path: string): string =
162+
&"Package link file \"{path}\" is saved."

tests/tdevelopfeature.nim

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import unittest, os, strutils, strformat, json, sets
77
import testscommon, nimblepkg/displaymessages, nimblepkg/paths
88

9-
from nimblepkg/common import cd
9+
from nimblepkg/common import cd, getLinkFileName, getLinkFileDir
1010
from nimblepkg/developfile import developFileName, pkgFoundMoreThanOnceMsg
1111
from nimblepkg/version import newVersion, parseVersionRange
1212
from nimblepkg/nimbledatafile import nimbleDataFileName, NimbleDataJsonKeys
@@ -81,6 +81,33 @@ suite "develop feature":
8181
check lines.inLinesOrdered(pkgSetupInDevModeMsg(
8282
pkgBName, installDir / pkgBName))
8383

84+
test "can develop global":
85+
cleanDir installDir
86+
usePackageListFile &"develop/{pkgListFileName}":
87+
let dependencyPath = getCurrentDir() / "develop" / "dependency"
88+
89+
# Check that a link file can be created for a global develop dependency.
90+
cd dependencyPath:
91+
let (output, exitCode) = execNimble("develop", "--global")
92+
check exitCode == QuitSuccess
93+
var lines = output.processOutput
94+
let linkFilePath = installDir / "links" / depName.getLinkFileDir /
95+
depName.getLinkFileName
96+
check lines.inLinesOrdered(pkgLinkFileSavedMsg(linkFilePath))
97+
check lines.inLinesOrdered(pkgSetupInDevModeMsg(
98+
depName, dependencyPath))
99+
check linkFilePath.fileExists
100+
let linkFileLines = linkFilePath.readFile.split('\n')
101+
let expectedLinkNimbleFilePath = dependencyPath / depName & ".nimble"
102+
check linkFileLines[0] == expectedLinkNimbleFilePath
103+
check linkFileLines[1] == dependencyPath
104+
105+
# Check that a link file can be used for finding the dependency.
106+
cd "develop/dependent":
107+
cleanFile dependentPkgName.addFileExt(ExeExt)
108+
let (_, exitCode) = execNimble("run")
109+
check exitCode == QuitSuccess
110+
84111
test "cannot remove package with develop reverse dependency":
85112
cdCleanDir installDir:
86113
usePackageListFile &"../develop/{pkgListFileName}":

0 commit comments

Comments
 (0)