#20 Add test file os property

This commit is contained in:
deme 2018-10-17 13:59:49 +02:00
parent c6c25ef652
commit 8b9e508a0f
5 changed files with 16 additions and 6 deletions

View File

@ -23,6 +23,9 @@ your own timestamp peg here.
should be expected.
- **error_file**: When expecting a compilation failure, the source file where the
error should occur.
- **os**: Space and/or comma separated list of operating systems for which the
test should be run. Defaults to `"linux, macosx, windows"`. Tests meant for a
different OS than the host will be marked as `SKIPPED`.
- **--skip**: This will simply skip the test (will not be marked as failure).
### Forwarded Options

View File

@ -1,13 +1,12 @@
; NativeColors on Unix will give AnsiColors
; To make this test work on both Unix and Windows we would need a flag where
; we can set the OS to test for or test on different outputs per OS
; For now, this test should only be run on Unix, as it will fail on Windows
program=long_lines
chronicles_sinks="textlines[stdout]"
chronicles_colors=NativeColors
chronicles_timestamps=None
os="Linux MacOSX"
[Output]
stdout="""INF long info  thread=0 file=long_lines.nim:10 str="some multiline\nstring\nmore lines"
WRN long warning  thread=0 str="some multiline\nstring\nmore lines"

View File

@ -1,10 +1,11 @@
--skip
; NativeColors test for Windows 7, actually just compares the non colored output
; NativeColors test for Windows, actually just compares the non colored output
program=long_lines
chronicles_sinks="textlines[stdout]"
chronicles_colors=NativeColors
chronicles_timestamps=None
os=Windows
[Output]
stdout="""INF long info thread=0 file=long_lines.nim:10 str="some multiline\nstring\nmore lines"
WRN long warning thread=0 str="some multiline\nstring\nmore lines"

View File

@ -26,6 +26,7 @@ type
errorFile*: string
errorLine*: int
errorColumn*: int
os*: seq[string]
proc processArguments*(): TestConfig =
var opt = initOptParser()
@ -47,7 +48,11 @@ proc processArguments*(): TestConfig =
if result.path == "":
quit(Usage)
proc defaults(result: var TestSpec) =
result.os = @["linux", "macosx", "windows"]
proc parseTestFile*(filePath:string): TestSpec =
result.defaults()
result.name = extractFilename(filePath)
var f = newFileStream(filePath, fmRead)
var outputSection = false
@ -81,6 +86,8 @@ proc parseTestFile*(filePath:string): TestSpec =
result.compileError = e.value
of "error_file":
result.errorFile = e.value
of "os":
result.os = e.value.normalize.split({','} + Whitespace)
else:
result.flags &= ("-d:$#:$#" % [e.key, e.value]).quoteShell & " "
of cfgOption:

View File

@ -187,7 +187,7 @@ proc test(testPath: string): TestStatus =
if test.program.len == 0: # a program name is bare minimum of a test file
result = INVALID
break
if test.skip:
if test.skip or hostOS notin test.os:
result = SKIPPED
break