add -d:nimStrictMode in CI to keep code from regressing; fixes ConvFromXtoItselfNotNeeded, UnusedImport notes (#16764)
This commit is contained in:
parent
35e14998ec
commit
31bb67a309
20 changed files with 43 additions and 23 deletions
|
|
@ -201,6 +201,8 @@ provided by the operating system.
|
||||||
in both rst2html (as before) as well as common tools rendering rst directly (e.g. github), by
|
in both rst2html (as before) as well as common tools rendering rst directly (e.g. github), by
|
||||||
adding: `default-role:: code` directive inside the rst file, which is now handled by rst2html.
|
adding: `default-role:: code` directive inside the rst file, which is now handled by rst2html.
|
||||||
|
|
||||||
|
- Added `-d:nimStrictMode` in CI in several places to ensure code doesn't have certain hints/warnings
|
||||||
|
|
||||||
## Tool changes
|
## Tool changes
|
||||||
|
|
||||||
- The rst parser now supports markdown table syntax.
|
- The rst parser now supports markdown table syntax.
|
||||||
|
|
|
||||||
|
|
@ -126,4 +126,5 @@ proc initDefines*(symbols: StringTableRef) =
|
||||||
defineSymbol("nimHasCastPragmaBlocks")
|
defineSymbol("nimHasCastPragmaBlocks")
|
||||||
defineSymbol("nimHasDeclaredLocs")
|
defineSymbol("nimHasDeclaredLocs")
|
||||||
defineSymbol("nimHasJsBigIntBackend")
|
defineSymbol("nimHasJsBigIntBackend")
|
||||||
|
defineSymbol("nimHasWarningAsError")
|
||||||
defineSymbol("nimHasHintAsError")
|
defineSymbol("nimHasHintAsError")
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,6 @@
|
||||||
import ast, types, intsets, lineinfos, renderer
|
import ast, types, intsets, lineinfos, renderer
|
||||||
import std/private/asciitables
|
import std/private/asciitables
|
||||||
|
|
||||||
from patterns import sameTrees
|
|
||||||
|
|
||||||
type
|
type
|
||||||
InstrKind* = enum
|
InstrKind* = enum
|
||||||
goto, fork, def, use
|
goto, fork, def, use
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,15 @@
|
||||||
|
|
||||||
cppDefine "errno"
|
cppDefine "errno"
|
||||||
cppDefine "unix"
|
cppDefine "unix"
|
||||||
|
|
||||||
|
when defined(nimStrictMode):
|
||||||
|
# xxx add more flags here, and use `-d:nimStrictMode` in more contexts in CI.
|
||||||
|
|
||||||
|
# pending bug #14246, enable this:
|
||||||
|
# when defined(nimHasWarningAsError):
|
||||||
|
# switch("warningAsError", "UnusedImport")
|
||||||
|
|
||||||
|
when defined(nimHasHintAsError):
|
||||||
|
# switch("hint", "ConvFromXtoItselfNotNeeded")
|
||||||
|
switch("hintAsError", "ConvFromXtoItselfNotNeeded")
|
||||||
|
# future work: XDeclaredButNotUsed
|
||||||
|
|
|
||||||
4
koch.nim
4
koch.nim
|
|
@ -526,7 +526,7 @@ proc runCI(cmd: string) =
|
||||||
echo "runCI: ", cmd
|
echo "runCI: ", cmd
|
||||||
echo hostInfo()
|
echo hostInfo()
|
||||||
# boot without -d:nimHasLibFFI to make sure this still works
|
# boot without -d:nimHasLibFFI to make sure this still works
|
||||||
kochExecFold("Boot in release mode", "boot -d:release")
|
kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode")
|
||||||
|
|
||||||
## build nimble early on to enable remainder to depend on it if needed
|
## build nimble early on to enable remainder to depend on it if needed
|
||||||
kochExecFold("Build Nimble", "nimble")
|
kochExecFold("Build Nimble", "nimble")
|
||||||
|
|
@ -549,7 +549,7 @@ proc runCI(cmd: string) =
|
||||||
#[
|
#[
|
||||||
BUG: with initOptParser, `--batch:'' all` interprets `all` as the argument of --batch
|
BUG: with initOptParser, `--batch:'' all` interprets `all` as the argument of --batch
|
||||||
]#
|
]#
|
||||||
execFold("Run tester", "nim c -r -d:nimCoroutines --putenv:NIM_TESTAMENT_REMOTE_NETWORKING:1 testament/testament --batch:$1 all -d:nimCoroutines" % ["NIM_TESTAMENT_BATCH".getEnv("_")])
|
execFold("Run tester", "nim c -r -d:nimCoroutines --putenv:NIM_TESTAMENT_REMOTE_NETWORKING:1 -d:nimStrictMode testament/testament --batch:$1 all -d:nimCoroutines" % ["NIM_TESTAMENT_BATCH".getEnv("_")])
|
||||||
|
|
||||||
block CT_FFI:
|
block CT_FFI:
|
||||||
when defined(posix): # windows can be handled in future PR's
|
when defined(posix): # windows can be handled in future PR's
|
||||||
|
|
|
||||||
|
|
@ -1279,7 +1279,7 @@ else:
|
||||||
var newList = newSeqOfCap[Callback](newLength)
|
var newList = newSeqOfCap[Callback](newLength)
|
||||||
|
|
||||||
var cb = curList[0]
|
var cb = curList[0]
|
||||||
if not cb(fd.AsyncFD):
|
if not cb(fd):
|
||||||
newList.add(cb)
|
newList.add(cb)
|
||||||
|
|
||||||
withData(p.selector, fd.int, adata) do:
|
withData(p.selector, fd.int, adata) do:
|
||||||
|
|
|
||||||
|
|
@ -364,7 +364,10 @@ proc read*[T](future: Future[T] | FutureVar[T]): T =
|
||||||
##
|
##
|
||||||
## If the result of the future is an error then that error will be raised.
|
## If the result of the future is an error then that error will be raised.
|
||||||
{.push hint[ConvFromXtoItselfNotNeeded]: off.}
|
{.push hint[ConvFromXtoItselfNotNeeded]: off.}
|
||||||
let fut = Future[T](future)
|
when future is Future[T]:
|
||||||
|
let fut = future
|
||||||
|
else:
|
||||||
|
let fut = Future[T](future)
|
||||||
{.pop.}
|
{.pop.}
|
||||||
if fut.finished:
|
if fut.finished:
|
||||||
if fut.error != nil:
|
if fut.error != nil:
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@ when defined(windows):
|
||||||
import winlean
|
import winlean
|
||||||
from os import absolutePath
|
from os import absolutePath
|
||||||
else:
|
else:
|
||||||
import os, osproc
|
import os
|
||||||
|
when not defined(osx):
|
||||||
|
import osproc
|
||||||
|
|
||||||
const osOpenCmd* =
|
const osOpenCmd* =
|
||||||
when defined(macos) or defined(macosx) or defined(windows): "open" else: "xdg-open" ## \
|
when defined(macos) or defined(macosx) or defined(windows): "open" else: "xdg-open" ## \
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ runnableExamples:
|
||||||
|
|
||||||
include "system/inclrtl"
|
include "system/inclrtl"
|
||||||
|
|
||||||
when not defined(windows):
|
when defined(linux):
|
||||||
import posix
|
import posix
|
||||||
|
|
||||||
when defined(freebsd) or defined(macosx):
|
when defined(freebsd) or defined(macosx):
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@
|
||||||
import std/private/since
|
import std/private/since
|
||||||
|
|
||||||
import nativesockets, os, strutils, times, sets, options, std/monotimes
|
import nativesockets, os, strutils, times, sets, options, std/monotimes
|
||||||
from ssl_certs import scanSSLCertificates
|
|
||||||
import ssl_config
|
import ssl_config
|
||||||
export nativesockets.Port, nativesockets.`$`, nativesockets.`==`
|
export nativesockets.Port, nativesockets.`$`, nativesockets.`==`
|
||||||
export Domain, SockType, Protocol
|
export Domain, SockType, Protocol
|
||||||
|
|
@ -101,6 +100,8 @@ when useWinVersion:
|
||||||
|
|
||||||
when defineSsl:
|
when defineSsl:
|
||||||
import openssl
|
import openssl
|
||||||
|
when not defined(nimDisableCertificateValidation):
|
||||||
|
from ssl_certs import scanSSLCertificates
|
||||||
|
|
||||||
# Note: The enumerations are mapped to Window's constants.
|
# Note: The enumerations are mapped to Window's constants.
|
||||||
|
|
||||||
|
|
@ -670,7 +671,7 @@ when defineSsl:
|
||||||
# That means we can assume that the next internal index is the length of
|
# That means we can assume that the next internal index is the length of
|
||||||
# extra data indexes.
|
# extra data indexes.
|
||||||
for i in ctx.referencedData:
|
for i in ctx.referencedData:
|
||||||
GC_unref(getExtraData(ctx, i).RootRef)
|
GC_unref(getExtraData(ctx, i))
|
||||||
ctx.context.SSL_CTX_free()
|
ctx.context.SSL_CTX_free()
|
||||||
|
|
||||||
proc `pskIdentityHint=`*(ctx: SslContext, hint: string) =
|
proc `pskIdentityHint=`*(ctx: SslContext, hint: string) =
|
||||||
|
|
|
||||||
|
|
@ -1234,7 +1234,7 @@ elif not defined(useNimRtl):
|
||||||
|
|
||||||
when defined(macosx) or defined(freebsd) or defined(netbsd) or
|
when defined(macosx) or defined(freebsd) or defined(netbsd) or
|
||||||
defined(openbsd) or defined(dragonfly):
|
defined(openbsd) or defined(dragonfly):
|
||||||
import kqueue, times
|
import kqueue
|
||||||
|
|
||||||
proc waitForExit(p: Process, timeout: int = -1): int =
|
proc waitForExit(p: Process, timeout: int = -1): int =
|
||||||
if p.exitFlag:
|
if p.exitFlag:
|
||||||
|
|
|
||||||
|
|
@ -769,8 +769,6 @@ proc getch*(): char =
|
||||||
discard fd.tcSetAttr(TCSADRAIN, addr oldMode)
|
discard fd.tcSetAttr(TCSADRAIN, addr oldMode)
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
from unicode import toUTF8, Rune, runeLenAt
|
|
||||||
|
|
||||||
proc readPasswordFromStdin*(prompt: string, password: var string):
|
proc readPasswordFromStdin*(prompt: string, password: var string):
|
||||||
bool {.tags: [ReadIOEffect, WriteIOEffect].} =
|
bool {.tags: [ReadIOEffect, WriteIOEffect].} =
|
||||||
## Reads a `password` from stdin without printing it. `password` must not
|
## Reads a `password` from stdin without printing it. `password` must not
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ when defined(js):
|
||||||
system.`+`(a, b)
|
system.`+`(a, b)
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
elif defined(posix):
|
elif defined(posix) and not defined(osx):
|
||||||
import posix
|
import posix
|
||||||
|
|
||||||
elif defined(windows):
|
elif defined(windows):
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ this can eventually be moved to std/os and `walkDirRec` can be implemented in te
|
||||||
to avoid duplication
|
to avoid duplication
|
||||||
]##
|
]##
|
||||||
|
|
||||||
import std/[os,strutils]
|
import std/[os]
|
||||||
|
when defined(windows):
|
||||||
|
from strutils import replace
|
||||||
|
|
||||||
type
|
type
|
||||||
PathEntry* = object
|
PathEntry* = object
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ proc `$`*(x: int): string {.magic: "IntToStr", noSideEffect.}
|
||||||
|
|
||||||
when defined(js):
|
when defined(js):
|
||||||
import std/private/since
|
import std/private/since
|
||||||
|
|
||||||
since (1, 3):
|
since (1, 3):
|
||||||
proc `$`*(x: uint): string =
|
proc `$`*(x: uint): string =
|
||||||
## Caveat: currently implemented as $(cast[int](x)), tied to current
|
## Caveat: currently implemented as $(cast[int](x)), tied to current
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,8 @@ proc reportUnhandledErrorAux(e: ref Exception) {.nodestroy.} =
|
||||||
# ugly, but avoids heap allocations :-)
|
# ugly, but avoids heap allocations :-)
|
||||||
template xadd(buf, s, slen) =
|
template xadd(buf, s, slen) =
|
||||||
if L + slen < high(buf):
|
if L + slen < high(buf):
|
||||||
copyMem(addr(buf[L]), cstring(s), slen)
|
|
||||||
|
copyMem(addr(buf[L]), (when s is cstring: s else: cstring(s)), slen)
|
||||||
inc L, slen
|
inc L, slen
|
||||||
template add(buf, s) =
|
template add(buf, s) =
|
||||||
xadd(buf, s, s.len)
|
xadd(buf, s, s.len)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ proc getMachine*(): MachineId =
|
||||||
var name = execProcess("hostname").strip
|
var name = execProcess("hostname").strip
|
||||||
if name.len == 0:
|
if name.len == 0:
|
||||||
name = when defined(posix): getEnv("HOSTNAME")
|
name = when defined(posix): getEnv("HOSTNAME")
|
||||||
else: getEnv("COMPUTERNAME").string
|
else: getEnv("COMPUTERNAME")
|
||||||
if name.len == 0:
|
if name.len == 0:
|
||||||
quit "cannot determine the machine name"
|
quit "cannot determine the machine name"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ when isMainModule:
|
||||||
verbose = false
|
verbose = false
|
||||||
|
|
||||||
for i in 0..paramCount() - 1:
|
for i in 0..paramCount() - 1:
|
||||||
let param = string(paramStr(i + 1))
|
let param = paramStr(i + 1)
|
||||||
case param
|
case param
|
||||||
of "verbose": verbose = true
|
of "verbose": verbose = true
|
||||||
else: filter = param
|
else: filter = param
|
||||||
|
|
|
||||||
|
|
@ -683,7 +683,7 @@ proc main() =
|
||||||
case p.key.normalize
|
case p.key.normalize
|
||||||
of "print", "verbose": optPrintResults = true
|
of "print", "verbose": optPrintResults = true
|
||||||
of "failing": optFailing = true
|
of "failing": optFailing = true
|
||||||
of "pedantic": discard # deadcode
|
of "pedantic": discard # deadcode refs https://github.com/nim-lang/Nim/issues/16731
|
||||||
of "targets":
|
of "targets":
|
||||||
targetsStr = p.val
|
targetsStr = p.val
|
||||||
gTargets = parseTargets(targetsStr)
|
gTargets = parseTargets(targetsStr)
|
||||||
|
|
@ -739,7 +739,7 @@ proc main() =
|
||||||
var r = initResults()
|
var r = initResults()
|
||||||
case action
|
case action
|
||||||
of "all":
|
of "all":
|
||||||
#processCategory(r, Category"megatest", p.cmdLineRest.string, testsDir, runJoinableTests = false)
|
#processCategory(r, Category"megatest", p.cmdLineRest, testsDir, runJoinableTests = false)
|
||||||
|
|
||||||
var myself = quoteShell(getAppFilename())
|
var myself = quoteShell(getAppFilename())
|
||||||
if targetsStr.len > 0:
|
if targetsStr.len > 0:
|
||||||
|
|
@ -798,8 +798,7 @@ proc main() =
|
||||||
p.next
|
p.next
|
||||||
processPattern(r, pattern, p.cmdLineRest, simulate)
|
processPattern(r, pattern, p.cmdLineRest, simulate)
|
||||||
of "r", "run":
|
of "r", "run":
|
||||||
var subPath = p.key
|
let (cat, path) = splitTestFile(p.key)
|
||||||
let (cat, path) = splitTestFile(subPath)
|
|
||||||
processSingleTest(r, cat.Category, p.cmdLineRest, path, gTargets, targetsSet)
|
processSingleTest(r, cat.Category, p.cmdLineRest, path, gTargets, targetsSet)
|
||||||
of "html":
|
of "html":
|
||||||
generateHtml(resultsFile, optFailing)
|
generateHtml(resultsFile, optFailing)
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,5 @@ hint("Processing", off)
|
||||||
# uncomment to enable all flaky tests disabled by this flag
|
# uncomment to enable all flaky tests disabled by this flag
|
||||||
# (works through process calls, e.g. tests that invoke nim).
|
# (works through process calls, e.g. tests that invoke nim).
|
||||||
# switch("define", "nimTestsEnableFlaky")
|
# switch("define", "nimTestsEnableFlaky")
|
||||||
|
|
||||||
|
# switch("hint", "ConvFromXtoItselfNotNeeded")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue