Add tests for examples from Nim in Action.

This commit is contained in:
Dominik Picheta 2017-10-01 17:17:40 +01:00
commit 7889c03cbc
34 changed files with 1213 additions and 0 deletions

View file

@ -238,6 +238,48 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
for testfile in ["strutils", "json", "random", "times", "logging"]:
test "lib/pure/" & testfile & ".nim"
# ------------------------- nim in action -----------
proc testNimInAction(r: var TResults, cat: Category, options: string) =
template test(filename: untyped, action: untyped) =
testSpec r, makeTest(filename, options, cat, action)
template testJS(filename: untyped) =
testSpec r, makeTest(filename, options, cat, actionCompile, targetJS)
template testCPP(filename: untyped) =
testSpec r, makeTest(filename, options, cat, actionCompile, targetCPP)
let tests = [
"niminaction/Chapter3/ChatApp/src/server",
"niminaction/Chapter3/ChatApp/src/client",
"niminaction/Chapter6/WikipediaStats/concurrency_regex",
"niminaction/Chapter6/WikipediaStats/concurrency",
"niminaction/Chapter6/WikipediaStats/naive",
"niminaction/Chapter6/WikipediaStats/parallel_counts",
"niminaction/Chapter6/WikipediaStats/race_condition",
"niminaction/Chapter6/WikipediaStats/sequential_counts",
"niminaction/Chapter7/Tweeter/src/tweeter",
"niminaction/Chapter7/Tweeter/src/createDatabase",
"niminaction/Chapter7/Tweeter/tests/database_test",
"niminaction/Chapter8/sdl/sdl_test",
]
for testfile in tests:
test "tests/" & testfile & ".nim", actionCompile
# TODO: This doesn't work for some reason ;\
# let reject = "tests/niminaction/Chapter6/WikipediaStats" &
# "/unguarded_access.nim"
# test reject, actionReject
let jsFile = "tests/niminaction/Chapter8/canvas/canvas_test.nim"
testJS jsFile
let cppFile = "tests/niminaction/Chapter8/sfml/sfml_test.nim"
testCPP cppFile
# ------------------------- manyloc -------------------------------------------
#proc runSpecialTests(r: var TResults, options: string) =
# for t in ["lib/packages/docutils/highlite"]:
@ -420,6 +462,8 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
testNimblePackages(r, cat, pfExtraOnly)
of "nimble-all":
testNimblePackages(r, cat, pfAll)
of "niminaction":
testNimInAction(r, cat, options)
of "untestable":
# We can't test it because it depends on a third party.
discard # TODO: Move untestable tests to someplace else, i.e. nimble repo.