Skip to content

Commit

Permalink
Add a test case for nimble develop --global
Browse files Browse the repository at this point in the history
Related to #948
  • Loading branch information
bobeff committed Dec 21, 2021
1 parent 81a1b62 commit 985dee3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/nimble.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ proc saveLinkFile(pkgInfo: PackageInfo, options: Options) =

pkgLinkDir.createDir
writeFile(pkgLinkFilePath, pkgLinkFileContent)
displaySuccess(&"Package link file saved to \"{pkgLinkFilePath}\".")
displaySuccess(pkgLinkFileSavedMsg(pkgLinkFilePath))

proc developFromDir(pkgInfo: PackageInfo, options: var Options) =
assert options.action.typ == actionDevelop,
Expand Down
3 changes: 3 additions & 0 deletions src/nimblepkg/displaymessages.nim
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,6 @@ proc pkgAlreadyExistsInTheCacheMsg*(pkgInfo: PackageInfo): string =
proc skipDownloadingInAlreadyExistingDirectoryMsg*(dir, name: string): string =
&"The download directory \"{dir}\" already exists.\n" &
&"Skipping the download of \"{name}\"."

proc pkgLinkFileSavedMsg*(path: string): string =
&"Package link file \"{path}\" is saved."
22 changes: 21 additions & 1 deletion tests/tdevelopfeature.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import unittest, os, strutils, strformat, json, sets
import testscommon, nimblepkg/displaymessages, nimblepkg/paths

from nimblepkg/common import cd
from nimblepkg/common import cd, getLinkFileName, getLinkFileDir
from nimblepkg/developfile import developFileName, pkgFoundMoreThanOnceMsg
from nimblepkg/version import newVersion, parseVersionRange
from nimblepkg/nimbledatafile import nimbleDataFileName, NimbleDataJsonKeys
Expand Down Expand Up @@ -81,6 +81,26 @@ suite "develop feature":
check lines.inLinesOrdered(pkgSetupInDevModeMsg(
pkgBName, installDir / pkgBName))

test "can develop global":
cdCleanDir installDir:
usePackageListFile &"../develop/{pkgListFileName}":
let (output, exitCode) = execNimble("develop", "--global", pkgAName)
check exitCode == QuitSuccess
var lines = output.processOutput
let linkFilePath = installDir / "links" / pkgAName.getLinkFileDir /
pkgAName.getLinkFileName
check lines.inLinesOrdered(pkgLinkFileSavedMsg(linkFilePath))
check lines.inLinesOrdered(pkgSetupInDevModeMsg(
pkgAName, installDir / pkgAName))
check linkFilePath.fileExists
let linkFileLines = linkFilePath.readFile.split('\n')
let lowerCasePkgAName = pkgAName.toLower
let expectedLinkPath = installDir / lowerCasePkgAName
let expectedLinkNimbleFilePath =
expectedLinkPath / lowerCasePkgAName & ".babel"
check linkFileLines[0] == expectedLinkNimbleFilePath
check linkFileLines[1] == expectedLinkPath

test "cannot remove package with develop reverse dependency":
cdCleanDir installDir:
usePackageListFile &"../develop/{pkgListFileName}":
Expand Down

0 comments on commit 985dee3

Please sign in to comment.