[backport] run nimpretty on the remaining files
This commit is contained in:
parent
34d0be2ec1
commit
5732bb41ef
13 changed files with 457 additions and 414 deletions
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
when not nimCoroutines and not defined(nimdoc):
|
||||
when defined(noNimCoroutines):
|
||||
{.error: "Coroutines can not be used with -d:noNimCoroutines"}
|
||||
{.error: "Coroutines can not be used with -d:noNimCoroutines".}
|
||||
else:
|
||||
{.error: "Coroutines require -d:nimCoroutines".}
|
||||
|
||||
|
|
@ -75,13 +75,18 @@ elif coroBackend == CORO_BACKEND_UCONTEXT:
|
|||
|
||||
Context = ucontext_t
|
||||
|
||||
proc getcontext(context: var ucontext_t): int32 {.importc, header: "<ucontext.h>".}
|
||||
proc setcontext(context: var ucontext_t): int32 {.importc, header: "<ucontext.h>".}
|
||||
proc swapcontext(fromCtx, toCtx: var ucontext_t): int32 {.importc, header: "<ucontext.h>".}
|
||||
proc makecontext(context: var ucontext_t, fn: pointer, argc: int32) {.importc, header: "<ucontext.h>", varargs.}
|
||||
proc getcontext(context: var ucontext_t): int32 {.importc,
|
||||
header: "<ucontext.h>".}
|
||||
proc setcontext(context: var ucontext_t): int32 {.importc,
|
||||
header: "<ucontext.h>".}
|
||||
proc swapcontext(fromCtx, toCtx: var ucontext_t): int32 {.importc,
|
||||
header: "<ucontext.h>".}
|
||||
proc makecontext(context: var ucontext_t, fn: pointer, argc: int32) {.importc,
|
||||
header: "<ucontext.h>", varargs.}
|
||||
|
||||
elif coroBackend == CORO_BACKEND_SETJMP:
|
||||
proc coroExecWithStack*(fn: pointer, stack: pointer) {.noreturn, importc: "narch_$1", fastcall.}
|
||||
proc coroExecWithStack*(fn: pointer, stack: pointer) {.noreturn,
|
||||
importc: "narch_$1", fastcall.}
|
||||
when defined(amd64):
|
||||
{.compile: "../arch/x86/amd64.S".}
|
||||
elif defined(i386):
|
||||
|
|
@ -251,7 +256,9 @@ proc start*(c: proc(), stacksize: int=defaultStackSize): CoroutineRef {.discarda
|
|||
when coroBackend == CORO_BACKEND_FIBERS:
|
||||
coro = cast[CoroutinePtr](alloc0(sizeof(Coroutine)))
|
||||
coro.execContext = CreateFiberEx(stacksize, stacksize,
|
||||
FIBER_FLAG_FLOAT_SWITCH, (proc(p: pointer): void {.stdcall.} = runCurrentTask()), nil)
|
||||
FIBER_FLAG_FLOAT_SWITCH,
|
||||
(proc(p: pointer): void {.stdcall.} = runCurrentTask()),
|
||||
nil)
|
||||
coro.stack.size = stacksize
|
||||
else:
|
||||
coro = cast[CoroutinePtr](alloc0(sizeof(Coroutine) + stacksize))
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ when not defined(js):
|
|||
import os
|
||||
|
||||
type
|
||||
Level* = enum
|
||||
Level* = enum ## \
|
||||
## Enumeration of logging levels.
|
||||
##
|
||||
## Debug messages represent the lowest logging level, and fatal error
|
||||
|
|
@ -187,8 +187,7 @@ const
|
|||
"DEBUG", "DEBUG", "INFO", "NOTICE", "WARN", "ERROR", "FATAL", "NONE"
|
||||
] ## Array of strings representing each logging level.
|
||||
|
||||
defaultFmtStr* = "$levelname " ## \
|
||||
## The default format string.
|
||||
defaultFmtStr* = "$levelname " ## The default format string.
|
||||
verboseFmtStr* = "$levelid, [$datetime] -- $appname: " ## \
|
||||
## A more verbose format string.
|
||||
##
|
||||
|
|
@ -265,7 +264,8 @@ var
|
|||
level {.threadvar.}: Level ## global log filter
|
||||
handlers {.threadvar.}: seq[Logger] ## handlers with their own log levels
|
||||
|
||||
proc substituteLog*(frmt: string, level: Level, args: varargs[string, `$`]): string =
|
||||
proc substituteLog*(frmt: string, level: Level,
|
||||
args: varargs[string, `$`]): string =
|
||||
## Formats a log message at the specified level with the given format string.
|
||||
##
|
||||
## The `format variables<#basic-usage-format-strings>`_ present within
|
||||
|
|
@ -375,7 +375,8 @@ method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) =
|
|||
except IOError:
|
||||
discard
|
||||
|
||||
proc newConsoleLogger*(levelThreshold = lvlAll, fmtStr = defaultFmtStr, useStderr=false): ConsoleLogger =
|
||||
proc newConsoleLogger*(levelThreshold = lvlAll, fmtStr = defaultFmtStr,
|
||||
useStderr = false): ConsoleLogger =
|
||||
## Creates a new `ConsoleLogger<#ConsoleLogger>`_.
|
||||
##
|
||||
## By default, log messages are written to ``stdout``. If ``useStderr`` is
|
||||
|
|
@ -616,7 +617,8 @@ when not defined(js):
|
|||
rotate(logger)
|
||||
logger.logFiles.inc
|
||||
logger.curLine = 0
|
||||
logger.file = open(logger.baseName, logger.baseMode, bufSize = logger.bufSize)
|
||||
logger.file = open(logger.baseName, logger.baseMode,
|
||||
bufSize = logger.bufSize)
|
||||
|
||||
writeLine(logger.file, substituteLog(logger.fmtStr, level, args))
|
||||
if level in {lvlError, lvlFatal}: flushFile(logger.file)
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ when defined(macosx) and not defined(nimdoc):
|
|||
type
|
||||
Port* = distinct uint16 ## port type
|
||||
|
||||
Domain* = enum ## domain, which specifies the protocol family of the
|
||||
Domain* = enum ## \
|
||||
## domain, which specifies the protocol family of the
|
||||
## created socket. Other domains than those that are listed
|
||||
## here are unsupported.
|
||||
AF_UNSPEC = 0, ## unspecified domain (can be detected automatically by
|
||||
|
|
@ -223,10 +224,12 @@ proc close*(socket: SocketHandle) =
|
|||
# TODO: These values should not be discarded. An OSError should be raised.
|
||||
# http://stackoverflow.com/questions/12463473/what-happens-if-you-call-close-on-a-bsd-socket-multiple-times
|
||||
|
||||
proc bindAddr*(socket: SocketHandle, name: ptr SockAddr, namelen: SockLen): cint =
|
||||
proc bindAddr*(socket: SocketHandle, name: ptr SockAddr,
|
||||
namelen: SockLen): cint =
|
||||
result = bindSocket(socket, name, namelen)
|
||||
|
||||
proc listen*(socket: SocketHandle, backlog = SOMAXCONN): cint {.tags: [ReadIOEffect].} =
|
||||
proc listen*(socket: SocketHandle, backlog = SOMAXCONN): cint {.tags: [
|
||||
ReadIOEffect].} =
|
||||
## Marks ``socket`` as accepting connections.
|
||||
## ``Backlog`` specifies the maximum length of the
|
||||
## queue of pending connections.
|
||||
|
|
@ -250,7 +253,8 @@ proc getAddrInfo*(address: string, port: Port, domain: Domain = AF_INET,
|
|||
# FreeBSD, Haiku don't support AI_V4MAPPED but defines the macro.
|
||||
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198092
|
||||
# https://dev.haiku-os.org/ticket/14323
|
||||
when not defined(freebsd) and not defined(openbsd) and not defined(netbsd) and not defined(android) and not defined(haiku):
|
||||
when not defined(freebsd) and not defined(openbsd) and not defined(netbsd) and
|
||||
not defined(android) and not defined(haiku):
|
||||
if domain == AF_INET6:
|
||||
hints.ai_flags = AI_V4MAPPED
|
||||
let socketPort = if sockType == SOCK_RAW: "" else: $port
|
||||
|
|
|
|||
|
|
@ -201,7 +201,8 @@ proc writeProfile() {.noconv.} =
|
|||
let procname = profileData[i].st[ii]
|
||||
let filename = profileData[i].st.files[ii]
|
||||
if isNil(procname): break
|
||||
writeLine(f, " ", $filename & ": " & $procname, " ", perProc[$procname] // totalCalls)
|
||||
writeLine(f, " ", $filename & ": " & $procname, " ",
|
||||
perProc[$procname] // totalCalls)
|
||||
close(f)
|
||||
echo "... done"
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -273,7 +273,8 @@ proc flatten*[A](self: Option[Option[A]]): Option[A] =
|
|||
else:
|
||||
none(A)
|
||||
|
||||
proc flatMap*[A, B](self: Option[A], callback: proc (input: A): Option[B]): Option[B] =
|
||||
proc flatMap*[A, B](self: Option[A],
|
||||
callback: proc (input: A): Option[B]): Option[B] =
|
||||
## Applies a `callback` function to the value of the `Option` and returns an
|
||||
## `Option` containing the new value.
|
||||
##
|
||||
|
|
|
|||
|
|
@ -796,7 +796,8 @@ template matchOrParse(mopProc: untyped) =
|
|||
of pkGreedyRepSet:
|
||||
enter(pkGreedyRepSet, s, p, start)
|
||||
result = 0
|
||||
while start+result < s.len and contains(p.charChoice[], s[start+result]): inc(result)
|
||||
while start+result < s.len and contains(p.charChoice[], s[start+result]):
|
||||
inc(result)
|
||||
leave(pkGreedyRepSet, s, p, start, result)
|
||||
of pkOption:
|
||||
enter(pkOption, s, p, start)
|
||||
|
|
|
|||
|
|
@ -883,7 +883,8 @@ proc enableTrueColors*() =
|
|||
else:
|
||||
term.trueColorIsEnabled = true
|
||||
else:
|
||||
term.trueColorIsSupported = string(getEnv("COLORTERM")).toLowerAscii() in ["truecolor", "24bit"]
|
||||
term.trueColorIsSupported = string(getEnv("COLORTERM")).toLowerAscii() in [
|
||||
"truecolor", "24bit"]
|
||||
term.trueColorIsEnabled = term.trueColorIsSupported
|
||||
|
||||
proc disableTrueColors*() =
|
||||
|
|
@ -944,5 +945,6 @@ when not defined(testing) and isMainModule:
|
|||
echo ""
|
||||
echo "ordinary text"
|
||||
stdout.styledWriteLine(fgRed, "red text ", styleBright, "bold red", fgDefault, " bold text")
|
||||
stdout.styledWriteLine(bgYellow, "text in yellow bg", styleBright, " bold text in yellow bg", bgDefault, " bold text")
|
||||
stdout.styledWriteLine(bgYellow, "text in yellow bg", styleBright,
|
||||
" bold text in yellow bg", bgDefault, " bold text")
|
||||
echo "ordinary text"
|
||||
|
|
|
|||
|
|
@ -435,10 +435,13 @@ const unitWeights: array[FixedTimeUnit, int64] = [
|
|||
]
|
||||
|
||||
const DefaultLocale* = DateTimeLocale(
|
||||
MMM: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
MMMM: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
MMM: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
|
||||
"Nov", "Dec"],
|
||||
MMMM: ["January", "February", "March", "April", "May", "June", "July",
|
||||
"August", "September", "October", "November", "December"],
|
||||
ddd: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
dddd: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||
dddd: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
|
||||
"Sunday"],
|
||||
)
|
||||
|
||||
proc convert*[T: SomeInteger](unitFrom, unitTo: FixedTimeUnit, quantity: T): T
|
||||
|
|
@ -854,21 +857,24 @@ proc `==`*(a, b: Duration): bool {.operator, extern: "ntEqDuration".} =
|
|||
doAssert d1 == d2
|
||||
eqImpl(a, b)
|
||||
|
||||
proc `*`*(a: int64, b: Duration): Duration {.operator, extern: "ntMulInt64Duration".} =
|
||||
proc `*`*(a: int64, b: Duration): Duration {.operator,
|
||||
extern: "ntMulInt64Duration".} =
|
||||
## Multiply a duration by some scalar.
|
||||
runnableExamples:
|
||||
doAssert 5 * initDuration(seconds = 1) == initDuration(seconds = 5)
|
||||
doAssert 3 * initDuration(minutes = 45) == initDuration(hours = 2, minutes = 15)
|
||||
normalize[Duration](a * b.seconds, a * b.nanosecond)
|
||||
|
||||
proc `*`*(a: Duration, b: int64): Duration {.operator, extern: "ntMulDuration".} =
|
||||
proc `*`*(a: Duration, b: int64): Duration {.operator,
|
||||
extern: "ntMulDuration".} =
|
||||
## Multiply a duration by some scalar.
|
||||
runnableExamples:
|
||||
doAssert initDuration(seconds = 1) * 5 == initDuration(seconds = 5)
|
||||
doAssert initDuration(minutes = 45) * 3 == initDuration(hours = 2, minutes = 15)
|
||||
b * a
|
||||
|
||||
proc `div`*(a: Duration, b: int64): Duration {.operator, extern: "ntDivDuration".} =
|
||||
proc `div`*(a: Duration, b: int64): Duration {.operator,
|
||||
extern: "ntDivDuration".} =
|
||||
## Integer division for durations.
|
||||
runnableExamples:
|
||||
doAssert initDuration(seconds = 3) div 2 ==
|
||||
|
|
@ -1783,7 +1789,8 @@ proc `$`*(f: TimeFormat): string =
|
|||
|
||||
proc raiseParseException(f: TimeFormat, input: string, msg: string) =
|
||||
raise newException(TimeParseError,
|
||||
"Failed to parse '" & input & "' with format '" & $f & "'. " & msg)
|
||||
"Failed to parse '" & input & "' with format '" & $f &
|
||||
"'. " & msg)
|
||||
|
||||
proc parseInt(s: string, b: var int, start = 0, maxLen = int.high,
|
||||
allowSign = false): int =
|
||||
|
|
@ -1919,7 +1926,8 @@ proc initTimeFormat*(format: string): TimeFormat =
|
|||
of tkPattern:
|
||||
result.patterns.add(stringToPattern(token).byte)
|
||||
|
||||
proc formatPattern(dt: DateTime, pattern: FormatPattern, result: var string, loc: DateTimeLocale) =
|
||||
proc formatPattern(dt: DateTime, pattern: FormatPattern, result: var string,
|
||||
loc: DateTimeLocale) =
|
||||
template yearOfEra(dt: DateTime): int =
|
||||
if dt.year <= 0: abs(dt.year) + 1 else: dt.year
|
||||
|
||||
|
|
@ -2270,7 +2278,8 @@ proc toDateTime(p: ParsedTime, zone: Timezone, f: TimeFormat,
|
|||
result.utcOffset = p.utcOffset.get()
|
||||
result = result.toTime.inZone(zone)
|
||||
|
||||
proc format*(dt: DateTime, f: TimeFormat, loc: DateTimeLocale = DefaultLocale): string {.raises: [].} =
|
||||
proc format*(dt: DateTime, f: TimeFormat,
|
||||
loc: DateTimeLocale = DefaultLocale): string {.raises: [].} =
|
||||
## Format ``dt`` using the format specified by ``f``.
|
||||
runnableExamples:
|
||||
let f = initTimeFormat("yyyy-MM-dd")
|
||||
|
|
@ -2334,7 +2343,8 @@ template formatValue*(result: var string; value: Time, specifier: string) =
|
|||
## adapter for ``strformat``. Not intended to be called directly.
|
||||
result.add format(value, specifier)
|
||||
|
||||
proc parse*(input: string, f: TimeFormat, zone: Timezone = local(), loc: DateTimeLocale = DefaultLocale): DateTime
|
||||
proc parse*(input: string, f: TimeFormat, zone: Timezone = local(),
|
||||
loc: DateTimeLocale = DefaultLocale): DateTime
|
||||
{.raises: [TimeParseError, Defect].} =
|
||||
## Parses ``input`` as a ``DateTime`` using the format specified by ``f``.
|
||||
## If no UTC offset was parsed, then ``input`` is assumed to be specified in
|
||||
|
|
@ -2377,7 +2387,8 @@ proc parse*(input: string, f: TimeFormat, zone: Timezone = local(), loc: DateTim
|
|||
|
||||
result = toDateTime(parsed, zone, f, input)
|
||||
|
||||
proc parse*(input, f: string, tz: Timezone = local(), loc: DateTimeLocale = DefaultLocale): DateTime
|
||||
proc parse*(input, f: string, tz: Timezone = local(),
|
||||
loc: DateTimeLocale = DefaultLocale): DateTime
|
||||
{.raises: [TimeParseError, TimeFormatParseError, Defect].} =
|
||||
## Shorthand for constructing a ``TimeFormat`` and using it to parse
|
||||
## ``input`` as a ``DateTime``.
|
||||
|
|
@ -2390,7 +2401,8 @@ proc parse*(input, f: string, tz: Timezone = local(), loc: DateTimeLocale = Defa
|
|||
let dtFormat = initTimeFormat(f)
|
||||
result = input.parse(dtFormat, tz, loc = loc)
|
||||
|
||||
proc parse*(input: string, f: static[string], zone: Timezone = local(), loc: DateTimeLocale = DefaultLocale):
|
||||
proc parse*(input: string, f: static[string], zone: Timezone = local(),
|
||||
loc: DateTimeLocale = DefaultLocale):
|
||||
DateTime {.raises: [TimeParseError, Defect].} =
|
||||
## Overload that validates ``f`` at compile time.
|
||||
const f2 = initTimeFormat(f)
|
||||
|
|
@ -2530,7 +2542,8 @@ when not defined(JS):
|
|||
when defined(macosx):
|
||||
var a: Timeval
|
||||
gettimeofday(a)
|
||||
result = toBiggestFloat(a.tv_sec.int64) + toBiggestFloat(a.tv_usec)*0.00_0001
|
||||
result = toBiggestFloat(a.tv_sec.int64) + toBiggestFloat(
|
||||
a.tv_usec)*0.00_0001
|
||||
elif defined(posix):
|
||||
var ts: Timespec
|
||||
discard clock_gettime(CLOCK_REALTIME, ts)
|
||||
|
|
@ -2647,7 +2660,8 @@ proc fractional*(dur: Duration): Duration {.inline, deprecated.} =
|
|||
runnableExamples:
|
||||
let dur = initDuration(minutes = 5, seconds = 6, milliseconds = 7,
|
||||
microseconds = 8, nanoseconds = 9)
|
||||
doAssert dur.fractional == initDuration(milliseconds = 7, microseconds = 8, nanoseconds = 9)
|
||||
doAssert dur.fractional == initDuration(milliseconds = 7, microseconds = 8,
|
||||
nanoseconds = 9)
|
||||
initDuration(nanoseconds = dur.nanosecond)
|
||||
|
||||
when not defined(JS):
|
||||
|
|
|
|||
|
|
@ -169,7 +169,8 @@ method suiteStarted*(formatter: OutputFormatter, suiteName: string) {.base, gcsa
|
|||
discard
|
||||
method testStarted*(formatter: OutputFormatter, testName: string) {.base, gcsafe.} =
|
||||
discard
|
||||
method failureOccurred*(formatter: OutputFormatter, checkpoints: seq[string], stackTrace: string) {.base, gcsafe.} =
|
||||
method failureOccurred*(formatter: OutputFormatter, checkpoints: seq[string],
|
||||
stackTrace: string) {.base, gcsafe.} =
|
||||
## ``stackTrace`` is provided only if the failure occurred due to an exception.
|
||||
## ``checkpoints`` is never ``nil``.
|
||||
discard
|
||||
|
|
@ -228,7 +229,8 @@ method suiteStarted*(formatter: ConsoleOutputFormatter, suiteName: string) =
|
|||
method testStarted*(formatter: ConsoleOutputFormatter, testName: string) =
|
||||
formatter.isInTest = true
|
||||
|
||||
method failureOccurred*(formatter: ConsoleOutputFormatter, checkpoints: seq[string], stackTrace: string) =
|
||||
method failureOccurred*(formatter: ConsoleOutputFormatter,
|
||||
checkpoints: seq[string], stackTrace: string) =
|
||||
if stackTrace.len > 0:
|
||||
echo stackTrace
|
||||
let prefix = if formatter.isInSuite: " " else: ""
|
||||
|
|
@ -241,14 +243,16 @@ method testEnded*(formatter: ConsoleOutputFormatter, testResult: TestResult) =
|
|||
if formatter.outputLevel != PRINT_NONE and
|
||||
(formatter.outputLevel == PRINT_ALL or testResult.status == FAILED):
|
||||
let prefix = if testResult.suiteName.len > 0: " " else: ""
|
||||
template rawPrint() = echo(prefix, "[", $testResult.status, "] ", testResult.testName)
|
||||
template rawPrint() = echo(prefix, "[", $testResult.status, "] ",
|
||||
testResult.testName)
|
||||
when not defined(ECMAScript):
|
||||
if formatter.colorOutput and not defined(ECMAScript):
|
||||
var color = case testResult.status
|
||||
of OK: fgGreen
|
||||
of FAILED: fgRed
|
||||
of SKIPPED: fgYellow
|
||||
styledEcho styleBright, color, prefix, "[", $testResult.status, "] ", resetStyle, testResult.testName
|
||||
styledEcho styleBright, color, prefix, "[", $testResult.status, "] ",
|
||||
resetStyle, testResult.testName
|
||||
else:
|
||||
rawPrint()
|
||||
else:
|
||||
|
|
@ -300,7 +304,8 @@ method testStarted*(formatter: JUnitOutputFormatter, testName: string) =
|
|||
formatter.testStackTrace.setLen(0)
|
||||
formatter.testStartTime = epochTime()
|
||||
|
||||
method failureOccurred*(formatter: JUnitOutputFormatter, checkpoints: seq[string], stackTrace: string) =
|
||||
method failureOccurred*(formatter: JUnitOutputFormatter,
|
||||
checkpoints: seq[string], stackTrace: string) =
|
||||
## ``stackTrace`` is provided only if the failure occurred due to an exception.
|
||||
## ``checkpoints`` is never ``nil``.
|
||||
formatter.testErrors.add(checkpoints)
|
||||
|
|
@ -310,7 +315,8 @@ method failureOccurred*(formatter: JUnitOutputFormatter, checkpoints: seq[string
|
|||
method testEnded*(formatter: JUnitOutputFormatter, testResult: TestResult) =
|
||||
let time = epochTime() - formatter.testStartTime
|
||||
let timeStr = time.formatFloat(ffDecimal, precision = 8)
|
||||
formatter.stream.writeLine("\t\t<testcase name=\"$#\" time=\"$#\">" % [xmlEscape(testResult.testName), timeStr])
|
||||
formatter.stream.writeLine("\t\t<testcase name=\"$#\" time=\"$#\">" % [
|
||||
xmlEscape(testResult.testName), timeStr])
|
||||
case testResult.status
|
||||
of OK:
|
||||
discard
|
||||
|
|
@ -327,7 +333,8 @@ method testEnded*(formatter: JUnitOutputFormatter, testResult: TestResult) =
|
|||
var errs = ""
|
||||
if formatter.testErrors.len > 1:
|
||||
var startIdx = if formatter.testStackTrace.len > 0: 0 else: 1
|
||||
var endIdx = if formatter.testStackTrace.len > 0: formatter.testErrors.len - 2
|
||||
var endIdx = if formatter.testStackTrace.len > 0:
|
||||
formatter.testErrors.len - 2
|
||||
else: formatter.testErrors.len - 1
|
||||
|
||||
for errIdx in startIdx..endIdx:
|
||||
|
|
@ -336,11 +343,13 @@ method testEnded*(formatter: JUnitOutputFormatter, testResult: TestResult) =
|
|||
errs.add(xmlEscape(formatter.testErrors[errIdx]))
|
||||
|
||||
if formatter.testStackTrace.len > 0:
|
||||
formatter.stream.writeLine("\t\t\t<error message=\"$#\">$#</error>" % [failureMsg, xmlEscape(formatter.testStackTrace)])
|
||||
formatter.stream.writeLine("\t\t\t<error message=\"$#\">$#</error>" % [
|
||||
failureMsg, xmlEscape(formatter.testStackTrace)])
|
||||
if errs.len > 0:
|
||||
formatter.stream.writeLine("\t\t\t<system-err>$#</system-err>" % errs)
|
||||
else:
|
||||
formatter.stream.writeLine("\t\t\t<failure message=\"$#\">$#</failure>" % [failureMsg, errs])
|
||||
formatter.stream.writeLine("\t\t\t<failure message=\"$#\">$#</failure>" %
|
||||
[failureMsg, errs])
|
||||
|
||||
formatter.stream.writeLine("\t\t</testcase>")
|
||||
|
||||
|
|
@ -363,7 +372,8 @@ proc glob(matcher, filter: string): bool =
|
|||
if matcher.len < filter.len - 1:
|
||||
return false # "12345" should not match "123*345"
|
||||
|
||||
return matcher.startsWith(beforeAndAfter[0]) and matcher.endsWith(beforeAndAfter[1])
|
||||
return matcher.startsWith(beforeAndAfter[0]) and matcher.endsWith(
|
||||
beforeAndAfter[1])
|
||||
|
||||
proc matchFilter(suiteName, testName, filter: string): bool =
|
||||
if filter == "":
|
||||
|
|
@ -378,7 +388,8 @@ proc matchFilter(suiteName, testName, filter: string): bool =
|
|||
let testFilter = suiteAndTestFilters[0]
|
||||
return glob(testName, testFilter)
|
||||
|
||||
return glob(suiteName, suiteAndTestFilters[0]) and glob(testName, suiteAndTestFilters[1])
|
||||
return glob(suiteName, suiteAndTestFilters[0]) and
|
||||
glob(testName, suiteAndTestFilters[1])
|
||||
|
||||
when defined(testing): export matchFilter
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue