Skip to content

Commit cea7631

Browse files
authored
Adds "should be able to install a special version" (#1413)
* Adds "should be able to install a special version" * Removes unused import
1 parent 6a2486b commit cea7631

File tree

5 files changed

+79
-1
lines changed

5 files changed

+79
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Package
2+
3+
version = "0.1.0"
4+
author = "jmgomez"
5+
description = "A new awesome nimble package"
6+
license = "MIT"
7+
srcDir = "src"
8+
9+
10+
# Dependencies
11+
12+
requires "nim"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is just an example to get you started. A typical library package
2+
# exports the main API in this file. Note that you cannot rename this file
3+
# but you can remove it if you wish.
4+
5+
proc add*(x, y: int): int =
6+
## Adds two numbers together.
7+
return x + y
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This is just an example to get you started. Users of your library will
2+
# import this file by writing ``import gitversions/submodule``. Feel free to rename or
3+
# remove this file altogether. You may create additional modules alongside
4+
# this file as required.
5+
6+
type
7+
Submodule* = object
8+
name*: string
9+
10+
proc initSubmodule*(): Submodule =
11+
## Initialises a new ``Submodule`` object.
12+
Submodule(name: "Anonymous")

tests/gitversions/tests/test1.nim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This is just an example to get you started. You may wish to put all of your
2+
# tests into a single file, or separate them into multiple `test1`, `test2`
3+
# etc. files (better names are recommended, just make sure the name starts with
4+
# the letter 't').
5+
#
6+
# To run these tests, simply execute `nimble test`.
7+
8+
import unittest
9+
10+
import gitversions
11+
test "can add":
12+
check add(5, 5) == 10

tests/trequireflag.nim

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{.used.}
2-
import unittest, os#, strformat, osproc
2+
import unittest, os, strutils# strformat, osproc
33
import testscommon
44
from nimblepkg/common import cd
55

@@ -35,3 +35,38 @@ suite "requires flag":
3535
# check output.processOutput.inLines("Installing [email protected]")
3636

3737

38+
39+
test "should be able to install a special version":
40+
#[
41+
Test it can install a dep with the following variations:
42+
- https://github.com/status-im/nim-json-serialization.git#lean-arrays
43+
- https://github.com/status-im/nim-json-serialization.git#4cd31594f868a3d3cb81ec9d5f479efbe2466ebd
44+
- json_serialization#lean-arrays
45+
- json_serialization#4cd31594f868a3d3cb81ec9d5f479efbe2466ebd
46+
]#
47+
let requires = [
48+
"https://github.com/status-im/nim-json-serialization.git#nimble_test_dont_delete",
49+
"https://github.com/status-im/nim-json-serialization.git#e45fe67d71f006f15a32f90a5a56a4775982d951",
50+
"json_serialization#nimble_test_dont_delete",
51+
"json_serialization#e45fe67d71f006f15a32f90a5a56a4775982d951",
52+
"json_serialization == 0.2.9"
53+
]
54+
cleanDir(installDir)
55+
cd "gitversions":
56+
for req in requires:
57+
let require = "--requires: " & req
58+
let isVersion = req.contains("==")
59+
# echo "Trying require: ", req
60+
let (output, exitCode) = execNimble("install", require)
61+
let pkgDir = getPackageDir(pkgsDir, "json_serialization-0.2.9")
62+
check exitCode == QuitSuccess
63+
let nimbleTestDontDeleteFile = pkgDir / "json_serialization" / "nimble.test.nim"
64+
# echo "Nimble test dont delete file: ", nimbleTestDontDeleteFile
65+
if isVersion:
66+
check output.processOutput.inLines("Success: json_serialization installed successfully.")
67+
check not fileExists(nimbleTestDontDeleteFile)
68+
else:
69+
check output.processOutput.inLines("Success: json_serialization installed successfully.")
70+
check fileExists(nimbleTestDontDeleteFile)
71+
cleanDir(pkgDir) #Resets the package dir for each require
72+

0 commit comments

Comments
 (0)