Merge branch 'devel' of github.com:nim-lang/Nim into devel

This commit is contained in:
Araq 2018-01-14 17:34:48 +01:00
commit bba6d62420
4 changed files with 15 additions and 12 deletions

View file

@ -41,7 +41,7 @@ Save this code to the file "greetings.nim". Now compile and run it::
nim compile --run greetings.nim nim compile --run greetings.nim
With the ``--run`` `switch <nimc.html#command-line-switches>`_ Nim With the ``--run`` `switch <nimc.html#compiler-usage-command-line-switches>`_ Nim
executes the file automatically after compilation. You can give your program executes the file automatically after compilation. You can give your program
command line arguments by appending them after the filename:: command line arguments by appending them after the filename::
@ -58,7 +58,7 @@ To compile a release version use::
By default the Nim compiler generates a large amount of runtime checks By default the Nim compiler generates a large amount of runtime checks
aiming for your debugging pleasure. With ``-d:release`` these checks are aiming for your debugging pleasure. With ``-d:release`` these checks are
`turned off and optimizations are turned on `turned off and optimizations are turned on
<nimc.html#compile-time-symbols>`_. <nimc.html#compiler-usage-compile-time-symbols>`_.
Though it should be pretty obvious what the program does, I will explain the Though it should be pretty obvious what the program does, I will explain the
syntax: statements which are not indented are executed when the program syntax: statements which are not indented are executed when the program

View file

@ -417,6 +417,7 @@ template fmt*(pattern: string): untyped =
## ##
## let example = "oh, look no conflicts anymore" ## let example = "oh, look no conflicts anymore"
## echo fmt"{example}" ## echo fmt"{example}"
bind `%`
%pattern %pattern
proc mkDigit(v: int, typ: char): string {.inline.} = proc mkDigit(v: int, typ: char): string {.inline.} =

View file

@ -17,11 +17,12 @@ const
rodfilesDir = "tests/rodfiles" rodfilesDir = "tests/rodfiles"
proc delNimCache(filename, options: string) = proc delNimCache(filename, options: string) =
let dir = nimcacheDir(filename, options) for target in low(TTarget)..high(TTarget):
try: let dir = nimcacheDir(filename, options, target)
removeDir(dir) try:
except OSError: removeDir(dir)
echo "[Warning] could not delete: ", dir except OSError:
echo "[Warning] could not delete: ", dir
proc runRodFiles(r: var TResults, cat: Category, options: string) = proc runRodFiles(r: var TResults, cat: Category, options: string) =
template test(filename: string, clearCacheFirst=false) = template test(filename: string, clearCacheFirst=false) =

View file

@ -71,13 +71,14 @@ proc getFileDir(filename: string): string =
if not result.isAbsolute(): if not result.isAbsolute():
result = getCurrentDir() / result result = getCurrentDir() / result
proc nimcacheDir(filename, options: string): string = proc nimcacheDir(filename, options: string, target: TTarget): string =
## Give each test a private nimcache dir so they don't clobber each other's. ## Give each test a private nimcache dir so they don't clobber each other's.
return "nimcache" / (filename & '_' & options.getMD5) let hashInput = options & $target
return "nimcache" / (filename & '_' & hashInput.getMD5)
proc callCompiler(cmdTemplate, filename, options: string, proc callCompiler(cmdTemplate, filename, options: string,
target: TTarget, extraOptions=""): TSpec = target: TTarget, extraOptions=""): TSpec =
let nimcache = nimcacheDir(filename, options) let nimcache = nimcacheDir(filename, options, target)
let options = options & " --nimCache:" & nimcache.quoteShell & extraOptions let options = options & " --nimCache:" & nimcache.quoteShell & extraOptions
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target], let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
"options", options, "file", filename.quoteShell, "options", options, "file", filename.quoteShell,
@ -231,7 +232,7 @@ proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest, target: TTarg
proc generatedFile(test: TTest, target: TTarget): string = proc generatedFile(test: TTest, target: TTarget): string =
let (_, name, _) = test.name.splitFile let (_, name, _) = test.name.splitFile
let ext = targetToExt[target] let ext = targetToExt[target]
result = nimcacheDir(test.name, test.options) / result = nimcacheDir(test.name, test.options, target) /
(if target == targetJS: "" else: "compiler_") & (if target == targetJS: "" else: "compiler_") &
name.changeFileExt(ext) name.changeFileExt(ext)
@ -334,7 +335,7 @@ proc testSpec(r: var TResults, test: TTest, target = targetC) =
var exeFile: string var exeFile: string
if isJsTarget: if isJsTarget:
let (_, file, _) = splitFile(tname) let (_, file, _) = splitFile(tname)
exeFile = nimcacheDir(test.name, test.options) / file & ".js" exeFile = nimcacheDir(test.name, test.options, target) / file & ".js"
else: else:
exeFile = changeFileExt(tname, ExeExt) exeFile = changeFileExt(tname, ExeExt)