Skip to content

testament: remove deadcode related to realtimeGC, testC, callCCompiler #18087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions testament/categories.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const
"js",
"ic",
"lib",
"longgc",
"manyloc",
"nimble-packages",
"niminaction",
Expand All @@ -39,7 +38,6 @@ const
"coroutines",
"osproc",
"shouldfail",
"dir with space",
"destructor"
]

Expand Down Expand Up @@ -156,19 +154,6 @@ proc gcTests(r: var TResults, cat: Category, options: string) =
test "cyclecollector"
testWithoutBoehm "trace_globals"

proc longGCTests(r: var TResults, cat: Category, options: string) =
when defined(windows):
let cOptions = "-ldl -DWIN"
else:
let cOptions = "-ldl"

var c = initResults()
# According to ioTests, this should compile the file
testSpec c, makeTest("tests/realtimeGC/shared", options, cat)
# ^- why is this not appended to r? Should this be discarded?
testC r, makeTest("tests/realtimeGC/cmain", cOptions, cat), actionRun
testSpec r, makeTest("tests/realtimeGC/nmain", options & "--threads: on", cat)

# ------------------------- threading tests -----------------------------------

proc threadTests(r: var TResults, cat: Category, options: string) =
Expand All @@ -186,6 +171,11 @@ proc ioTests(r: var TResults, cat: Category, options: string) =
# dummy compile result:
var c = initResults()
testSpec c, makeTest("tests/system/helpers/readall_echo", options, cat)
# ^- why is this not appended to r? Should this be discarded?
# EDIT: this should be replaced by something like in D20210524T180826,
# likewise in similar instances where `testSpec c` is used, or more generally
# when a test depends on another test, as it makes tests non-independent,
# creating complications for batching and megatest logic.
testSpec r, makeTest("tests/system/tio", options, cat)

# ------------------------- async tests ---------------------------------------
Expand Down Expand Up @@ -687,8 +677,6 @@ proc processCategory(r: var TResults, cat: Category,
dllTests(r, cat, options)
of "gc":
gcTests(r, cat, options)
of "longgc":
longGCTests(r, cat, options)
of "debugger":
debuggerTests(r, cat, options)
of "manyloc":
Expand Down
63 changes: 0 additions & 63 deletions testament/testament.nim
Original file line number Diff line number Diff line change
Expand Up @@ -221,53 +221,6 @@ proc callNimCompiler(cmdTemplate, filename, options, nimcache: string,
result.msg = matches[0]
trimUnitSep result.msg

proc callCCompiler(cmdTemplate, filename, options: string,
target: TTarget): TSpec =
let cmd = prepareTestCmd(cmdTemplate, filename, options, nimcache = "", target)
doAssert false
#[
this code hasn't been run in a while, and should be removed which simplifies code
there are better ways to do this anyways (e.g. running c code from a nim file)

the only place where this is called is:
`testC r, makeTest("tests/realtimeGC/cmain", cOptions, cat), actionRun`
which isn't run unless you call:
XDG_CONFIG_HOME= nim r --lib:lib --stacktrace:on testament/testament.nim r longgc

and this fails since at least nim 1.0 with:
testament/testament.nim(851) testament
testament/testament.nim(822) main
testament/categories.nim(713) processCategory
testament/categories.nim(189) longGCTests
testament/testament.nim(644) makeTest
testament/specs.nim(251) parseSpec
testament/specs.nim(184) extractSpec
lib/system/io.nim(861) readFile
Error: unhandled exception: cannot open: tests/realtimeGC/cmain.nim [IOError]

Also, `c[5 .. ^1]` is too magical.
]#
let c = cmd.parseCmdLine
var p = startProcess(command = "gcc", args = c[5 .. ^1],
options = {poStdErrToStdOut, poUsePath, poEvalCommand})
let outp = p.outputStream
var x = newStringOfCap(120)
result.nimout = ""
result.msg = ""
result.file = ""
result.output = ""
result.line = -1
while true:
if outp.readLine(x):
result.nimout.add(x & '\n')
elif not running(p):
break
close(p)
if p.peekExitCode == 0:
result.err = reSuccess
else:
result.err = reNimcCrash

proc initResults: TResults =
result.total = 0
result.passed = 0
Expand Down Expand Up @@ -628,22 +581,6 @@ proc testSpecWithNimcache(r: var TResults, test: TTest; nimcache: string) {.used
var testClone = test
testSpecHelper(r, testClone, test.spec, target, nimcache)

proc testC(r: var TResults, test: TTest, action: TTestAction) =
# runs C code. Doesn't support any specs, just goes by exit code.
if not checkDisabled(r, test): return

let tname = test.name.addFileExt(".c")
inc(r.total)
maybeStyledEcho "Processing ", fgCyan, extractFilename(tname)
var given = callCCompiler(getCmd(TSpec()), test.name & ".c", test.options, targetC)
if given.err != reSuccess:
r.addResult(test, targetC, "", given.msg, given.err)
elif action == actionRun:
let exeFile = changeFileExt(test.name, ExeExt)
var (_, exitCode) = execCmdEx(exeFile, options = {poStdErrToStdOut, poUsePath})
if exitCode != 0: given.err = reExitcodesDiffer
if given.err == reSuccess: inc(r.passed)

proc makeTest(test, options: string, cat: Category): TTest =
result.cat = cat
result.name = test
Expand Down
3 changes: 1 addition & 2 deletions tests/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,4 @@ testing, which is slower).
The folder ``dll`` contains simple DLL tests.

The folder ``realtimeGC`` contains a test for validating that the realtime GC
can run properly without linking against the nimrtl.dll/so. It includes a C
client and platform specific build files for manual compilation.
can run properly without linking against the nimrtl.dll/so.
69 changes: 0 additions & 69 deletions tests/realtimeGC/cmain.c

This file was deleted.

10 changes: 0 additions & 10 deletions tests/realtimeGC/readme.txt

This file was deleted.

10 changes: 9 additions & 1 deletion tests/realtimeGC/tmain.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@ these dont' seem needed --debuginfo
nor these from the previous main.nim.cfg: --app:console
]#

#[
Test the realtime GC without linking nimrtl.dll/so.

To build by hand and run the test for 35 minutes:
`nim r --threads:on -d:runtimeSecs:2100 tests/realtimeGC/tmain.nim`
]#

import times, os, strformat, strutils
from stdtest/specialpaths import buildDir
# import threadpool

const runtimeSecs {.intdefine.} = 5

const file = "shared.nim"
const dllname = buildDir / (DynlibFormat % file)
const dllname = buildDir / (DynlibFormat % "shared_D20210524T180506")

static:
# D20210524T180826:here we compile the dependency on the fly
let nim = getCurrentCompilerExe()
let (output, exitCode) = gorgeEx(fmt"{nim} c -o:{dllname} --debuginfo --app:lib --threads:on -d:release -d:useRealtimeGC {file}")
doAssert exitCode == 0, output
Expand Down