compilation cache: tests now part of test suite
This commit is contained in:
parent
5e5e4abfee
commit
2d54b85089
19 changed files with 250 additions and 46 deletions
9
tests/rodfiles/aconv.nim
Normal file
9
tests/rodfiles/aconv.nim
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
discard """
|
||||
output: "ugly conversion successful"
|
||||
"""
|
||||
|
||||
import int2bool
|
||||
|
||||
if 4:
|
||||
echo "ugly conversion successful"
|
||||
|
||||
13
tests/rodfiles/amethods.nim
Normal file
13
tests/rodfiles/amethods.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
type
|
||||
TBaseClass* = object of TObject
|
||||
|
||||
proc newBaseClass*: ref TBaseClass =
|
||||
new result
|
||||
|
||||
method echoType*(x: ref TBaseClass) =
|
||||
echo "base class"
|
||||
|
||||
proc echoAlias*(x: ref TBaseClass) =
|
||||
echoType x
|
||||
|
||||
9
tests/rodfiles/bconv.nim
Normal file
9
tests/rodfiles/bconv.nim
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
discard """
|
||||
output: "ugly conversion successful 2"
|
||||
"""
|
||||
|
||||
import int2bool
|
||||
|
||||
if 4:
|
||||
echo "ugly conversion successful 2"
|
||||
|
||||
30
tests/rodfiles/bmethods.nim
Normal file
30
tests/rodfiles/bmethods.nim
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
discard """
|
||||
output: '''
|
||||
derived class
|
||||
base class
|
||||
'''
|
||||
"""
|
||||
|
||||
import amethods
|
||||
|
||||
|
||||
type
|
||||
TDerivedClass* = object of TBaseClass
|
||||
|
||||
proc newDerivedClass: ref TDerivedClass =
|
||||
new result
|
||||
|
||||
method echoType*(x: ref TDerivedClass) =
|
||||
echo "derived class"
|
||||
|
||||
var b, d: ref TBaseClass
|
||||
|
||||
b = newBaseClass()
|
||||
d = newDerivedClass()
|
||||
|
||||
#b.echoType()
|
||||
#d.echoType()
|
||||
|
||||
echoAlias d
|
||||
echoAlias b
|
||||
|
||||
30
tests/rodfiles/bmethods2.nim
Normal file
30
tests/rodfiles/bmethods2.nim
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
discard """
|
||||
output: '''
|
||||
derived class 2
|
||||
base class
|
||||
'''
|
||||
"""
|
||||
|
||||
import amethods
|
||||
|
||||
|
||||
type
|
||||
TDerivedClass* = object of TBaseClass
|
||||
|
||||
proc newDerivedClass: ref TDerivedClass =
|
||||
new result
|
||||
|
||||
method echoType*(x: ref TDerivedClass) =
|
||||
echo "derived class 2"
|
||||
|
||||
var b, d: ref TBaseClass
|
||||
|
||||
b = newBaseClass()
|
||||
d = newDerivedClass()
|
||||
|
||||
#b.echoType()
|
||||
#d.echoType()
|
||||
|
||||
echoAlias d
|
||||
echoAlias b
|
||||
|
||||
9
tests/rodfiles/deada.nim
Normal file
9
tests/rodfiles/deada.nim
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
discard """
|
||||
output: '''
|
||||
246
|
||||
'''
|
||||
"""
|
||||
|
||||
import deadg, deadb
|
||||
|
||||
|
||||
13
tests/rodfiles/deada2.nim
Normal file
13
tests/rodfiles/deada2.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
discard """
|
||||
output: '''
|
||||
246
|
||||
xyzabc
|
||||
'''
|
||||
"""
|
||||
|
||||
import deadg, deadb
|
||||
|
||||
# now add call to previously unused proc p2:
|
||||
echo p2("xyz", "abc")
|
||||
|
||||
|
||||
7
tests/rodfiles/deadb.nim
Normal file
7
tests/rodfiles/deadb.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
import deadg
|
||||
|
||||
|
||||
echo p1(123, 123)
|
||||
|
||||
|
||||
10
tests/rodfiles/deadg.nim
Normal file
10
tests/rodfiles/deadg.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
proc p1*(x, y: int): int =
|
||||
result = x + y
|
||||
|
||||
proc p2*(x, y: string): string =
|
||||
result = x & y
|
||||
|
||||
|
||||
14
tests/rodfiles/gtkex1.nim
Executable file
14
tests/rodfiles/gtkex1.nim
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
import
|
||||
cairo, glib2, gtk2
|
||||
|
||||
proc destroy(widget: pWidget, data: pgpointer) {.cdecl.} =
|
||||
main_quit()
|
||||
|
||||
var
|
||||
window: pWidget
|
||||
nimrod_init()
|
||||
window = window_new(WINDOW_TOPLEVEL)
|
||||
discard signal_connect(window, "destroy",
|
||||
SIGNAL_FUNC(gtkex1.destroy), nil)
|
||||
show(window)
|
||||
main()
|
||||
22
tests/rodfiles/gtkex2.nim
Executable file
22
tests/rodfiles/gtkex2.nim
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
import
|
||||
glib2, gtk2
|
||||
|
||||
proc destroy(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
main_quit()
|
||||
|
||||
var
|
||||
window: PWidget
|
||||
button: PWidget
|
||||
|
||||
nimrod_init()
|
||||
window = window_new(WINDOW_TOPLEVEL)
|
||||
button = button_new("Click me")
|
||||
set_border_width(PContainer(Window), 5)
|
||||
add(PContainer(window), button)
|
||||
discard signal_connect(window, "destroy",
|
||||
SIGNAL_FUNC(gtkex2.destroy), nil)
|
||||
show(button)
|
||||
show(window)
|
||||
main()
|
||||
|
||||
6
tests/rodfiles/hallo.nim
Executable file
6
tests/rodfiles/hallo.nim
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
discard """
|
||||
output: "Hello World"
|
||||
"""
|
||||
|
||||
echo "Hello World"
|
||||
|
||||
17
tests/rodfiles/hallo2.nim
Normal file
17
tests/rodfiles/hallo2.nim
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
discard """
|
||||
output: "Hello World"
|
||||
"""
|
||||
|
||||
# Test incremental type information
|
||||
|
||||
type
|
||||
TNode = object {.pure.}
|
||||
le, ri: ref TNode
|
||||
data: string
|
||||
|
||||
proc newNode(data: string): ref TNode =
|
||||
new(result)
|
||||
result.data = data
|
||||
|
||||
echo newNode("Hello World").data
|
||||
|
||||
5
tests/rodfiles/int2bool.nim
Normal file
5
tests/rodfiles/int2bool.nim
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
converter uglyToBool*(x: int): bool =
|
||||
result = x != 0
|
||||
|
||||
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#
|
||||
#
|
||||
# Nimrod Tester
|
||||
# (c) Copyright 2011 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This program tests Nimrod's ROD file mechanism.
|
||||
|
||||
import
|
||||
parseutils, strutils, pegs, os, osproc, streams, parsecfg, browsers, json,
|
||||
marshal, cgi
|
||||
|
||||
const
|
||||
cmdTemplate = r"nimrod cc --hints:on $# $#"
|
||||
resultsFile = "testresults.html"
|
||||
jsonFile = "testresults.json"
|
||||
Usage = "usage: tester reject|compile|examples|run|merge [nimrod options]"
|
||||
|
||||
proc myExec(cmd: string): string =
|
||||
result = osproc.execProcess(cmd)
|
||||
|
||||
var
|
||||
pegLineError = peg"{[^(]*} '(' {\d+} ', ' \d+ ') Error:' \s* {.*}"
|
||||
pegOtherError = peg"'Error:' \s* {.*}"
|
||||
pegSuccess = peg"'Hint: operation successful'.*"
|
||||
pegOfInterest = pegLineError / pegOtherError / pegSuccess
|
||||
|
||||
|
|
@ -267,6 +267,51 @@ proc runSingleTest(r: var TResults, test, options: string) =
|
|||
proc run(r: var TResults, dir, options: string) =
|
||||
for test in os.walkFiles(dir / "t*.nim"): runSingleTest(r, test, options)
|
||||
|
||||
# ---------------- ROD file tests ---------------------------------------------
|
||||
|
||||
const
|
||||
rodfilesDir = "tests/rodfiles"
|
||||
|
||||
proc delNimCache() = removeDir(rodfilesDir / "nimcache")
|
||||
proc plusCache(options: string): string = return options & " --symbolFiles:on"
|
||||
|
||||
proc runRodFiles(r: var TResults, options: string) =
|
||||
var options = options.plusCache
|
||||
delNimCache()
|
||||
|
||||
# test basic recompilation scheme:
|
||||
runSingleTest(r, rodfilesDir / "hallo", options)
|
||||
runSingleTest(r, rodfilesDir / "hallo", options)
|
||||
# test incremental type information:
|
||||
runSingleTest(r, rodfilesDir / "hallo2", options)
|
||||
delNimCache()
|
||||
|
||||
# test type converters:
|
||||
runSingleTest(r, rodfilesDir / "aconv", options)
|
||||
runSingleTest(r, rodfilesDir / "bconv", options)
|
||||
delNimCache()
|
||||
|
||||
# test G, A, B example from the documentation; test init sections:
|
||||
runSingleTest(r, rodfilesDir / "deada", options)
|
||||
runSingleTest(r, rodfilesDir / "deada2", options)
|
||||
delNimCache()
|
||||
|
||||
# test method generation:
|
||||
runSingleTest(r, rodfilesDir / "bmethods", options)
|
||||
runSingleTest(r, rodfilesDir / "bmethods2", options)
|
||||
delNimCache()
|
||||
|
||||
|
||||
proc compileRodFiles(r: var TResults, options: string) =
|
||||
var options = options.plusCache
|
||||
delNimCache()
|
||||
# test DLL interfacing:
|
||||
compileSingleTest(r, rodfilesDir / "gtkex1", options)
|
||||
compileSingleTest(r, rodfilesDir / "gtkex2", options)
|
||||
delNimCache()
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
proc compileExample(r: var TResults, pattern, options: string) =
|
||||
for test in os.walkFiles(pattern): compileSingleTest(r, test, options)
|
||||
|
||||
|
|
@ -303,6 +348,7 @@ proc main(action: string) =
|
|||
var compileRes = initResults()
|
||||
compile(compileRes, "tests/accept/compile/t*.nim", options)
|
||||
compile(compileRes, "tests/ecmas.nim", options)
|
||||
compileRodFiles(compileRes, options)
|
||||
writeResults(compileJson, compileRes)
|
||||
of "examples":
|
||||
var compileRes = readResults(compileJson)
|
||||
|
|
@ -313,6 +359,7 @@ proc main(action: string) =
|
|||
of "run":
|
||||
var runRes = initResults()
|
||||
run(runRes, "tests/accept/run", options)
|
||||
runRodFiles(runRes, options)
|
||||
writeResults(runJson, runRes)
|
||||
of "merge":
|
||||
var rejectRes = readResults(rejectJson)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue