Make caasdriver compile

This commit is contained in:
def 2015-01-20 14:21:49 +01:00
commit d2ef99071c

View file

@ -1,4 +1,5 @@
import osproc, streams, os, strutils, re import osproc, streams, os, strutils, re
{.experimental.}
## Compiler as a service tester. ## Compiler as a service tester.
## ##
@ -10,7 +11,7 @@ type
ProcRun, CaasRun, SymbolProcRun ProcRun, CaasRun, SymbolProcRun
NimSession* = object NimSession* = object
nim: PProcess # Holds the open process for CaasRun sessions, nil otherwise. nim: Process # Holds the open process for CaasRun sessions, nil otherwise.
mode: TRunMode # Stores the type of run mode the session was started with. mode: TRunMode # Stores the type of run mode the session was started with.
lastOutput: string # Preserves the last output, needed for ProcRun mode. lastOutput: string # Preserves the last output, needed for ProcRun mode.
filename: string # Appended to each command starting with '>'. Also a var. filename: string # Appended to each command starting with '>'. Also a var.
@ -70,8 +71,10 @@ proc doCaasCommand(session: var NimSession, command: string): string =
break break
proc doProcCommand(session: var NimSession, command: string): string = proc doProcCommand(session: var NimSession, command: string): string =
assert session.mode == ProcRun or session.mode == SymbolProcRun try:
except: result = "FAILED TO EXECUTE: " & command & "\n" & result assert session.mode == ProcRun or session.mode == SymbolProcRun
except:
result = "FAILED TO EXECUTE: " & command & "\n" & result
var var
process = startProcess(NimBin, args = session.replaceVars(command).split) process = startProcess(NimBin, args = session.replaceVars(command).split)
stream = outputStream(process) stream = outputStream(process)
@ -102,11 +105,11 @@ proc doCommand(session: var NimSession, command: string) =
session.lastOutput = doProcCommand(session, session.lastOutput = doProcCommand(session,
command & " " & session.filename) command & " " & session.filename)
proc close(session: var NimSession) {.destructor.} = proc destroy(session: var NimSession) {.destructor.} =
if session.mode == CaasRun: if session.mode == CaasRun:
session.nim.close session.nim.close
proc doScenario(script: string, output: PStream, mode: TRunMode, verbose: bool): bool = proc doScenario(script: string, output: Stream, mode: TRunMode, verbose: bool): bool =
result = true result = true
var f = open(script) var f = open(script)
@ -171,7 +174,7 @@ when isMainModule:
failures = 0 failures = 0
verbose = false verbose = false
for i in 0..ParamCount() - 1: for i in 0..paramCount() - 1:
let param = string(paramStr(i + 1)) let param = string(paramStr(i + 1))
case param case param
of "verbose": verbose = true of "verbose": verbose = true