attempt to add valgrind support to the CIs and testament (#12646)
* attempt to add valgrind support to the CIs and testament * valgrind (currently) works only on 64-bit Linux
This commit is contained in:
parent
58f3e07b1a
commit
223e65e529
5 changed files with 29 additions and 8 deletions
|
|
@ -51,6 +51,8 @@ addons:
|
||||||
- libsdl1.2-dev
|
- libsdl1.2-dev
|
||||||
- libgc-dev
|
- libgc-dev
|
||||||
- libsfml-dev
|
- libsfml-dev
|
||||||
|
- libc6-dbg
|
||||||
|
- valgrind
|
||||||
homebrew:
|
homebrew:
|
||||||
packages:
|
packages:
|
||||||
- boehmgc
|
- boehmgc
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ steps:
|
||||||
sudo apt-fast update -qq
|
sudo apt-fast update -qq
|
||||||
DEBIAN_FRONTEND='noninteractive' \
|
DEBIAN_FRONTEND='noninteractive' \
|
||||||
sudo apt-fast install --no-install-recommends -yq \
|
sudo apt-fast install --no-install-recommends -yq \
|
||||||
libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev
|
libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev valgrind libc6-dbg
|
||||||
displayName: 'Install dependencies (amd64 Linux)'
|
displayName: 'Install dependencies (amd64 Linux)'
|
||||||
condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'amd64'))
|
condition: and(eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'amd64'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ type
|
||||||
nimout*: string
|
nimout*: string
|
||||||
parseErrors*: string # when the spec definition is invalid, this is not empty.
|
parseErrors*: string # when the spec definition is invalid, this is not empty.
|
||||||
unjoinable*: bool
|
unjoinable*: bool
|
||||||
|
useValgrind*: bool
|
||||||
timeout*: float # in seconds, fractions possible,
|
timeout*: float # in seconds, fractions possible,
|
||||||
# but don't rely on much precision
|
# but don't rely on much precision
|
||||||
|
|
||||||
|
|
@ -195,6 +196,14 @@ proc parseSpec*(filename: string): TSpec =
|
||||||
result.nimout = e.value
|
result.nimout = e.value
|
||||||
of "joinable":
|
of "joinable":
|
||||||
result.unjoinable = not parseCfgBool(e.value)
|
result.unjoinable = not parseCfgBool(e.value)
|
||||||
|
of "valgrind":
|
||||||
|
when defined(linux) and sizeof(int) == 8:
|
||||||
|
result.useValgrind = parseCfgBool(e.value)
|
||||||
|
result.unjoinable = true
|
||||||
|
else:
|
||||||
|
# Windows lacks valgrind. Silly OS.
|
||||||
|
# Valgrind only supports OSX <= 17.x
|
||||||
|
result.useValgrind = false
|
||||||
of "disabled":
|
of "disabled":
|
||||||
case e.value.normalize
|
case e.value.normalize
|
||||||
of "y", "yes", "true", "1", "on": result.err = reDisabled
|
of "y", "yes", "true", "1", "on": result.err = reDisabled
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,8 @@ proc execCmdEx2(command: string, args: openarray[string]; workingDir, input: str
|
||||||
for arg in args:
|
for arg in args:
|
||||||
result.cmdLine.add ' '
|
result.cmdLine.add ' '
|
||||||
result.cmdLine.add quoteShell(arg)
|
result.cmdLine.add quoteShell(arg)
|
||||||
|
var p = startProcess(command, workingDir=workingDir, args=args,
|
||||||
var p = startProcess(command, workingDir=workingDir, args=args, options={poStdErrToStdOut, poUsePath})
|
options={poStdErrToStdOut, poUsePath})
|
||||||
var outp = outputStream(p)
|
var outp = outputStream(p)
|
||||||
|
|
||||||
# There is no way to provide input for the child process
|
# There is no way to provide input for the child process
|
||||||
|
|
@ -441,12 +441,16 @@ proc testSpecHelper(r: var TResults, test: TTest, expected: TSpec, target: TTarg
|
||||||
if isJsTarget:
|
if isJsTarget:
|
||||||
exeCmd = nodejs
|
exeCmd = nodejs
|
||||||
args = concat(@[exeFile], args)
|
args = concat(@[exeFile], args)
|
||||||
elif defined(posix) and not exeFile.contains('/'):
|
|
||||||
# "security" in Posix is actually just a euphemism
|
|
||||||
# for "unproductive arbitrary shit"
|
|
||||||
exeCmd = "./" & exeFile
|
|
||||||
else:
|
else:
|
||||||
exeCmd = exeFile
|
if defined(posix) and not exeFile.contains('/'):
|
||||||
|
# "security" in Posix is actually just a euphemism
|
||||||
|
# for "unproductive arbitrary shit"
|
||||||
|
exeCmd = "./" & exeFile
|
||||||
|
else:
|
||||||
|
exeCmd = exeFile
|
||||||
|
if expected.useValgrind:
|
||||||
|
args = exeCmd & args
|
||||||
|
exeCmd = "valgrind"
|
||||||
var (_, buf, exitCode) = execCmdEx2(exeCmd, args, input = expected.input)
|
var (_, buf, exitCode) = execCmdEx2(exeCmd, args, input = expected.input)
|
||||||
# Treat all failure codes from nodejs as 1. Older versions of nodejs used
|
# Treat all failure codes from nodejs as 1. Older versions of nodejs used
|
||||||
# to return other codes, but for us it is sufficient to know that it's not 0.
|
# to return other codes, but for us it is sufficient to know that it's not 0.
|
||||||
|
|
|
||||||
6
tests/valgrind/tbasic_valgrind.nim
Normal file
6
tests/valgrind/tbasic_valgrind.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
discard """
|
||||||
|
valgrind: true
|
||||||
|
cmd: "nim c --gc:destructors $file"
|
||||||
|
"""
|
||||||
|
|
||||||
|
echo "hello world"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue