From 82a04051bb0e02c574d22503786d6d47d500bc27 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Wed, 30 Sep 2015 20:13:37 -0700 Subject: [PATCH 01/19] fix failure in tests/method/tmapper.nim FAIL: tmapper.nim Test "tests/method/tmapper.nim" in category "method" Failure: reMsgsDiffer Expected: invalid declaration order; cannot attach 'step' to method defined here: tmapper.nim(22,7) Gotten: invalid declaration order; cannot attach 'step' to method defined here: tests/method/tmapper.nim(22,7) --- tests/method/tmapper.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/method/tmapper.nim b/tests/method/tmapper.nim index 0008d90337..75b36e69af 100644 --- a/tests/method/tmapper.nim +++ b/tests/method/tmapper.nim @@ -1,5 +1,5 @@ discard """ - errormsg: "invalid declaration order; cannot attach 'step' to method defined here: tmapper.nim(22,7)" + errormsg: "invalid declaration order; cannot attach 'step' to method defined here: tests/method/tmapper.nim(22,7)" line: 25 """ From 61ace9e394128a362a457e64c6acd76d7954aaeb Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Wed, 30 Sep 2015 20:14:14 -0700 Subject: [PATCH 02/19] fix failure in lib/pure/ospaths.nim FAIL: ospaths.nim Test "lib/pure/ospaths.nim" in category "lib" Failure: reNimcCrash Expected: Gotten: invalid pragma: rtl --- lib/pure/ospaths.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pure/ospaths.nim b/lib/pure/ospaths.nim index 99f6bcd4de..fd28db4438 100644 --- a/lib/pure/ospaths.nim +++ b/lib/pure/ospaths.nim @@ -10,6 +10,10 @@ # Included by the ``os`` module but a module in its own right for NimScript # support. +when isMainModule: + {.pragma: rtl.} + import strutils + when defined(nimscript) or (defined(nimdoc) and not declared(os)): {.pragma: rtl.} {.push hint[ConvFromXtoItselfNotNeeded]:off.} From 18882d006b418dab61a6c03e06c08b03ead31b97 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Thu, 1 Oct 2015 11:42:11 -0700 Subject: [PATCH 03/19] fix test failures in subexes due to missing trailing whitespace FAIL: subexes.nim Test "lib/pure/subexes.nim" in category "lib" Failure: reExitcodesDiffer Expected: exitcode: 0 Gotten: exitcode: 1 Output: Traceback (most recent call last) subexes.nim(385) subexes system.nim(3335) raiseAssert system.nim(2531) sysFatal Error: unhandled exception: "$#($\', \'10c\'\x0A \'{#..})" % ["doAssert", "longishA", "longish"] == --- lib/pure/subexes.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pure/subexes.nim b/lib/pure/subexes.nim index 2d1adc0ebe..04c43463b8 100644 --- a/lib/pure/subexes.nim +++ b/lib/pure/subexes.nim @@ -384,15 +384,15 @@ when isMainModule: doAssert "$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"] == """doAssert( - longishA, + longishA, longish)""" assert "type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", "fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"] == strutils.unindent """ type MyEnum* = enum - fieldA, fieldB, - FiledClkad, fieldD, + fieldA, fieldB, + FiledClkad, fieldD, fieldE, longishFieldName""" doAssert subex"$1($', '{2..})" % ["f", "a", "b", "c"] == "f(a, b, c)" @@ -406,7 +406,7 @@ when isMainModule: strutils.unindent """ type Enum = enum - fieldNameA, fieldNameB, fieldNameC, + fieldNameA, fieldNameB, fieldNameC, fieldNameD""" From f89c247a89ff98e36ad8abcc44d2e96935356f50 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Thu, 1 Oct 2015 11:42:40 -0700 Subject: [PATCH 04/19] fix test failure in coro.nim FAIL: coro.nim Test "lib/pure/coro.nim" in category "lib" Failure: reNimcCrash Expected: Gotten: Coroutines require -d:nimCoroutines --- lib/pure/coro.nimcfg | 1 + 1 file changed, 1 insertion(+) create mode 100644 lib/pure/coro.nimcfg diff --git a/lib/pure/coro.nimcfg b/lib/pure/coro.nimcfg new file mode 100644 index 0000000000..b011bc585e --- /dev/null +++ b/lib/pure/coro.nimcfg @@ -0,0 +1 @@ +-d:nimCoroutines From 97c2574e8d6488118f85d8dff6cd88d7787f809b Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Thu, 1 Oct 2015 12:25:39 -0700 Subject: [PATCH 05/19] fix test failure due to "illegal recursion" error message FAIL: tillegal_recursion.nim Test "tests/objects/tillegal_recursion.nim" in category "objects" Failure: reMsgsDiffer Expected: illegal recursion in type 'object' Gotten: inheritance only works with non-final objects --- tests/objects/tillegal_recursion.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/objects/tillegal_recursion.nim b/tests/objects/tillegal_recursion.nim index 171a04f87e..2221391016 100644 --- a/tests/objects/tillegal_recursion.nim +++ b/tests/objects/tillegal_recursion.nim @@ -1,5 +1,5 @@ discard """ - errormsg: "illegal recursion in type 'object'" + errormsg: "inheritance only works with non-final objects" line: 7 """ # bug #1691 From e9fc86597ea7475668543498c7a113bca4ddbce4 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 13:38:32 -0700 Subject: [PATCH 06/19] use clang for threading tests on travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 486feb1274..32977b185c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ script: - cd csources - sh build.sh - cd .. + - sed -i -e 's,cc = gcc,cc = clang,' config/nim.cfg - ./bin/nim c koch - ./koch boot - ./koch boot -d:release From 2f7802bea3f27eae92b828b0cb3d49b451f10839 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 16:00:33 -0700 Subject: [PATCH 07/19] fix rawsockets test FAIL: trawsockets.nim Test "tests/cpp/trawsockets.nim" in category "cpp" Failure: reNimcCrash Expected: Gotten: Hint: system [Processing] Hint: trawsockets [Processing] Hint: rawsockets [Processing] Hint: unsigned [Processing] lib/pure/rawsockets.nim(15, 8) Warning: unsigned is deprecated [Deprecated] Hint: os [Processing] Hint: strutils [Processing] Hint: parseutils [Processing] Hint: times [Processing] Hint: posix [Processing] CC: compiler_trawsockets CC: stdlib_system CC: stdlib_rawsockets CC: stdlib_unsigned CC: stdlib_os CC: stdlib_strutils Error: execution of an external compiler program 'clang++ -c -w -I/Users/tmm1/code/nim/lib -o tests/cpp/nimcache/stdlib_rawsockets.o tests/cpp/nimcache/stdlib_rawsockets.cpp' failed with exit code: 256 tests/cpp/nimcache/stdlib_rawsockets.cpp:355:8: error: assigning to 'NCSTRING' (aka 'char *') from incompatible type 'const char *' LOC6 = gai_strerror(gairesult); ^ ~~~~~~~~~~~~~~~~~~~~~~~ tests/cpp/nimcache/stdlib_rawsockets.cpp:499:8: error: assigning to 'NCSTRING' (aka 'char *') from incompatible type 'const char *' LOC5 = hstrerror(h_errno); ^ ~~~~~~~~~~~~~~~~~~ tests/cpp/nimcache/stdlib_rawsockets.cpp:650:8: error: assigning to 'NCSTRING' (aka 'char *') from incompatible type 'const char *' LOC9 = inet_ntop(AF_INET6, ((void*) (addr6)), result->data, ((NI32)chckRange((result ? result->len : 0), ((NI32) (-2147483647 -1)), ((NI32) 2147483647)))); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tests/cpp/nimcache/stdlib_rawsockets.cpp:771:10: error: assigning to 'NCSTRING' (aka 'char *') from incompatible type 'const char *' LOC17 = inet_ntop(name.sin6_family, ((void*) ((&name))), ((NCSTRING) (buf)), ((NI32)chckRange(((NI)sizeof(TY143006)), ((NI32) (-2147483647 -1)), ((NI32) 2147483647)))); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tests/cpp/nimcache/stdlib_rawsockets.cpp:859:10: error: assigning to 'NCSTRING' (aka 'char *') from incompatible type 'const char *' LOC17 = inet_ntop(name.sin6_family, ((void*) ((&name))), ((NCSTRING) (buf)), ((NI32)chckRange(((NI)sizeof(TY143006)), ((NI32) (-2147483647 -1)), ((NI32) 2147483647)))); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 errors generated. --- lib/posix/posix.nim | 6 +++--- lib/pure/rawsockets.nim | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index 8486fa04f0..5f1dfcfcd5 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -1810,7 +1810,7 @@ proc ntohs*(a1: int16): int16 {.importc, header: "".} proc inet_addr*(a1: cstring): InAddrT {.importc, header: "".} proc inet_ntoa*(a1: InAddr): cstring {.importc, header: "".} proc inet_ntop*(a1: cint, a2: pointer, a3: cstring, a4: int32): cstring {. - importc, header: "".} + importc:"(char *)$1", header: "".} proc inet_pton*(a1: cint, a2: cstring, a3: pointer): cint {. importc, header: "".} @@ -2381,7 +2381,7 @@ proc sched_setscheduler*(a1: Pid, a2: cint, a3: var Sched_param): cint {. proc sched_yield*(): cint {.importc, header: "".} proc strerror*(errnum: cint): cstring {.importc, header: "".} -proc hstrerror*(herrnum: cint): cstring {.importc, header: "".} +proc hstrerror*(herrnum: cint): cstring {.importc:"(char *)$1", header: "".} proc FD_CLR*(a1: cint, a2: var TFdSet) {.importc, header: "".} proc FD_ISSET*(a1: cint | SocketHandle, a2: var TFdSet): cint {. @@ -2565,7 +2565,7 @@ proc endprotoent*() {.importc, header: "".} proc endservent*() {.importc, header: "".} proc freeaddrinfo*(a1: ptr AddrInfo) {.importc, header: "".} -proc gai_strerror*(a1: cint): cstring {.importc, header: "".} +proc gai_strerror*(a1: cint): cstring {.importc:"(char *)$1", header: "".} proc getaddrinfo*(a1, a2: cstring, a3: ptr AddrInfo, a4: var ptr AddrInfo): cint {.importc, header: "".} diff --git a/lib/pure/rawsockets.nim b/lib/pure/rawsockets.nim index f5860ef282..1b62913f1a 100644 --- a/lib/pure/rawsockets.nim +++ b/lib/pure/rawsockets.nim @@ -345,7 +345,6 @@ proc getAddrString*(sockAddr: ptr SockAddr): string = elif sockAddr.sa_family == rawAfInet6: when not useWinVersion: # TODO: Windows - var v6addr = cast[ptr Sockaddr_in6](sockAddr).sin6_addr result = newString(posix.INET6_ADDRSTRLEN) let addr6 = addr cast[ptr Sockaddr_in6](sockAddr).sin6_addr discard posix.inet_ntop(posix.AF_INET6, addr6, result.cstring, From 8f6a275f4de74873170f0cf00745fff8cee5bcb8 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 16:10:58 -0700 Subject: [PATCH 08/19] download fasm for the coro build --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 32977b185c..98a125fc6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,11 @@ addons: packages: - libcurl4-openssl-dev - libsdl1.2-dev +before_script: + - set -e + - wget http://flatassembler.net/fasm-1.71.39.tgz + - tar xvf fasm-1.71.39.tgz + - export PATH=$(pwd)/fasm:$PATH script: - git clone --depth 1 https://github.com/nim-lang/csources.git - cd csources From 6e7759734e321e6441b73ddfc5a0a0b37b81ded3 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 17:38:48 -0700 Subject: [PATCH 09/19] show stderr w/ reExitcodesDiffer --- tests/testament/tester.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim index e52988682b..814e342ca7 100644 --- a/tests/testament/tester.nim +++ b/tests/testament/tester.nim @@ -282,7 +282,7 @@ proc testSpec(r: var TResults, test: TTest) = return let exeCmd = (if isJsTarget: nodejs & " " else: "") & exeFile - let (buf, exitCode) = execCmdEx(exeCmd) + var (buf, exitCode) = execCmdEx(exeCmd, options = {poStdErrToStdOut}) let bufB = if expected.sortoutput: makeDeterministic(strip(buf.string)) else: strip(buf.string) let expectedOut = strip(expected.outp) From 1652fd0431de1391cd2bb29166e813ad9f16db46 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 17:41:37 -0700 Subject: [PATCH 10/19] install nimble and zip package --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 98a125fc6a..c4efa61cfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,4 +23,7 @@ script: - ./koch boot -d:release after_script: - export PATH=$(pwd)/bin:$PATH + - nim e install_nimble.nims + - nimble update + - nimble install zip - ./koch test From 1639de0a4e18f9e055c2412efe326a1e1b904f61 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 18:08:23 -0700 Subject: [PATCH 11/19] remove trailing whitespace requirement from subexes test file --- lib/pure/subexes.nim | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/pure/subexes.nim b/lib/pure/subexes.nim index 04c43463b8..5824ace811 100644 --- a/lib/pure/subexes.nim +++ b/lib/pure/subexes.nim @@ -351,6 +351,7 @@ proc format*(formatstr: Subex, a: varargs[string, `$`]): string {.noSideEffect, {.pop.} when isMainModule: + from strutils import replace proc `%`(formatstr: string, a: openarray[string]): string = result = newStringOfCap(formatstr.len + a.len shl 4) @@ -382,18 +383,18 @@ when isMainModule: doAssert "${$1}" % "1" == "1" doAssert "${$$-1} $$1" % "1" == "1 $1" - doAssert "$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"] == + doAssert(("$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"]).replace(" \n", "\n") == """doAssert( - longishA, - longish)""" + longishA, + longish)""") - assert "type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", - "fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"] == + doAssert(("type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", + "fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"]).replace(" \n", "\n") == strutils.unindent """ type MyEnum* = enum - fieldA, fieldB, - FiledClkad, fieldD, - fieldE, longishFieldName""" + fieldA, fieldB, + FiledClkad, fieldD, + fieldE, longishFieldName""") doAssert subex"$1($', '{2..})" % ["f", "a", "b", "c"] == "f(a, b, c)" @@ -401,12 +402,10 @@ when isMainModule: doAssert subex"$['''|'|''''|']']#" % "0" == "'|" - assert subex("type\n Enum = enum\n $', '40c'\n '{..}") % [ - "fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"] == + doAssert((subex("type\n Enum = enum\n $', '40c'\n '{..}") % [ + "fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"]).replace(" \n", "\n") == strutils.unindent """ type Enum = enum - fieldNameA, fieldNameB, fieldNameC, - fieldNameD""" - - + fieldNameA, fieldNameB, fieldNameC, + fieldNameD""") From 5b9465acf615e0513defa074673c6da46b27fe28 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 18:20:51 -0700 Subject: [PATCH 12/19] fix test failures due to import errors --- .travis.yml | 2 ++ tests/manyloc/keineschweine/lib/zlib_helpers.nim | 2 +- tests/manyloc/nake/nakefile.nim | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c4efa61cfb..ae2ac4f888 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,4 +26,6 @@ after_script: - nim e install_nimble.nims - nimble update - nimble install zip + - nimble install opengl + - nimble install sdl1 - ./koch test diff --git a/tests/manyloc/keineschweine/lib/zlib_helpers.nim b/tests/manyloc/keineschweine/lib/zlib_helpers.nim index 5241a77c0a..0764759641 100644 --- a/tests/manyloc/keineschweine/lib/zlib_helpers.nim +++ b/tests/manyloc/keineschweine/lib/zlib_helpers.nim @@ -1,4 +1,4 @@ -import zlib +import zip/zlib proc compress*(source: string): string = var diff --git a/tests/manyloc/nake/nakefile.nim b/tests/manyloc/nake/nakefile.nim index 6dc453e8d6..2fe07ec174 100644 --- a/tests/manyloc/nake/nakefile.nim +++ b/tests/manyloc/nake/nakefile.nim @@ -1,5 +1,5 @@ import nake -import httpclient, zipfiles, times, math +import httpclient, zip/zipfiles, times, math nakeImports randomize() From 2fbdf9320c43b1a8b8ca0a7b28ffdda6680c5237 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 18:34:04 -0700 Subject: [PATCH 13/19] fix float comparision failure in math tests FAIL: math.nim Test "lib/pure/math.nim" in category "lib" Failure: reExitcodesDiffer Expected: exitcode: 0 Gotten: exitcode: 1 Output: Traceback (most recent call last) math.nim(478) math system.nim(3343) failedAssertImpl system.nim(3335) raiseAssert system.nim(2531) sysFatal Error: unhandled exception: tgamma(5.0'f64) == 24.0'f64 [AssertionError] --- lib/pure/math.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/math.nim b/lib/pure/math.nim index 06a018d9f5..391a880aea 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -475,7 +475,7 @@ when isMainModule and not defined(JS): return sqrt(num) # check gamma function - assert(tgamma(5.0) == 24.0) # 4! + assert($tgamma(5.0) == $24.0) # 4! assert(lgamma(1.0) == 0.0) # ln(1.0) == 0.0 assert(erf(6.0) > erf(5.0)) assert(erfc(6.0) < erfc(5.0)) From b33d97621d9e0c73d9512e74b44407394858eb08 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 18:56:57 -0700 Subject: [PATCH 14/19] only compile coro.nim by avoiding "when isMainModule" string match in testament/tester FAIL: coro.nim Test "lib/pure/coro.nim" in category "lib" Failure: reOutputsDiffer Expected: Gotten: c1 c2 c2 c1 c2 c1 c2 c1 c1 exits c2 exits done 1100220033 --- lib/pure/coro.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/coro.nim b/lib/pure/coro.nim index 8fa529474a..c5724f26f4 100644 --- a/lib/pure/coro.nim +++ b/lib/pure/coro.nim @@ -119,7 +119,7 @@ proc wait*(c: proc(), interval=0.01) = while alive(c): suspend interval -when isMainModule: +when defined(nimCoroutines) and isMainModule: var stackCheckValue = 1100220033 proc c2() From a01fd5e93f58a2bf9dea4f577218b8ff7d874bbf Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Fri, 2 Oct 2015 19:02:01 -0700 Subject: [PATCH 15/19] fail CI when tests fail --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae2ac4f888..664466e2bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,21 +11,19 @@ before_script: - set -e - wget http://flatassembler.net/fasm-1.71.39.tgz - tar xvf fasm-1.71.39.tgz - - export PATH=$(pwd)/fasm:$PATH -script: - git clone --depth 1 https://github.com/nim-lang/csources.git - cd csources - sh build.sh - cd .. - sed -i -e 's,cc = gcc,cc = clang,' config/nim.cfg - - ./bin/nim c koch + - export PATH=$(pwd)/bin:$(pwd)/fasm:$PATH +script: + - nim c koch - ./koch boot - ./koch boot -d:release -after_script: - - export PATH=$(pwd)/bin:$PATH - nim e install_nimble.nims - nimble update - nimble install zip - nimble install opengl - nimble install sdl1 - - ./koch test + - ./koch test --pedantic From 2240fd3f3fb32fc4b1c8c7815d6d59982df44406 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Tue, 6 Oct 2015 15:47:07 -0700 Subject: [PATCH 16/19] add tfile/tline assertions for template expansion file/line --- tests/enum/tenummix.nim | 4 ++-- tests/misc/tnot.nim | 7 ++----- tests/testament/specs.nim | 5 +++++ tests/testament/tester.nim | 23 ++++++++++++++++++++++- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/tests/enum/tenummix.nim b/tests/enum/tenummix.nim index 4352cdd813..c7db4e0560 100644 --- a/tests/enum/tenummix.nim +++ b/tests/enum/tenummix.nim @@ -1,6 +1,6 @@ discard """ - file: "tenummix.nim" - line: 11 + tfile: "tenummix.nim" + tline: 11 errormsg: "type mismatch" """ diff --git a/tests/misc/tnot.nim b/tests/misc/tnot.nim index 60d23c0353..8c75c6bc06 100644 --- a/tests/misc/tnot.nim +++ b/tests/misc/tnot.nim @@ -1,6 +1,6 @@ discard """ - file: "tnot.nim" - line: 14 + tfile: "tnot.nim" + tline: 14 errormsg: "type mismatch" """ # BUG: following compiles, but should not: @@ -17,6 +17,3 @@ proc main = echo "No" main() - - - diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim index 99640f22c3..dcca8a66ea 100644 --- a/tests/testament/specs.nim +++ b/tests/testament/specs.nim @@ -44,6 +44,8 @@ type file*, cmd*: string outp*: string line*, column*: int + tfile*: string + tline*, tcolumn*: int exitCode*: int msg*: string ccodeCheck*: string @@ -116,6 +118,9 @@ proc parseSpec*(filename: string): TSpec = of "file": result.file = e.value of "line": discard parseInt(e.value, result.line) of "column": discard parseInt(e.value, result.column) + of "tfile": result.tfile = e.value + of "tline": discard parseInt(e.value, result.tline) + of "tcolumn": discard parseInt(e.value, result.tcolumn) of "output": result.action = actionRun result.outp = e.value diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim index 814e342ca7..636093a7f5 100644 --- a/tests/testament/tester.nim +++ b/tests/testament/tester.nim @@ -53,6 +53,8 @@ type let pegLineError = peg"{[^(]*} '(' {\d+} ', ' {\d+} ') ' ('Error') ':' \s* {.*}" + pegLineTemplate = + peg"{[^(]*} '(' {\d+} ', ' {\d+} ') ' 'template/generic instantiation from here'.*" pegOtherError = peg"'Error:' \s* {.*}" pegSuccess = peg"'Hint: operation successful'.*" pegOfInterest = pegLineError / pegOtherError @@ -66,6 +68,7 @@ proc callCompiler(cmdTemplate, filename, options: string, let outp = p.outputStream var suc = "" var err = "" + var tmpl = "" var x = newStringOfCap(120) result.nimout = "" while outp.readLine(x.TaintedString) or running(p): @@ -73,6 +76,9 @@ proc callCompiler(cmdTemplate, filename, options: string, if x =~ pegOfInterest: # `err` should contain the last error/warning message err = x + elif x =~ pegLineTemplate and err == "": + # `tmpl` contains the last template expansion before the error + tmpl = x elif x =~ pegSuccess: suc = x close(p) @@ -81,6 +87,13 @@ proc callCompiler(cmdTemplate, filename, options: string, result.outp = "" result.line = 0 result.column = 0 + result.tfile = "" + result.tline = 0 + result.tcolumn = 0 + if tmpl =~ pegLineTemplate: + result.tfile = extractFilename(matches[0]) + result.tline = parseInt(matches[1]) + result.tcolumn = parseInt(matches[2]) if err =~ pegLineError: result.file = extractFilename(matches[0]) result.line = parseInt(matches[1]) @@ -154,7 +167,7 @@ proc addResult(r: var TResults, test: TTest, proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) = if strip(expected.msg) notin strip(given.msg): r.addResult(test, expected.msg, given.msg, reMsgsDiffer) - elif extractFilename(expected.file) != extractFilename(given.file) and + elif expected.tfile == "" and extractFilename(expected.file) != extractFilename(given.file) and "internal error:" notin expected.msg: r.addResult(test, expected.file, given.file, reFilesDiffer) elif expected.line != given.line and expected.line != 0 or @@ -162,6 +175,14 @@ proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) = r.addResult(test, $expected.line & ':' & $expected.column, $given.line & ':' & $given.column, reLinesDiffer) + elif expected.tfile != "" and extractFilename(expected.tfile) != extractFilename(given.tfile) and + "internal error:" notin expected.msg: + r.addResult(test, expected.tfile, given.tfile, reFilesDiffer) + elif expected.tline != given.tline and expected.tline != 0 or + expected.tcolumn != given.tcolumn and expected.tcolumn != 0: + r.addResult(test, $expected.tline & ':' & $expected.tcolumn, + $given.tline & ':' & $given.tcolumn, + reLinesDiffer) else: r.addResult(test, expected.msg, given.msg, reSuccess) inc(r.passed) From d9281adf8a7a8c90284ecae35907589c748ccea4 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Tue, 6 Oct 2015 15:53:55 -0700 Subject: [PATCH 17/19] run all tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 664466e2bf..c027386f56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,4 +26,4 @@ script: - nimble install zip - nimble install opengl - nimble install sdl1 - - ./koch test --pedantic + - ./koch test all --pedantic From 7f5c49e2047696d0d89ad18430456c62563509d8 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Tue, 6 Oct 2015 15:54:12 -0700 Subject: [PATCH 18/19] copy nimrtl into lib, reset LD_LIBRARY_PATH after use --- tests/testament/categories.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index afc4a616f3..9de33acb1f 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -89,8 +89,11 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = var libpath = getEnv"LD_LIBRARY_PATH".string # Temporarily add the lib directory to LD_LIBRARY_PATH: putEnv("LD_LIBRARY_PATH", "lib:" & libpath) + defer: putEnv("LD_LIBRARY_PATH", libpath) var serverDll = DynlibFormat % "server" safeCopyFile("tests/dll" / serverDll, "lib" / serverDll) + var nimrtlDll = DynlibFormat % "nimrtl" + safeCopyFile("tests/dll" / nimrtlDll, "lib" / nimrtlDll) testSpec r, makeTest("tests/dll/client.nim", options & " -d:useNimRtl", cat, actionRun) From 391f2fc9b1954061169978c484c7c2fe7047209a Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Tue, 6 Oct 2015 16:06:14 -0700 Subject: [PATCH 19/19] initialize new fields to empty values --- tests/testament/specs.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim index dcca8a66ea..bab17d2cd1 100644 --- a/tests/testament/specs.nim +++ b/tests/testament/specs.nim @@ -103,6 +103,9 @@ proc specDefaults*(result: var TSpec) = result.cmd = cmdTemplate result.line = 0 result.column = 0 + result.tfile = "" + result.tline = 0 + result.tcolumn = 0 proc parseSpec*(filename: string): TSpec = specDefaults(result)