Merge branch 'devel' of https://github.com/Araq/Nimrod into devel
This commit is contained in:
commit
05e89ffceb
43 changed files with 123 additions and 61 deletions
|
|
@ -1060,6 +1060,8 @@ proc genObjConstr(p: BProc, e: PNode, d: var TLoc) =
|
||||||
t = t.sons[0].skipTypes(abstractInst)
|
t = t.sons[0].skipTypes(abstractInst)
|
||||||
r = ropef("(*$1)", r)
|
r = ropef("(*$1)", r)
|
||||||
gcUsage(e)
|
gcUsage(e)
|
||||||
|
else:
|
||||||
|
constructLoc(p, tmp)
|
||||||
discard getTypeDesc(p.module, t)
|
discard getTypeDesc(p.module, t)
|
||||||
for i in 1 .. <e.len:
|
for i in 1 .. <e.len:
|
||||||
let it = e.sons[i]
|
let it = e.sons[i]
|
||||||
|
|
@ -1082,6 +1084,7 @@ proc genObjConstr(p: BProc, e: PNode, d: var TLoc) =
|
||||||
tmp2.s = if isRef: OnHeap else: OnStack
|
tmp2.s = if isRef: OnHeap else: OnStack
|
||||||
tmp2.heapRoot = tmp.r
|
tmp2.heapRoot = tmp.r
|
||||||
expr(p, it.sons[1], tmp2)
|
expr(p, it.sons[1], tmp2)
|
||||||
|
|
||||||
if d.k == locNone:
|
if d.k == locNone:
|
||||||
d = tmp
|
d = tmp
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ const
|
||||||
errInvalidNumberOfYieldExpr: "invalid number of \'yield\' expressions",
|
errInvalidNumberOfYieldExpr: "invalid number of \'yield\' expressions",
|
||||||
errCannotReturnExpr: "current routine cannot return an expression",
|
errCannotReturnExpr: "current routine cannot return an expression",
|
||||||
errAttemptToRedefine: "redefinition of \'$1\'",
|
errAttemptToRedefine: "redefinition of \'$1\'",
|
||||||
errStmtInvalidAfterReturn: "statement not allowed after \'return\', \'break\' or \'raise\'",
|
errStmtInvalidAfterReturn: "statement not allowed after \'return\', \'break\', \'raise\' or \'continue'",
|
||||||
errStmtExpected: "statement expected",
|
errStmtExpected: "statement expected",
|
||||||
errInvalidLabel: "\'$1\' is no label",
|
errInvalidLabel: "\'$1\' is no label",
|
||||||
errInvalidCmdLineOption: "invalid command line option: \'$1\'",
|
errInvalidCmdLineOption: "invalid command line option: \'$1\'",
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import
|
import
|
||||||
os, lists, strutils, strtabs
|
os, lists, strutils, strtabs, osproc, sets
|
||||||
|
|
||||||
const
|
const
|
||||||
hasTinyCBackend* = defined(tinyc)
|
hasTinyCBackend* = defined(tinyc)
|
||||||
|
|
@ -16,6 +16,7 @@ const
|
||||||
hasFFI* = defined(useFFI)
|
hasFFI* = defined(useFFI)
|
||||||
newScopeForIf* = true
|
newScopeForIf* = true
|
||||||
useCaas* = not defined(noCaas)
|
useCaas* = not defined(noCaas)
|
||||||
|
noTimeMachine = defined(avoidTimeMachine) and defined(macosx)
|
||||||
|
|
||||||
type # please make sure we have under 32 options
|
type # please make sure we have under 32 options
|
||||||
# (improves code efficiency a lot!)
|
# (improves code efficiency a lot!)
|
||||||
|
|
@ -263,6 +264,28 @@ proc toGeneratedFile*(path, ext: string): string =
|
||||||
result = joinPath([getGeneratedPath(), changeFileExt(tail, ext)])
|
result = joinPath([getGeneratedPath(), changeFileExt(tail, ext)])
|
||||||
#echo "toGeneratedFile(", path, ", ", ext, ") = ", result
|
#echo "toGeneratedFile(", path, ", ", ext, ") = ", result
|
||||||
|
|
||||||
|
when noTimeMachine:
|
||||||
|
var alreadyExcludedDirs = initSet[string]()
|
||||||
|
proc excludeDirFromTimeMachine(dir: string) {.raises: [].} =
|
||||||
|
## Calls a macosx command on the directory to exclude it from backups.
|
||||||
|
##
|
||||||
|
## The macosx tmutil command is invoked to mark the specified path as an
|
||||||
|
## item to be excluded from time machine backups. If a path already exists
|
||||||
|
## with files before excluding it, newer files won't be added to the
|
||||||
|
## directory, but previous files won't be removed from the backup until the
|
||||||
|
## user deletes that directory.
|
||||||
|
##
|
||||||
|
## The whole proc is optional and will ignore all kinds of errors. The only
|
||||||
|
## way to be sure that it works is to call ``tmutil isexcluded path``.
|
||||||
|
if alreadyExcludedDirs.contains(dir): return
|
||||||
|
alreadyExcludedDirs.incl(dir)
|
||||||
|
try:
|
||||||
|
var p = startProcess("/usr/bin/tmutil", args = ["addexclusion", dir])
|
||||||
|
discard p.waitForExit
|
||||||
|
p.close
|
||||||
|
except E_Base, EOS:
|
||||||
|
discard
|
||||||
|
|
||||||
proc completeGeneratedFilePath*(f: string, createSubDir: bool = true): string =
|
proc completeGeneratedFilePath*(f: string, createSubDir: bool = true): string =
|
||||||
var (head, tail) = splitPath(f)
|
var (head, tail) = splitPath(f)
|
||||||
#if len(head) > 0: head = removeTrailingDirSep(shortenDir(head & dirSep))
|
#if len(head) > 0: head = removeTrailingDirSep(shortenDir(head & dirSep))
|
||||||
|
|
@ -270,6 +293,8 @@ proc completeGeneratedFilePath*(f: string, createSubDir: bool = true): string =
|
||||||
if createSubDir:
|
if createSubDir:
|
||||||
try:
|
try:
|
||||||
createDir(subdir)
|
createDir(subdir)
|
||||||
|
when noTimeMachine:
|
||||||
|
excludeDirFromTimeMachine(subdir)
|
||||||
except EOS:
|
except EOS:
|
||||||
writeln(stdout, "cannot create directory: " & subdir)
|
writeln(stdout, "cannot create directory: " & subdir)
|
||||||
quit(1)
|
quit(1)
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ proc serve*(action: proc (){.nimcall.}) =
|
||||||
of "tcp", "":
|
of "tcp", "":
|
||||||
when useCaas:
|
when useCaas:
|
||||||
var server = socket()
|
var server = socket()
|
||||||
|
if server == invalidSocket: osError(osLastError())
|
||||||
let p = getConfigVar("server.port")
|
let p = getConfigVar("server.port")
|
||||||
let port = if p.len > 0: parseInt(p).TPort else: 6000.TPort
|
let port = if p.len > 0: parseInt(p).TPort else: 6000.TPort
|
||||||
server.bindAddr(port, getConfigVar("server.address"))
|
server.bindAddr(port, getConfigVar("server.address"))
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ Advanced commands:
|
||||||
//compileToOC, objc compile project to Objective C code
|
//compileToOC, objc compile project to Objective C code
|
||||||
//rst2html convert a reStructuredText file to HTML
|
//rst2html convert a reStructuredText file to HTML
|
||||||
//rst2tex convert a reStructuredText file to TeX
|
//rst2tex convert a reStructuredText file to TeX
|
||||||
|
//jsondoc extract the documentation to a json file
|
||||||
//buildIndex build an index for the whole documentation
|
//buildIndex build an index for the whole documentation
|
||||||
//run run the project (with Tiny C backend; buggy!)
|
//run run the project (with Tiny C backend; buggy!)
|
||||||
//genDepend generate a DOT file containing the
|
//genDepend generate a DOT file containing the
|
||||||
|
|
|
||||||
1
koch.nim
1
koch.nim
|
|
@ -53,6 +53,7 @@ Boot options:
|
||||||
(not needed on Windows)
|
(not needed on Windows)
|
||||||
-d:nativeStacktrace use native stack traces (only for Mac OS X or Linux)
|
-d:nativeStacktrace use native stack traces (only for Mac OS X or Linux)
|
||||||
-d:noCaas build Nimrod without CAAS support
|
-d:noCaas build Nimrod without CAAS support
|
||||||
|
-d:avoidTimeMachine only for Mac OS X, excludes nimcache dir from backups
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc exe(f: string): string = return addFileExt(f, ExeExt)
|
proc exe(f: string): string = return addFileExt(f, ExeExt)
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ proc `==`*[A, B](s, t: TTable[A, B]): bool =
|
||||||
# to use the slow route here:
|
# to use the slow route here:
|
||||||
for key, val in s:
|
for key, val in s:
|
||||||
if not hasKey(t, key): return false
|
if not hasKey(t, key): return false
|
||||||
if mget(t, key) != val: return false
|
if t[key] != val: return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc indexBy*[A, B, C](collection: A, index: proc(x: B): C): TTable[C, B] =
|
proc indexBy*[A, B, C](collection: A, index: proc(x: B): C): TTable[C, B] =
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ proc ftpClient*(address: string, port = TPort(21),
|
||||||
result.isAsync = false
|
result.isAsync = false
|
||||||
result.dsockConnected = false
|
result.dsockConnected = false
|
||||||
result.csock = socket()
|
result.csock = socket()
|
||||||
|
if result.csock == InvalidSocket: osError(osLastError())
|
||||||
|
|
||||||
proc getDSock(ftp: PFTPClient): TSocket =
|
proc getDSock(ftp: PFTPClient): TSocket =
|
||||||
if ftp.isAsync: return ftp.asyncDSock else: return ftp.dsock
|
if ftp.isAsync: return ftp.asyncDSock else: return ftp.dsock
|
||||||
|
|
@ -213,6 +214,7 @@ proc pasv(ftp: PFTPClient) =
|
||||||
## Negotiate a data connection.
|
## Negotiate a data connection.
|
||||||
if not ftp.isAsync:
|
if not ftp.isAsync:
|
||||||
ftp.dsock = socket()
|
ftp.dsock = socket()
|
||||||
|
if ftp.dsock == InvalidSocket: osError(osLastError())
|
||||||
else:
|
else:
|
||||||
ftp.asyncDSock = AsyncSocket()
|
ftp.asyncDSock = AsyncSocket()
|
||||||
ftp.asyncDSock.handleRead =
|
ftp.asyncDSock.handleRead =
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
## constructor should be used for this purpose. However,
|
## constructor should be used for this purpose. However,
|
||||||
## currently only basic authentication is supported.
|
## currently only basic authentication is supported.
|
||||||
|
|
||||||
import sockets, strutils, parseurl, parseutils, strtabs, base64
|
import sockets, strutils, parseurl, parseutils, strtabs, base64, os
|
||||||
import asyncnet, asyncdispatch
|
import asyncnet, asyncdispatch
|
||||||
import rawsockets
|
import rawsockets
|
||||||
|
|
||||||
|
|
@ -288,6 +288,7 @@ proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
|
||||||
add(headers, "\c\L")
|
add(headers, "\c\L")
|
||||||
|
|
||||||
var s = socket()
|
var s = socket()
|
||||||
|
if s == InvalidSocket: osError(osLastError())
|
||||||
var port = sockets.TPort(80)
|
var port = sockets.TPort(80)
|
||||||
if r.scheme == "https":
|
if r.scheme == "https":
|
||||||
when defined(ssl):
|
when defined(ssl):
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,7 @@ proc reconnect*(irc: PIRC, timeout = 5000) =
|
||||||
if secSinceReconnect < timeout:
|
if secSinceReconnect < timeout:
|
||||||
sleep(timeout - secSinceReconnect)
|
sleep(timeout - secSinceReconnect)
|
||||||
irc.sock = socket()
|
irc.sock = socket()
|
||||||
|
if irc.sock == InvalidSocket: osError(osLastError())
|
||||||
irc.connect()
|
irc.connect()
|
||||||
irc.lastReconnect = epochTime()
|
irc.lastReconnect = epochTime()
|
||||||
|
|
||||||
|
|
@ -274,6 +275,7 @@ proc irc*(address: string, port: TPort = 6667.TPort,
|
||||||
result.messageBuffer = @[]
|
result.messageBuffer = @[]
|
||||||
result.status = SockIdle
|
result.status = SockIdle
|
||||||
result.sock = socket()
|
result.sock = socket()
|
||||||
|
if result.sock == InvalidSocket: osError(osLastError())
|
||||||
|
|
||||||
proc processLine(irc: PIRC, line: string): TIRCEvent =
|
proc processLine(irc: PIRC, line: string): TIRCEvent =
|
||||||
if line.len == 0:
|
if line.len == 0:
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,14 @@ proc startProcess*(command: string,
|
||||||
## to `startProcess`. See the documentation of ``TProcessOption`` for the
|
## to `startProcess`. See the documentation of ``TProcessOption`` for the
|
||||||
## meaning of these flags. You need to `close` the process when done.
|
## meaning of these flags. You need to `close` the process when done.
|
||||||
##
|
##
|
||||||
|
## Note that you can't pass any `args` if you use the option
|
||||||
|
## ``poEvalCommand``, which invokes the system shell to run the specified
|
||||||
|
## `command`. In this situation you have to concatenate manually the contents
|
||||||
|
## of `args` to `command` carefully escaping/quoting any special characters,
|
||||||
|
## since it will be passed *as is* to the system shell. Each system/shell may
|
||||||
|
## feature different escaping rules, so try to avoid this kind of shell
|
||||||
|
## invokation if possible as it leads to non portable software.
|
||||||
|
##
|
||||||
## Return value: The newly created process object. Nil is never returned,
|
## Return value: The newly created process object. Nil is never returned,
|
||||||
## but ``EOS`` is raised in case of an error.
|
## but ``EOS`` is raised in case of an error.
|
||||||
|
|
||||||
|
|
@ -633,7 +641,7 @@ elif not defined(useNimRtl):
|
||||||
if poEvalCommand in options:
|
if poEvalCommand in options:
|
||||||
sysCommand = "/bin/sh"
|
sysCommand = "/bin/sh"
|
||||||
sysArgsRaw = @[sysCommand, "-c", command]
|
sysArgsRaw = @[sysCommand, "-c", command]
|
||||||
assert args.len == 0
|
assert args.len == 0, "`args` has to be empty when using poEvalCommand."
|
||||||
else:
|
else:
|
||||||
sysCommand = command
|
sysCommand = command
|
||||||
sysArgsRaw = @[command]
|
sysArgsRaw = @[command]
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ proc open*(s: var TScgiState, port = TPort(4000), address = "127.0.0.1",
|
||||||
s.input = newString(s.buflen) # will be reused
|
s.input = newString(s.buflen) # will be reused
|
||||||
|
|
||||||
s.server = socket()
|
s.server = socket()
|
||||||
|
if s.server == InvalidSocket: osError(osLastError())
|
||||||
new(s.client) # Initialise s.client for `next`
|
new(s.client) # Initialise s.client for `next`
|
||||||
if s.server == InvalidSocket: scgiError("could not open socket")
|
if s.server == InvalidSocket: scgiError("could not open socket")
|
||||||
#s.server.connect(connectionName, port)
|
#s.server.connect(connectionName, port)
|
||||||
|
|
|
||||||
|
|
@ -238,6 +238,7 @@ when isMainModule:
|
||||||
sock: TSocket
|
sock: TSocket
|
||||||
|
|
||||||
var sock = socket()
|
var sock = socket()
|
||||||
|
if sock == sockets.InvalidSocket: osError(osLastError())
|
||||||
#sock.setBlocking(false)
|
#sock.setBlocking(false)
|
||||||
sock.connect("irc.freenode.net", TPort(6667))
|
sock.connect("irc.freenode.net", TPort(6667))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ proc hash(data: pointer, size: int): THash =
|
||||||
while s > 0:
|
while s > 0:
|
||||||
h = h !& ord(p[i])
|
h = h !& ord(p[i])
|
||||||
inc(i)
|
inc(i)
|
||||||
cec(s)
|
dec(s)
|
||||||
result = !$h
|
result = !$h
|
||||||
|
|
||||||
proc hashGcHeader(data: pointer): THash =
|
proc hashGcHeader(data: pointer): THash =
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ const
|
||||||
SQLITE_IGNORE* = 2 # Original from sqlite3.h:
|
SQLITE_IGNORE* = 2 # Original from sqlite3.h:
|
||||||
##define SQLITE_STATIC ((void(*)(void *))0)
|
##define SQLITE_STATIC ((void(*)(void *))0)
|
||||||
##define SQLITE_TRANSIENT ((void(*)(void *))-1)
|
##define SQLITE_TRANSIENT ((void(*)(void *))-1)
|
||||||
|
SQLITE_DETERMINISTIC* = 0x800
|
||||||
|
|
||||||
const
|
const
|
||||||
SQLITE_STATIC* = nil
|
SQLITE_STATIC* = nil
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,21 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''0
|
output: '''8 5 0 0
|
||||||
pre test a:test b:1 c:2 haha:3
|
pre test a:test b:1 c:2 haha:3
|
||||||
assignment test a:test b:1 c:2 haha:3
|
assignment test a:test b:1 c:2 haha:3
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type TSomeObj = object of TObject
|
# bug #1005
|
||||||
Variable: int
|
|
||||||
|
type
|
||||||
|
TSomeObj = object of TObject
|
||||||
|
a, b: int
|
||||||
|
PSomeObj = ref object
|
||||||
|
a, b: int
|
||||||
|
|
||||||
var a = TSomeObj()
|
var a = TSomeObj(a: 8)
|
||||||
|
var b = PSomeObj(a: 5)
|
||||||
echo a.Variable.`$`
|
echo a.a, " ", b.a, " ", a.b, " ", b.b
|
||||||
|
|
||||||
# bug #575
|
# bug #575
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tasyncawait.nim"
|
file: "tasyncawait.nim"
|
||||||
cmd: "nimrod cc --hints:on $# $#"
|
|
||||||
output: "5000"
|
output: "5000"
|
||||||
"""
|
"""
|
||||||
import asyncdispatch, rawsockets, net, strutils, os
|
import asyncdispatch, rawsockets, net, strutils, os
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tasynciossl.nim"
|
file: "tasynciossl.nim"
|
||||||
cmd: "nimrod cc --hints:on --define:ssl $# $#"
|
cmd: "nimrod $target --hints:on --define:ssl $options $file"
|
||||||
output: "20000"
|
output: "20000"
|
||||||
"""
|
"""
|
||||||
import sockets, asyncio, strutils, times
|
import sockets, asyncio, strutils, times
|
||||||
|
|
@ -88,4 +88,4 @@ while true:
|
||||||
break
|
break
|
||||||
|
|
||||||
assert msgCount == (swarmSize * messagesToSend) * serverCount
|
assert msgCount == (swarmSize * messagesToSend) * serverCount
|
||||||
echo(msgCount)
|
echo(msgCount)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
outputsub: "101"
|
outputsub: "101"
|
||||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, locks
|
import os, locks
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
output: "Done"
|
output: "Done"
|
||||||
cmd: "nimrod cc --debuginfo --hints:on --define:useNimRtl $# $#"
|
cmd: "nimrod $target --debuginfo --hints:on --define:useNimRtl $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod cc --debuginfo --hints:on --define:useNimRtl --app:lib $# $#"
|
cmd: "nimrod $target --debuginfo --hints:on --define:useNimRtl --app:lib $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod check $# $#"
|
cmd: "nimrod check $options $file"
|
||||||
errormsg: "'proc' is not a concrete type"
|
errormsg: "'proc' is not a concrete type"
|
||||||
errormsg: "'Foo' is not a concrete type."
|
errormsg: "'Foo' is not a concrete type."
|
||||||
errormsg: "invalid type: 'TBaseMed'"
|
errormsg: "invalid type: 'TBaseMed'"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''true'''
|
output: '''true'''
|
||||||
cmd: "nimrod cc --gc:none --hints:on --warnings:off $# $#"
|
cmd: "nimrod $target --gc:none --hints:on --warnings:off $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import hashes
|
import hashes
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod js --hints:on $# $#"
|
cmd: "nimrod js --hints:on $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This file tests the JavaScript generator
|
# This file tests the JavaScript generator
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod js --hints:on $# $#"
|
|
||||||
output: "1261129"
|
output: "1261129"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod js --hints:on -r $# $#"
|
|
||||||
output: '''foo
|
output: '''foo
|
||||||
js 3.14'''
|
js 3.14'''
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod js --hints:on -r $# $#"
|
|
||||||
output: '''true'''
|
output: '''true'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
discard """
|
||||||
|
disabled: true
|
||||||
|
"""
|
||||||
import
|
import
|
||||||
gtk2, glib2, atk, gdk2, gdk2pixbuf, libglade2, pango,
|
gtk2, glib2, atk, gdk2, gdk2pixbuf, libglade2, pango,
|
||||||
pangoutils
|
pangoutils
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod cc --hints:on -d:release $# $#"
|
cmd: "nimrod $target --hints:on -d:release $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# -*- nimrod -*-
|
# -*- nimrod -*-
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''true'''
|
output: '''true'''
|
||||||
cmd: "nimrod cc --hints:on $# $#"
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import hashes, sets
|
import hashes, sets
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import sockets
|
import sockets, os
|
||||||
var s: TSocket
|
var s: TSocket
|
||||||
s = socket()
|
s = socket()
|
||||||
|
if s == InvalidSocket: osError(osLastError())
|
||||||
|
|
||||||
s.connect("www.google.com", TPort(80))
|
s.connect("www.google.com", TPort(80))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod cc --hints:on -d:embedUnidecodeTable $# $#"
|
cmd: "nimrod $target --hints:on -d:embedUnidecodeTable $options $file"
|
||||||
output: "Ausserst"
|
output: "Ausserst"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''true'''
|
output: '''true'''
|
||||||
cmd: "nimrod cc --hints:on $# $#"
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import hashes, tables
|
import hashes, tables
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''true'''
|
output: '''true'''
|
||||||
cmd: "nimrod cc --hints:on $# $#"
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import tables
|
import tables
|
||||||
|
|
|
||||||
|
|
@ -179,10 +179,12 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
|
||||||
|
|
||||||
for t in os.walkFiles("tests/js/t*.nim"):
|
for t in os.walkFiles("tests/js/t*.nim"):
|
||||||
test(t)
|
test(t)
|
||||||
for testfile in ["texceptions", "texcpt1", "texcsub", "tfinally",
|
for testfile in ["exception/texceptions", "exception/texcpt1",
|
||||||
"tfinally2", "tfinally3", "tactiontable", "tmultim1",
|
"exception/texcsub", "exception/tfinally",
|
||||||
"tmultim3", "tmultim4"]:
|
"exception/tfinally2", "exception/tfinally3",
|
||||||
test "tests/run/" & testfile & ".nim"
|
"actiontable/tactiontable", "method/tmultim1",
|
||||||
|
"method/tmultim3", "method/tmultim4"]:
|
||||||
|
test "tests/" & testfile & ".nim"
|
||||||
|
|
||||||
# ------------------------- manyloc -------------------------------------------
|
# ------------------------- manyloc -------------------------------------------
|
||||||
#proc runSpecialTests(r: var TResults, options: string) =
|
#proc runSpecialTests(r: var TResults, options: string) =
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
import parseutils, strutils, os, osproc, streams, parsecfg
|
import parseutils, strutils, os, osproc, streams, parsecfg
|
||||||
|
|
||||||
const
|
const
|
||||||
cmdTemplate* = r"nimrod cc --hints:on $# $#"
|
cmdTemplate* = r"nimrod $target --hints:on $options $file"
|
||||||
|
|
||||||
type
|
type
|
||||||
TTestAction* = enum
|
TTestAction* = enum
|
||||||
|
|
@ -51,6 +51,7 @@ type
|
||||||
|
|
||||||
const
|
const
|
||||||
targetToExt*: array[TTarget, string] = ["c", "cpp", "m", "js"]
|
targetToExt*: array[TTarget, string] = ["c", "cpp", "m", "js"]
|
||||||
|
targetToCmd*: array[TTarget, string] = ["c", "cpp", "objc", "js"]
|
||||||
|
|
||||||
when not defined(parseCfgBool):
|
when not defined(parseCfgBool):
|
||||||
# candidate for the stdlib:
|
# candidate for the stdlib:
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,10 @@ let
|
||||||
pegSuccess = peg"'Hint: operation successful'.*"
|
pegSuccess = peg"'Hint: operation successful'.*"
|
||||||
pegOfInterest = pegLineError / pegOtherError
|
pegOfInterest = pegLineError / pegOtherError
|
||||||
|
|
||||||
proc callCompiler(cmdTemplate, filename, options: string): TSpec =
|
proc callCompiler(cmdTemplate, filename, options: string,
|
||||||
let c = parseCmdLine(cmdTemplate % [options, filename])
|
target: TTarget): TSpec =
|
||||||
|
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
||||||
|
"options", options, "file", filename])
|
||||||
var p = startProcess(command=c[0], args=c[1.. -1],
|
var p = startProcess(command=c[0], args=c[1.. -1],
|
||||||
options={poStdErrToStdOut, poUseShell})
|
options={poStdErrToStdOut, poUseShell})
|
||||||
let outp = p.outputStream
|
let outp = p.outputStream
|
||||||
|
|
@ -111,10 +113,10 @@ proc addResult(r: var TResults, test: TTest,
|
||||||
r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success)
|
r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success)
|
||||||
if success notin {reSuccess, reIgnored}:
|
if success notin {reSuccess, reIgnored}:
|
||||||
styledEcho styleBright, name, fgRed, " [", $success, "]"
|
styledEcho styleBright, name, fgRed, " [", $success, "]"
|
||||||
styledEcho styleDim, "EXPECTED:"
|
echo"Expected:"
|
||||||
echo expected
|
styledEcho styleBright, expected
|
||||||
styledEcho styleDim, "GIVEN:"
|
echo"Given:"
|
||||||
echo given
|
styledEcho styleBright, given
|
||||||
|
|
||||||
proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
|
proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
|
||||||
if strip(expected.msg) notin strip(given.msg):
|
if strip(expected.msg) notin strip(given.msg):
|
||||||
|
|
@ -152,7 +154,7 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||||
# major entry point for a single test
|
# major entry point for a single test
|
||||||
let tname = test.name.addFileExt(".nim")
|
let tname = test.name.addFileExt(".nim")
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
echo extractFilename(tname)
|
styledEcho "Processing ", fgCyan, extractFilename(tname)
|
||||||
var expected = parseSpec(tname)
|
var expected = parseSpec(tname)
|
||||||
if expected.err == reIgnored:
|
if expected.err == reIgnored:
|
||||||
r.addResult(test, "", "", reIgnored)
|
r.addResult(test, "", "", reIgnored)
|
||||||
|
|
@ -160,13 +162,15 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||||
else:
|
else:
|
||||||
case expected.action
|
case expected.action
|
||||||
of actionCompile:
|
of actionCompile:
|
||||||
var given = callCompiler(expected.cmd, test.name, test.options)
|
var given = callCompiler(expected.cmd, test.name, test.options,
|
||||||
|
test.target)
|
||||||
if given.err == reSuccess:
|
if given.err == reSuccess:
|
||||||
codegenCheck(test, expected.ccodeCheck, given)
|
codegenCheck(test, expected.ccodeCheck, given)
|
||||||
r.addResult(test, "", given.msg, given.err)
|
r.addResult(test, "", given.msg, given.err)
|
||||||
if given.err == reSuccess: inc(r.passed)
|
if given.err == reSuccess: inc(r.passed)
|
||||||
of actionRun:
|
of actionRun:
|
||||||
var given = callCompiler(expected.cmd, test.name, test.options)
|
var given = callCompiler(expected.cmd, test.name, test.options,
|
||||||
|
test.target)
|
||||||
if given.err != reSuccess:
|
if given.err != reSuccess:
|
||||||
r.addResult(test, "", given.msg, given.err)
|
r.addResult(test, "", given.msg, given.err)
|
||||||
else:
|
else:
|
||||||
|
|
@ -176,10 +180,13 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||||
exeFile = dir / "nimcache" / file & ".js"
|
exeFile = dir / "nimcache" / file & ".js"
|
||||||
else:
|
else:
|
||||||
exeFile = changeFileExt(tname, ExeExt)
|
exeFile = changeFileExt(tname, ExeExt)
|
||||||
|
|
||||||
if existsFile(exeFile):
|
if existsFile(exeFile):
|
||||||
|
if test.target == targetJS and findExe("nodejs") == "":
|
||||||
|
r.addResult(test, expected.outp, "nodejs binary not in PATH",
|
||||||
|
reExeNotFound)
|
||||||
|
return
|
||||||
var (buf, exitCode) = execCmdEx(
|
var (buf, exitCode) = execCmdEx(
|
||||||
(if test.target==targetJS: "node " else: "") & exeFile)
|
(if test.target == targetJS: "nodejs " else: "") & exeFile)
|
||||||
if exitCode != expected.ExitCode:
|
if exitCode != expected.ExitCode:
|
||||||
r.addResult(test, "exitcode: " & $expected.exitCode,
|
r.addResult(test, "exitcode: " & $expected.exitCode,
|
||||||
"exitcode: " & $exitCode, reExitCodesDiffer)
|
"exitcode: " & $exitCode, reExitCodesDiffer)
|
||||||
|
|
@ -194,7 +201,8 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||||
else:
|
else:
|
||||||
r.addResult(test, expected.outp, "executable not found", reExeNotFound)
|
r.addResult(test, expected.outp, "executable not found", reExeNotFound)
|
||||||
of actionReject:
|
of actionReject:
|
||||||
var given = callCompiler(expected.cmd, test.name, test.options)
|
var given = callCompiler(expected.cmd, test.name, test.options,
|
||||||
|
test.target)
|
||||||
cmpMsgs(r, expected, given, test)
|
cmpMsgs(r, expected, given, test)
|
||||||
|
|
||||||
proc testNoSpec(r: var TResults, test: TTest) =
|
proc testNoSpec(r: var TResults, test: TTest) =
|
||||||
|
|
@ -202,7 +210,7 @@ proc testNoSpec(r: var TResults, test: TTest) =
|
||||||
let tname = test.name.addFileExt(".nim")
|
let tname = test.name.addFileExt(".nim")
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
echo extractFilename(tname)
|
echo extractFilename(tname)
|
||||||
let given = callCompiler(cmdTemplate, test.name, test.options)
|
let given = callCompiler(cmdTemplate, test.name, test.options, test.target)
|
||||||
r.addResult(test, "", given.msg, given.err)
|
r.addResult(test, "", given.msg, given.err)
|
||||||
if given.err == reSuccess: inc(r.passed)
|
if given.err == reSuccess: inc(r.passed)
|
||||||
|
|
||||||
|
|
@ -223,7 +231,7 @@ proc main() =
|
||||||
os.putenv "NIMTEST_NO_COLOR", "1"
|
os.putenv "NIMTEST_NO_COLOR", "1"
|
||||||
os.putenv "NIMTEST_OUTPUT_LVL", "PRINT_FAILURES"
|
os.putenv "NIMTEST_OUTPUT_LVL", "PRINT_FAILURES"
|
||||||
|
|
||||||
backend.open()
|
backend.open()
|
||||||
var optPrintResults = false
|
var optPrintResults = false
|
||||||
var p = initOptParser()
|
var p = initOptParser()
|
||||||
p.next()
|
p.next()
|
||||||
|
|
@ -238,9 +246,12 @@ proc main() =
|
||||||
var r = initResults()
|
var r = initResults()
|
||||||
case action
|
case action
|
||||||
of "all":
|
of "all":
|
||||||
for kind, dir in walkDir("tests"):
|
let testsDir = "tests" & dirSep
|
||||||
if kind == pcDir and dir notin ["testament", "testdata", "nimcache"]:
|
for kind, dir in walkDir(testsDir):
|
||||||
processCategory(r, Category(dir), p.cmdLineRest.string)
|
assert testsDir.startsWith(testsDir)
|
||||||
|
let cat = dir[testsDir.len .. -1]
|
||||||
|
if kind == pcDir and cat notin ["testament", "testdata", "nimcache"]:
|
||||||
|
processCategory(r, Category(cat), p.cmdLineRest.string)
|
||||||
for a in AdditionalCategories:
|
for a in AdditionalCategories:
|
||||||
processCategory(r, Category(a), p.cmdLineRest.string)
|
processCategory(r, Category(a), p.cmdLineRest.string)
|
||||||
of "c", "cat", "category":
|
of "c", "cat", "category":
|
||||||
|
|
@ -255,11 +266,11 @@ proc main() =
|
||||||
else:
|
else:
|
||||||
quit usage
|
quit usage
|
||||||
|
|
||||||
if optPrintResults:
|
if optPrintResults:
|
||||||
if action == "html": openDefaultBrowser(resultsFile)
|
if action == "html": openDefaultBrowser(resultsFile)
|
||||||
else: echo r, r.data
|
else: echo r, r.data
|
||||||
backend.close()
|
backend.close()
|
||||||
|
|
||||||
if paramCount() == 0:
|
if paramCount() == 0:
|
||||||
quit usage
|
quit usage
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ discard """
|
||||||
outputsub: "101"
|
outputsub: "101"
|
||||||
msg: "Warning: write to foreign heap"
|
msg: "Warning: write to foreign heap"
|
||||||
line: 37
|
line: 37
|
||||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ discard """
|
||||||
file: "tthreadanalysis2.nim"
|
file: "tthreadanalysis2.nim"
|
||||||
line: 42
|
line: 42
|
||||||
errormsg: "write to foreign heap"
|
errormsg: "write to foreign heap"
|
||||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ discard """
|
||||||
file: "tthreadanalysis3.nim"
|
file: "tthreadanalysis3.nim"
|
||||||
line: 35
|
line: 35
|
||||||
errormsg: "write to foreign heap"
|
errormsg: "write to foreign heap"
|
||||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
line: 12
|
line: 12
|
||||||
errormsg: "write to foreign heap"
|
errormsg: "write to foreign heap"
|
||||||
cmd: "nimrod cc --hints:on --threads:on $# $#"
|
cmd: "nimrod $target --hints:on --threads:on $options $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nimrod c --threads:on $# $#"
|
cmd: "nimrod $target --threads:on $options $file"
|
||||||
errormsg: "illegal recursion in type 'TIRC'"
|
errormsg: "illegal recursion in type 'TIRC'"
|
||||||
line: 16
|
line: 16
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue