commit
61ff329337
5 changed files with 93 additions and 22 deletions
|
|
@ -128,12 +128,19 @@ proc rejectThreadTests(r: var TResults, options: string) =
|
|||
rejectSingleTest(r, "tests/threads/tthreadanalysis3", options)
|
||||
rejectSingleTest(r, "tests/threads/tthreadheapviolation1", options)
|
||||
|
||||
# ------------------------- IO tests -----------------------------------
|
||||
|
||||
proc runIOTests(r: var TResults, options: string) =
|
||||
compileSingleTest(r, "tests/system/helpers/readall_echo.nim", options)
|
||||
runSingleTest(r, "tests/system/io", options)
|
||||
|
||||
# ------------------------- register special tests here -----------------------
|
||||
proc runSpecialTests(r: var TResults, options: string) =
|
||||
runRodFiles(r, options)
|
||||
runDLLTests(r, options)
|
||||
runGCTests(r, options)
|
||||
runThreadTests(r, options & " --threads:on")
|
||||
runIOTests(r, options)
|
||||
|
||||
proc rejectSpecialTests(r: var TResults, options: string) =
|
||||
rejectThreadTests(r, options)
|
||||
|
|
|
|||
1
tests/system/helpers/readall_echo.nim
Normal file
1
tests/system/helpers/readall_echo.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
echo(stdin.readAll)
|
||||
29
tests/system/io.nim
Normal file
29
tests/system/io.nim
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
discard """output: '''[OK] stdin
|
||||
|
||||
[OK] file'''"""
|
||||
|
||||
import
|
||||
unittest, osproc, streams, os, readall_echo
|
||||
const STRING_DATA = """Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."""
|
||||
const TEST_FILE = "tests/testdata/string"
|
||||
|
||||
proc echoLoop(str: string): string =
|
||||
result = ""
|
||||
var process = startProcess(os.addFileExt("tests/system/helpers/readall_echo", ExeExt))
|
||||
var input = process.inputStream
|
||||
input.write(str)
|
||||
input.close()
|
||||
var output = process.outputStream
|
||||
discard process.waitForExit
|
||||
while not output.atEnd:
|
||||
result.add(output.readLine)
|
||||
|
||||
suite "io":
|
||||
suite "readAll":
|
||||
test "stdin":
|
||||
check:
|
||||
echoLoop(STRING_DATA) == STRING_DATA
|
||||
echoLoop(STRING_DATA[0..3999]) == STRING_DATA[0..3999]
|
||||
test "file":
|
||||
check:
|
||||
readFile(TEST_FILE) == STRING_DATA
|
||||
Loading…
Add table
Add a link
Reference in a new issue