Merge branch 'master' into native-pkg-support
This commit is contained in:
commit
6368ccb0df
28 changed files with 698 additions and 194 deletions
1
tests/issue289/issue289.nim
Normal file
1
tests/issue289/issue289.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
echo 42
|
||||
14
tests/issue289/issue289.nimble
Normal file
14
tests/issue289/issue289.nimble
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Package reproducing issues depending on #head and concrete version of the same package."
|
||||
license = "MIT"
|
||||
|
||||
bin = @["issue289"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.15.0", "https://github.com/nimble-test/packagea.git 0.6.0"
|
||||
requires "https://github.com/nimble-test/packagea.git#head"
|
||||
|
||||
1
tests/packageStructure/a/a.nim
Normal file
1
tests/packageStructure/a/a.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
11
tests/packageStructure/a/a.nimble
Normal file
11
tests/packageStructure/a/a.nimble
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Correctly structured package A"
|
||||
license = "MIT"
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.15.0"
|
||||
|
||||
1
tests/packageStructure/b/b.nim
Normal file
1
tests/packageStructure/b/b.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
11
tests/packageStructure/b/b.nimble
Normal file
11
tests/packageStructure/b/b.nimble
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Correctly structured package B"
|
||||
license = "MIT"
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.15.0"
|
||||
|
||||
1
tests/packageStructure/b/b/foobar.nim
Normal file
1
tests/packageStructure/b/b/foobar.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
tests/packageStructure/c/c.nim
Normal file
1
tests/packageStructure/c/c.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
13
tests/packageStructure/c/c.nimble
Normal file
13
tests/packageStructure/c/c.nimble
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Correctly structured package C"
|
||||
license = "MIT"
|
||||
|
||||
bin = @["c"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.15.0"
|
||||
|
||||
1
tests/packageStructure/c/cpkg/foobar.nim
Normal file
1
tests/packageStructure/c/cpkg/foobar.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
0
tests/packageStructure/x/incorrect/foobar.nim
Normal file
0
tests/packageStructure/x/incorrect/foobar.nim
Normal file
11
tests/packageStructure/x/x.nimble
Normal file
11
tests/packageStructure/x/x.nimble
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Incorrectly structured package X."
|
||||
license = "MIT"
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.15.0"
|
||||
|
||||
0
tests/packageStructure/y/y.nim
Normal file
0
tests/packageStructure/y/y.nim
Normal file
13
tests/packageStructure/y/y.nimble
Normal file
13
tests/packageStructure/y/y.nimble
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Incorrectly structured package Y"
|
||||
license = "MIT"
|
||||
|
||||
bin = @["y"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.15.0"
|
||||
|
||||
1
tests/packageStructure/y/yWrong/foobar.nim
Normal file
1
tests/packageStructure/y/yWrong/foobar.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
0
tests/packageStructure/z/incorrect.nim
Normal file
0
tests/packageStructure/z/incorrect.nim
Normal file
11
tests/packageStructure/z/z.nimble
Normal file
11
tests/packageStructure/z/z.nimble
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Dominik Picheta"
|
||||
description = "Incorrect package structure Z."
|
||||
license = "MIT"
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.15.0"
|
||||
|
||||
4
tests/testdump/testdump.nimble
Normal file
4
tests/testdump/testdump.nimble
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
description = "Test package for dump command"
|
||||
version = "0.1.0"
|
||||
author = "nigredo-tori"
|
||||
license = "BSD"
|
||||
|
|
@ -2,6 +2,10 @@
|
|||
# BSD License. Look at license.txt for more info.
|
||||
import osproc, streams, unittest, strutils, os, sequtils, future
|
||||
|
||||
# TODO: Each test should start off with a clean slate. Currently installed
|
||||
# packages are shared between each test which causes a multitude of issues
|
||||
# and is really fragile.
|
||||
|
||||
var rootDir = getCurrentDir().parentDir()
|
||||
var nimblePath = rootDir / "src" / addFileExt("nimble", ExeExt)
|
||||
var installDir = rootDir / "tests" / "nimbleDir"
|
||||
|
|
@ -37,10 +41,55 @@ proc inLines(lines: seq[string], line: string): bool =
|
|||
for i in lines:
|
||||
if line.normalize in i.normalize: return true
|
||||
|
||||
test "can build with #head and versioned package (#289)":
|
||||
cd "issue289":
|
||||
check execNimble(["install", "-y"]).exitCode == QuitSuccess
|
||||
|
||||
check execNimble(["uninstall", "issue289", "-y"]).exitCode == QuitSuccess
|
||||
check execNimble(["uninstall", "packagea", "-y"]).exitCode == QuitSuccess
|
||||
|
||||
test "can validate package structure (#144)":
|
||||
# Test that no warnings are produced for correctly structured packages.
|
||||
for package in ["a", "b", "c"]:
|
||||
cd "packageStructure/" & package:
|
||||
let (output, exitCode) = execNimble(["install", "-y"])
|
||||
check exitCode == QuitSuccess
|
||||
let lines = output.strip.splitLines()
|
||||
check(not inLines(lines, "warning"))
|
||||
|
||||
# Test that warnings are produced for the incorrectly structured packages.
|
||||
for package in ["x", "y", "z"]:
|
||||
cd "packageStructure/" & package:
|
||||
let (output, exitCode) = execNimble(["install", "-y"])
|
||||
check exitCode == QuitSuccess
|
||||
let lines = output.strip.splitLines()
|
||||
case package
|
||||
of "x":
|
||||
check inLines(lines, "File 'foobar.nim' inside package 'x' is outside" &
|
||||
" of the permitted namespace, should be inside a" &
|
||||
" directory named 'x' but is in a directory named" &
|
||||
" 'incorrect' instead.")
|
||||
of "y":
|
||||
check inLines(lines, "File 'foobar.nim' inside package 'y' is outside" &
|
||||
" of the permitted namespace, should be inside a" &
|
||||
" directory named 'ypkg' but is in a directory" &
|
||||
" named 'yWrong' instead.")
|
||||
of "z":
|
||||
check inLines(lines, "File inside package 'z' is outside of permitted" &
|
||||
" namespace, should be named 'z.nim' but was" &
|
||||
" named 'incorrect.nim' instead.")
|
||||
else:
|
||||
assert false
|
||||
|
||||
test "issue 129 (installing commit hash)":
|
||||
let arguments = @["install", "-y",
|
||||
"https://github.com/nimble-test/packagea.git@#1f9cb289c89"]
|
||||
check execNimble(arguments).exitCode == QuitSuccess
|
||||
# Verify that it was installed correctly.
|
||||
check dirExists(installDir / "pkgs" / "PackageA-#1f9cb289c89")
|
||||
# Remove it so that it doesn't interfere with the uninstall tests.
|
||||
check execNimble("uninstall", "-y", "packagea@#1f9cb289c89").exitCode ==
|
||||
QuitSuccess
|
||||
|
||||
test "issue 113 (uninstallation problems)":
|
||||
cd "issue113/c":
|
||||
|
|
@ -247,6 +296,34 @@ test "can uninstall":
|
|||
|
||||
check execNimble("uninstall", "-y", "PackageA@0.2", "issue27b").exitCode ==
|
||||
QuitSuccess
|
||||
check(not dirExists(getHomeDir() / ".nimble" / "pkgs" / "PackageA-0.2.0"))
|
||||
check(not dirExists(installDir / "pkgs" / "PackageA-0.2.0"))
|
||||
|
||||
check execNimble("uninstall", "-y", "nimscript").exitCode == QuitSuccess
|
||||
|
||||
test "can dump for current project":
|
||||
cd "testdump":
|
||||
let (outp, exitCode) = execNimble("dump")
|
||||
check: exitCode == 0
|
||||
check: outp.processOutput.inLines("desc: \"Test package for dump command\"")
|
||||
|
||||
test "can dump for project directory":
|
||||
let (outp, exitCode) = execNimble("dump", "testdump")
|
||||
check: exitCode == 0
|
||||
check: outp.processOutput.inLines("desc: \"Test package for dump command\"")
|
||||
|
||||
test "can dump for project file":
|
||||
let (outp, exitCode) = execNimble("dump", "testdump" / "testdump.nimble")
|
||||
check: exitCode == 0
|
||||
check: outp.processOutput.inLines("desc: \"Test package for dump command\"")
|
||||
|
||||
test "can dump for installed package":
|
||||
cd "testdump":
|
||||
check: execNimble("install", "-y").exitCode == 0
|
||||
defer:
|
||||
discard execNimble("remove", "-y", "testdump")
|
||||
|
||||
# Otherwise we might find subdirectory instead
|
||||
cd "..":
|
||||
let (outp, exitCode) = execNimble("dump", "testdump")
|
||||
check: exitCode == 0
|
||||
check: outp.processOutput.inLines("desc: \"Test package for dump command\"")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue