Merge branch 'devel' into faster-nimsuggest
This commit is contained in:
commit
b935eeb997
9 changed files with 56 additions and 6 deletions
|
|
@ -46,6 +46,8 @@
|
||||||
##
|
##
|
||||||
## **Warning:** The global list of handlers is a thread var, this means that
|
## **Warning:** The global list of handlers is a thread var, this means that
|
||||||
## the handlers must be re-added in each thread.
|
## the handlers must be re-added in each thread.
|
||||||
|
## **Warning:** When logging on disk or console, only error and fatal messages
|
||||||
|
## are flushed out immediately. Use flushFile() where needed.
|
||||||
|
|
||||||
import strutils, times
|
import strutils, times
|
||||||
when not defined(js):
|
when not defined(js):
|
||||||
|
|
|
||||||
|
|
@ -898,7 +898,7 @@ proc toHex*(x: BiggestInt, len: Positive): string {.noSideEffect,
|
||||||
|
|
||||||
proc toHex*[T](x: T): string =
|
proc toHex*[T](x: T): string =
|
||||||
## Shortcut for ``toHex(x, T.sizeOf * 2)``
|
## Shortcut for ``toHex(x, T.sizeOf * 2)``
|
||||||
toHex(x, T.sizeOf * 2)
|
toHex(BiggestInt(x), T.sizeOf * 2)
|
||||||
|
|
||||||
proc intToStr*(x: int, minchars: Positive = 1): string {.noSideEffect,
|
proc intToStr*(x: int, minchars: Positive = 1): string {.noSideEffect,
|
||||||
rtl, extern: "nsuIntToStr".} =
|
rtl, extern: "nsuIntToStr".} =
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
## echo "run before each test"
|
## echo "run before each test"
|
||||||
##
|
##
|
||||||
## teardown:
|
## teardown:
|
||||||
## echo "run after each test":
|
## echo "run after each test"
|
||||||
##
|
##
|
||||||
## test "essential truths":
|
## test "essential truths":
|
||||||
## # give up and stop if this fails
|
## # give up and stop if this fails
|
||||||
|
|
|
||||||
|
|
@ -2743,6 +2743,7 @@ when not defined(JS): #and not defined(nimscript):
|
||||||
# we use binary mode on Windows:
|
# we use binary mode on Windows:
|
||||||
c_setmode(c_fileno(stdin), O_BINARY)
|
c_setmode(c_fileno(stdin), O_BINARY)
|
||||||
c_setmode(c_fileno(stdout), O_BINARY)
|
c_setmode(c_fileno(stdout), O_BINARY)
|
||||||
|
c_setmode(c_fileno(stderr), O_BINARY)
|
||||||
|
|
||||||
when defined(endb):
|
when defined(endb):
|
||||||
proc endbStep()
|
proc endbStep()
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
import strutils
|
|
||||||
let x = stdin.readLine()
|
|
||||||
echo x.parseInt + 5
|
|
||||||
5
tests/osproc/ta_in.nim
Normal file
5
tests/osproc/ta_in.nim
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# This file is prefixed with an "a", because other tests
|
||||||
|
# depend on it and it must be compiled first.
|
||||||
|
import strutils
|
||||||
|
let x = stdin.readLine()
|
||||||
|
echo x.parseInt + 5
|
||||||
16
tests/osproc/ta_out.nim
Normal file
16
tests/osproc/ta_out.nim
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# This file is prefixed with an "a", because other tests
|
||||||
|
# depend on it and it must be compiled first.
|
||||||
|
stdout.writeLine("to stdout")
|
||||||
|
stdout.flushFile()
|
||||||
|
stdout.writeLine("to stdout")
|
||||||
|
stdout.flushFile()
|
||||||
|
|
||||||
|
stderr.writeLine("to stderr")
|
||||||
|
stderr.flushFile()
|
||||||
|
stderr.writeLine("to stderr")
|
||||||
|
stderr.flushFile()
|
||||||
|
|
||||||
|
stdout.writeLine("to stdout")
|
||||||
|
stdout.flushFile()
|
||||||
|
stdout.writeLine("to stdout")
|
||||||
|
stdout.flushFile()
|
||||||
|
|
@ -4,7 +4,7 @@ discard """
|
||||||
"""
|
"""
|
||||||
import osproc, os, streams
|
import osproc, os, streams
|
||||||
|
|
||||||
const filename = when defined(Windows): "ta.exe" else: "ta"
|
const filename = when defined(Windows): "ta_in.exe" else: "ta_in"
|
||||||
|
|
||||||
doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
|
doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
|
||||||
|
|
||||||
|
|
|
||||||
29
tests/osproc/tstdout.nim
Normal file
29
tests/osproc/tstdout.nim
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
discard """
|
||||||
|
output: '''--------------------------------------
|
||||||
|
to stdout
|
||||||
|
to stdout
|
||||||
|
to stderr
|
||||||
|
to stderr
|
||||||
|
to stdout
|
||||||
|
to stdout
|
||||||
|
--------------------------------------
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
import osproc, os, streams
|
||||||
|
|
||||||
|
const filename = when defined(Windows): "ta_out.exe" else: "ta_out"
|
||||||
|
|
||||||
|
doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
|
||||||
|
|
||||||
|
var p = startProcess(filename, getCurrentDir() / "tests" / "osproc",
|
||||||
|
options={poStdErrToStdOut})
|
||||||
|
|
||||||
|
let outputStream = p.outputStream
|
||||||
|
var x = newStringOfCap(120)
|
||||||
|
var output = ""
|
||||||
|
while outputStream.readLine(x.TaintedString):
|
||||||
|
output.add(x & "\n")
|
||||||
|
|
||||||
|
echo "--------------------------------------"
|
||||||
|
stdout.write output
|
||||||
|
echo "--------------------------------------"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue