make tests green again
This commit is contained in:
parent
e06a89e112
commit
f078f272e5
4 changed files with 16 additions and 9 deletions
|
|
@ -59,6 +59,7 @@ build_script:
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- tests\testament\tester --pedantic all -d:nimCoroutines
|
- tests\testament\tester --pedantic all -d:nimCoroutines
|
||||||
|
- nim c -r nimdoc\tester
|
||||||
# - koch csource
|
# - koch csource
|
||||||
# - koch zip
|
# - koch zip
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
|
|
||||||
## Layouter for nimpretty.
|
## Layouter for nimpretty.
|
||||||
|
|
||||||
import idents, lexer, lineinfos, llstream, options, msgs, strutils
|
import idents, lexer, lineinfos, llstream, options, msgs, strutils,
|
||||||
|
pathutils
|
||||||
from os import changeFileExt
|
from os import changeFileExt
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -39,7 +40,7 @@ type
|
||||||
|
|
||||||
proc openEmitter*(em: var Emitter, cache: IdentCache;
|
proc openEmitter*(em: var Emitter, cache: IdentCache;
|
||||||
config: ConfigRef, fileIdx: FileIndex) =
|
config: ConfigRef, fileIdx: FileIndex) =
|
||||||
let fullPath = config.toFullPath(fileIdx)
|
let fullPath = Absolutefile config.toFullPath(fileIdx)
|
||||||
em.indWidth = getIndentWidth(fileIdx, llStreamOpen(fullPath, fmRead),
|
em.indWidth = getIndentWidth(fileIdx, llStreamOpen(fullPath, fmRead),
|
||||||
cache, config)
|
cache, config)
|
||||||
if em.indWidth == 0: em.indWidth = 2
|
if em.indWidth == 0: em.indWidth = 2
|
||||||
|
|
@ -55,7 +56,7 @@ proc openEmitter*(em: var Emitter, cache: IdentCache;
|
||||||
proc closeEmitter*(em: var Emitter) =
|
proc closeEmitter*(em: var Emitter) =
|
||||||
var f = llStreamOpen(em.config.outFile, fmWrite)
|
var f = llStreamOpen(em.config.outFile, fmWrite)
|
||||||
if f == nil:
|
if f == nil:
|
||||||
rawMessage(em.config, errGenerated, "cannot open file: " & em.config.outFile)
|
rawMessage(em.config, errGenerated, "cannot open file: " & em.config.outFile.string)
|
||||||
f.llStreamWrite em.content
|
f.llStreamWrite em.content
|
||||||
llStreamClose(f)
|
llStreamClose(f)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,11 +111,12 @@ proc canon(x: string; result: var string; state: var int) =
|
||||||
# f/..
|
# f/..
|
||||||
while d > (state and 1) and result[d-1] != DirSep:
|
while d > (state and 1) and result[d-1] != DirSep:
|
||||||
dec d
|
dec d
|
||||||
setLen(result, d)
|
setLen(result, d-1)
|
||||||
elif isDot(x, b):
|
elif isDot(x, b):
|
||||||
discard "discard the dot"
|
discard "discard the dot"
|
||||||
else:
|
elif b[1] > b[0]:
|
||||||
if result.len > (state and 1): result.add DirSep
|
if result.len > 0 and result[^1] != DirSep:
|
||||||
|
result.add DirSep
|
||||||
result.add substr(x, b[0], b[1])
|
result.add substr(x, b[0], b[1])
|
||||||
inc state, 2
|
inc state, 2
|
||||||
|
|
||||||
|
|
@ -253,3 +254,7 @@ when isMainModule and defined(posix):
|
||||||
|
|
||||||
doAssert AbsoluteDir"/Users/me///" / RelativeFile"z.nim" == AbsoluteFile"/Users/me/z.nim"
|
doAssert AbsoluteDir"/Users/me///" / RelativeFile"z.nim" == AbsoluteFile"/Users/me/z.nim"
|
||||||
doAssert relativeTo("/foo/bar.nim", "/foo/") == "bar.nim"
|
doAssert relativeTo("/foo/bar.nim", "/foo/") == "bar.nim"
|
||||||
|
|
||||||
|
when isMainModule and defined(windows):
|
||||||
|
let nasty = string(AbsoluteDir(r"C:\Users\rumpf\projects\nim\tests\nimble\nimbleDir\linkedPkgs\pkgB-#head\../../simplePkgs/pkgB-#head/") / RelativeFile"pkgA/module.nim")
|
||||||
|
doAssert nasty == r"C:\Users\rumpf\projects\nim\tests\nimble\nimbleDir\simplePkgs\pkgB-#head\pkgA\module.nim"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
when not defined(nimpretty):
|
when not defined(nimpretty):
|
||||||
{.error: "This needs to be compiled with --define:nimPretty".}
|
{.error: "This needs to be compiled with --define:nimPretty".}
|
||||||
|
|
||||||
import ../compiler / [idents, msgs, ast, syntaxes, renderer, options]
|
import ../compiler / [idents, msgs, ast, syntaxes, renderer, options, pathutils]
|
||||||
|
|
||||||
import parseopt, strutils, os
|
import parseopt, strutils, os
|
||||||
|
|
||||||
|
|
@ -42,8 +42,8 @@ proc writeVersion() =
|
||||||
|
|
||||||
proc prettyPrint(infile, outfile: string) =
|
proc prettyPrint(infile, outfile: string) =
|
||||||
var conf = newConfigRef()
|
var conf = newConfigRef()
|
||||||
let fileIdx = fileInfoIdx(conf, infile)
|
let fileIdx = fileInfoIdx(conf, AbsoluteFile infile)
|
||||||
conf.outFile = outfile
|
conf.outFile = AbsoluteFile outfile
|
||||||
when defined(nimpretty2):
|
when defined(nimpretty2):
|
||||||
discard parseFile(fileIdx, newIdentCache(), conf)
|
discard parseFile(fileIdx, newIdentCache(), conf)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue