Skip to content

Commit c451f72

Browse files
authored
config.nims empty line (#1370)
* green: config file should end with a newline It also uncomments tests that shouldnt be commented * adds extra line * Remove warnings
1 parent 7b96e6d commit c451f72

File tree

4 files changed

+115
-109
lines changed

4 files changed

+115
-109
lines changed

config.nims

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ switch("define", "ssl")
66
switch("path", "vendor" / "zippy" / "src")
77
switch("path", "vendor" / "sat" / "src")
88
switch("path", "vendor" / "checksums" / "src")
9-
switch("define", "zippyNoSimd")
9+
switch("define", "zippyNoSimd")
10+

src/nimblepkg/publish.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ proc createTag*(tag: string, commit: Sha1Hash, message, repoDir, nimbleFile: str
282282
of DownloadMethod.hg:
283283
assert false, "hg not supported"
284284

285-
proc findVersions(commits: seq[(Sha1Hash, string)], projdir, nimbleFile: string, downloadMethod: DownloadMethod, options: Options) =
285+
proc findVersions*(commits: seq[(Sha1Hash, string)], projdir, nimbleFile: string, downloadMethod: DownloadMethod, options: Options) =
286286
## parse the versions
287287
var
288288
versions: HashSet[Version]

tests/tmisctests.nim

+111-106
Original file line numberDiff line numberDiff line change
@@ -3,116 +3,116 @@
33

44
{.used.}
55

6-
import unittest, os, osproc, strutils, strformat
6+
import unittest, os, osproc, strutils, strformat, sequtils
77
import testscommon
88
from nimblepkg/common import cd, nimbleVersion, nimblePackagesDirName
99

1010
suite "misc tests":
11-
# test "depsOnly + flag order test":
12-
# let (output, exitCode) = execNimbleYes("--depsOnly", "install", pkgBin2Url)
13-
# check(not output.contains("Success: packagebin2 installed successfully."))
14-
# check exitCode == QuitSuccess
15-
16-
# test "caching of nims and ini detects changes":
17-
# cd "caching":
18-
# var (output, exitCode) = execNimble("dump")
19-
# check output.contains("0.1.0")
20-
# let
21-
# nfile = "caching.nimble"
22-
# writeFile(nfile, readFile(nfile).replace("0.1.0", "0.2.0"))
23-
# (output, exitCode) = execNimble("dump")
24-
# check output.contains("0.2.0")
25-
# writeFile(nfile, readFile(nfile).replace("0.2.0", "0.1.0"))
26-
27-
# # Verify cached .nims runs project dir specific commands correctly
28-
# (output, exitCode) = execNimble("testpath")
29-
# check exitCode == QuitSuccess
30-
# check output.contains("imported")
31-
# check output.contains("tests/caching")
32-
# check output.contains("copied")
33-
# check output.contains("removed")
34-
35-
# test "tasks can be called recursively":
36-
# cd "recursive":
37-
# check execNimble("recurse").exitCode == QuitSuccess
38-
39-
# test "picks #head when looking for packages":
40-
# removeDir installDir
41-
# cd "versionClashes" / "aporiaScenario":
42-
# let (output, exitCode) = execNimbleYes("install", "--verbose")
43-
# checkpoint output
44-
# check exitCode == QuitSuccess
45-
# check execNimbleYes("remove", "aporiascenario").exitCode == QuitSuccess
46-
# check execNimbleYes("remove", "packagea").exitCode == QuitSuccess
47-
48-
# test "pass options to the compiler with `nimble install`":
49-
# cd "passNimFlags":
50-
# let (_, exitCode) = execNimble("install", "--passNim:-d:passNimIsWorking")
51-
# check exitCode == QuitSuccess
52-
53-
# test "install with --noRebuild flag":
54-
# cd "run":
55-
# check execNimbleYes("build").exitCode == QuitSuccess
56-
57-
# let (output, exitCode) = execNimbleYes("install", "--noRebuild")
58-
# check exitCode == QuitSuccess
59-
# check output.contains("Skipping")
60-
61-
# test "NimbleVersion is defined":
62-
# cd "nimbleVersionDefine":
63-
# let (output, exitCode) = execNimble("c", "-r", "src/nimbleVersionDefine.nim")
64-
# check output.contains("0.1.0")
65-
# check exitCode == QuitSuccess
66-
67-
# let (output2, exitCode2) = execNimble("run", "nimbleVersionDefine")
68-
# check output2.contains("0.1.0")
69-
# check exitCode2 == QuitSuccess
70-
71-
# test "compilation without warnings":
72-
# const buildDir = "./buildDir/"
73-
# const filesToBuild = [
74-
# "../src/nimble.nim",
75-
# #"../src/nimblepkg/nimscriptapi.nim",
76-
# "./tester.nim",
77-
# ]
78-
79-
# proc execBuild(fileName: string): tuple[output: string, exitCode: int] =
80-
# result = execCmdEx(
81-
# &"nim c -o:{buildDir/fileName.splitFile.name} {fileName}")
82-
83-
# proc checkOutput(output: string): uint =
84-
# const warningsToCheck = [
85-
# "[UnusedImport]",
86-
# "[DuplicateModuleImport]",
87-
# # "[Deprecated]", # todo fixme
88-
# "[XDeclaredButNotUsed]",
89-
# "[Spacing]",
90-
# "[ProveInit]",
91-
# # "[UnsafeDefault]", # todo fixme
92-
# ]
93-
94-
# for line in output.splitLines():
95-
# for warning in warningsToCheck:
96-
# if line.find(warning) != stringNotFound:
97-
# once: checkpoint("Detected warnings:")
98-
# checkpoint(line)
99-
# inc(result)
100-
101-
# removeDir(buildDir)
102-
103-
# var linesWithWarningsCount: uint = 0
104-
# for file in filesToBuild:
105-
# let (output, exitCode) = execBuild(file)
106-
# check exitCode == QuitSuccess
107-
# linesWithWarningsCount += checkOutput(output)
108-
# check linesWithWarningsCount == 0
109-
110-
# test "can update":
111-
# check execNimble("update").exitCode == QuitSuccess
112-
113-
# test "can list":
114-
# check execNimble("list").exitCode == QuitSuccess
115-
# check execNimble("list", "-i").exitCode == QuitSuccess
11+
test "depsOnly + flag order test":
12+
let (output, exitCode) = execNimbleYes("--depsOnly", "install", pkgBin2Url)
13+
check(not output.contains("Success: packagebin2 installed successfully."))
14+
check exitCode == QuitSuccess
15+
16+
test "caching of nims and ini detects changes":
17+
cd "caching":
18+
var (output, exitCode) = execNimble("dump")
19+
check output.contains("0.1.0")
20+
let
21+
nfile = "caching.nimble"
22+
writeFile(nfile, readFile(nfile).replace("0.1.0", "0.2.0"))
23+
(output, exitCode) = execNimble("dump")
24+
check output.contains("0.2.0")
25+
writeFile(nfile, readFile(nfile).replace("0.2.0", "0.1.0"))
26+
27+
# Verify cached .nims runs project dir specific commands correctly
28+
(output, exitCode) = execNimble("testpath")
29+
check exitCode == QuitSuccess
30+
check output.contains("imported")
31+
check output.contains("tests/caching")
32+
check output.contains("copied")
33+
check output.contains("removed")
34+
35+
test "tasks can be called recursively":
36+
cd "recursive":
37+
check execNimble("recurse").exitCode == QuitSuccess
38+
39+
test "picks #head when looking for packages":
40+
removeDir installDir
41+
cd "versionClashes" / "aporiaScenario":
42+
let (output, exitCode) = execNimbleYes("install", "--verbose")
43+
checkpoint output
44+
check exitCode == QuitSuccess
45+
check execNimbleYes("remove", "aporiascenario").exitCode == QuitSuccess
46+
check execNimbleYes("remove", "packagea").exitCode == QuitSuccess
47+
48+
test "pass options to the compiler with `nimble install`":
49+
cd "passNimFlags":
50+
let (_, exitCode) = execNimble("install", "--passNim:-d:passNimIsWorking")
51+
check exitCode == QuitSuccess
52+
53+
test "install with --noRebuild flag":
54+
cd "run":
55+
check execNimbleYes("build").exitCode == QuitSuccess
56+
57+
let (output, exitCode) = execNimbleYes("install", "--noRebuild")
58+
check exitCode == QuitSuccess
59+
check output.contains("Skipping")
60+
61+
test "NimbleVersion is defined":
62+
cd "nimbleVersionDefine":
63+
let (output, exitCode) = execNimble("c", "-r", "src/nimbleVersionDefine.nim")
64+
check output.contains("0.1.0")
65+
check exitCode == QuitSuccess
66+
67+
let (output2, exitCode2) = execNimble("run", "nimbleVersionDefine")
68+
check output2.contains("0.1.0")
69+
check exitCode2 == QuitSuccess
70+
71+
test "compilation without warnings":
72+
const buildDir = "./buildDir/"
73+
const filesToBuild = [
74+
"../src/nimble.nim",
75+
#"../src/nimblepkg/nimscriptapi.nim",
76+
"./tester.nim",
77+
]
78+
79+
proc execBuild(fileName: string): tuple[output: string, exitCode: int] =
80+
result = execCmdEx(
81+
&"nim c -o:{buildDir/fileName.splitFile.name} {fileName}")
82+
83+
proc checkOutput(output: string): uint =
84+
const warningsToCheck = [
85+
"[UnusedImport]",
86+
"[DuplicateModuleImport]",
87+
# "[Deprecated]", # todo fixme
88+
"[XDeclaredButNotUsed]",
89+
"[Spacing]",
90+
"[ProveInit]",
91+
# "[UnsafeDefault]", # todo fixme
92+
]
93+
94+
for line in output.splitLines():
95+
for warning in warningsToCheck:
96+
if line.find(warning) != stringNotFound:
97+
once: checkpoint("Detected warnings:")
98+
checkpoint(line)
99+
inc(result)
100+
101+
removeDir(buildDir)
102+
103+
var linesWithWarningsCount: uint = 0
104+
for file in filesToBuild:
105+
let (output, exitCode) = execBuild(file)
106+
check exitCode == QuitSuccess
107+
linesWithWarningsCount += checkOutput(output)
108+
check linesWithWarningsCount == 0
109+
110+
test "can update":
111+
check execNimble("update").exitCode == QuitSuccess
112+
113+
test "can list":
114+
check execNimble("list").exitCode == QuitSuccess
115+
check execNimble("list", "-i").exitCode == QuitSuccess
116116

117117
test "should not install submodules when --ignoreSubmodules flag is on":
118118
let (_, exitCode) = execNimble("--ignoreSubmodules", "install", "https://github.com/jmgomez/submodule_package")
@@ -121,3 +121,8 @@ suite "misc tests":
121121
test "should install submodules when --ignoreSubmodules flag is off":
122122
let (_, exitCode) = execNimble("install", "https://github.com/jmgomez/submodule_package")
123123
check exitCode == QuitSuccess
124+
test "config file should end with a newline":
125+
let configFile = readFile("../config.nims")
126+
let content = configFile.splitLines.toSeq()
127+
check content[^2].strip() == ""
128+
check content[^1].strip() == ""

tests/trequireflag.nim

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

0 commit comments

Comments
 (0)