Skip to content

Commit f991b94

Browse files
authored
Merge branch 'nim-lang:master' into path
2 parents 7fcddc7 + 20e2e4d commit f991b94

File tree

8 files changed

+72
-4
lines changed

8 files changed

+72
-4
lines changed

src/nimble.nim

+13
Original file line numberDiff line numberDiff line change
@@ -1802,13 +1802,26 @@ proc validateDevelopDependenciesVersionRanges(dependentPkg: PackageInfo,
18021802
if errors.len > 0:
18031803
raise nimbleError(invalidDevelopDependenciesVersionsMsg(errors))
18041804

1805+
proc validateParsedDependencies(pkgInfo: PackageInfo, options: Options) =
1806+
displayInfo(&"Validating dependencies for pkgInfo {pkgInfo.infoKind}", HighPriority)
1807+
var options = options
1808+
options.useDeclarativeParser = true
1809+
let declDeps = pkgInfo.toRequiresInfo(options).requires
1810+
1811+
options.useDeclarativeParser = false
1812+
let vmDeps = pkgInfo.toFullInfo(options).requires
1813+
1814+
if declDeps != vmDeps:
1815+
raise nimbleError(&"Parsed declarative and VM dependencies are not the same: {declDeps} != {vmDeps}")
1816+
18051817
proc check(options: Options) =
18061818
try:
18071819
let currentDir = getCurrentDir()
18081820
let pkgInfo = getPkgInfo(currentDir, options, true)
18091821
validateDevelopFile(pkgInfo, options)
18101822
let dependencies = pkgInfo.processAllDependencies(options).toSeq
18111823
validateDevelopDependenciesVersionRanges(pkgInfo, dependencies, options)
1824+
validateParsedDependencies(pkgInfo, options)
18121825
displaySuccess(&"The package \"{pkgInfo.basicInfo.name}\" is valid.")
18131826
except CatchableError as error:
18141827
displayError(error)

src/nimblepkg/downloadnim.nim

+6-4
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ proc getGccArch*(options: Options): int =
123123
return when defined(windows): 32 else: 64
124124

125125
proc isRosetta*(): bool =
126-
let res = gorgeEx("sysctl -in sysctl.proc_translated")
127-
if res.exitCode == 0:
128-
return res.output.strip() == "1"
129-
return false
126+
try:
127+
let res = execCmdEx("sysctl -in sysctl.proc_translated")
128+
if res.exitCode == 0:
129+
return res.output.strip() == "1"
130+
except CatchableError:
131+
return false
130132

131133
proc getNightliesUrl*(parsedContents: JsonNode, arch: int): (string, string) =
132134
let os =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
requires "results"
12+
if true:
13+
requires "stew"
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
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 inconsistentdeps/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")
+12
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 inconsistentdeps
11+
test "can add":
12+
check add(5, 5) == 10

tests/tcheckcommand.nim

+6
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ suite "check command":
3838
check exitCode == QuitSuccess
3939
check outp.processOutput.inLines("success")
4040
check outp.processOutput.inLines("\"x\" is valid")
41+
42+
test "should fail if parsers parse different dependencies":
43+
cd "inconsistentdeps":
44+
let (outp, exitCode) = execNimble("check")
45+
check exitCode == QuitFailure
46+
check outp.processOutput.inLines("Parsed declarative and VM dependencies are not the same: @[results@any version] != @[results@any version, stew@any version]")

tests/tdeclarativeparser.nim

+3
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ suite "Declarative parsing":
7070
let (output, exitCode) = execNimble("--parser:declarative", "install", "nimlangserver")
7171
echo output
7272
check exitCode == QuitSuccess
73+
74+
75+
# suite "Declarative parser features":

0 commit comments

Comments
 (0)