Skip to content

Commit

Permalink
Remove ospaths, fix tests for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
genotrance committed Apr 16, 2019
1 parent 74201bc commit 85f3865
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
os:
- linux
- osx
dist: trusty

language: c
Expand Down
8 changes: 5 additions & 3 deletions nimble.nimble
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import ospaths
template thisModuleFile: string = instantiationInfo(fullPaths = true).filename
import strutils

when fileExists(thisModuleFile.parentDir / "src/nimblepkg/common.nim"):
const
parentDir = currentSourcePath.rsplit(seps={'/', '\\', ':'}, maxsplit=1)[0]

when fileExists(parentDir & "/src/nimblepkg/common.nim"):
# In the git repository the Nimble sources are in a ``src`` directory.
import src/nimblepkg/common
else:
Expand Down
33 changes: 23 additions & 10 deletions tests/tester.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ proc execNimble(args: varargs[string]): tuple[output: string, exitCode: int] =
quotedArgs.add("--nimbleDir:" & installDir)
quotedArgs = quotedArgs.map((x: string) => ("\"" & x & "\""))

let path = getCurrentDir().parentDir() / "src"
let path {.used.} = getCurrentDir().parentDir() / "src"

var cmd = "PATH=" & path & ":$PATH " & quotedArgs.join(" ")
var cmd =
when not defined(windows):
"PATH=" & path & ":$PATH " & quotedArgs.join(" ")
else:
quotedArgs.join(" ")
when defined(macosx):
# TODO: Yeah, this is really specific to my machine but for my own sanity...
cmd = "DYLD_LIBRARY_PATH=/usr/local/opt/openssl@1.1/lib " & cmd
Expand Down Expand Up @@ -213,7 +217,7 @@ test "can refresh with local package list":
[PackageList]
name = "local"
path = "$1"
""".unindent % (getCurrentDir() / "issue368" / "packages.json"))
""".unindent % (getCurrentDir() / "issue368" / "packages.json").replace("\\", "\\\\"))
let (output, exitCode) = execNimble(["refresh", "--verbose"])
let lines = output.strip.processOutput()
check inLines(lines, "config file at")
Expand Down Expand Up @@ -258,9 +262,9 @@ suite "nimscript":
check exitCode == QuitSuccess
let lines = output.strip.processOutput()
check lines[0].startsWith("Before PkgDir:")
check lines[0].endsWith("tests/nimscript")
check lines[0].endsWith("tests" / "nimscript")
check lines[^1].startsWith("After PkgDir:")
check lines[^1].endsWith("tests/nimbleDir/pkgs/nimscript-0.1.0")
check lines[^1].endsWith("tests" / "nimbleDir" / "pkgs" / "nimscript-0.1.0")

test "can execute nimscript tasks":
cd "nimscript":
Expand Down Expand Up @@ -412,6 +416,9 @@ test "issue #349":
]

proc checkName(name: string) =
when defined(windows):
if name.toLowerAscii() in @["con", "nul"]:
return
let (outp, code) = execNimble("init", "-y", name)
let msg = outp.strip.processOutput()
check code == QuitFailure
Expand Down Expand Up @@ -526,25 +533,31 @@ suite "can handle two binary versions":
cd "binaryPackage/v2":
check execNimble("install", "-y").exitCode == QuitSuccess

var
cmd = installDir / "bin" / "binaryPackage"

when defined(windows):
cmd = "cmd /c " & cmd & ".cmd"

test "can execute v2":
let (output, exitCode) =
execCmdEx(installDir / "bin" / "binaryPackage".addFileExt(ExeExt))
execCmdEx(cmd)
check exitCode == QuitSuccess
check output.strip() == "v2"

test "can update symlink to earlier version after removal":
check execNimble("remove", "binaryPackage@2.0", "-y").exitCode==QuitSuccess

let (output, exitCode) =
execCmdEx(installDir / "bin" / "binaryPackage".addFileExt(ExeExt))
execCmdEx(cmd)
check exitCode == QuitSuccess
check output.strip() == "v1"

test "can keep symlink version after earlier version removal":
check execNimble("remove", "binaryPackage@1.0", "-y").exitCode==QuitSuccess

let (output, exitCode) =
execCmdEx(installDir / "bin" / "binaryPackage".addFileExt(ExeExt))
execCmdEx(cmd)
check exitCode == QuitSuccess
check output.strip() == "v2"

Expand Down Expand Up @@ -678,9 +691,9 @@ suite "path command":
test "can get correct path for srcDir (#531)":
check execNimble("uninstall", "srcdirtest", "-y").exitCode == QuitSuccess
cd "develop/srcdirtest":
let (output, exitCode) = execNimble("install", "-y")
let (_, exitCode) = execNimble("install", "-y")
check exitCode == QuitSuccess
let (output, exitCode) = execNimble("path", "srcdirtest")
let (output, _) = execNimble("path", "srcdirtest")
check output.strip() == installDir / "pkgs" / "srcdirtest-1.0"

suite "test command":
Expand Down

0 comments on commit 85f3865

Please sign in to comment.