summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2015-10-07 01:33:20 +0200
committerAndreas Rumpf <rumpf_a@web.de>2015-10-07 01:33:20 +0200
commit80ee72956af12b54853bfe05c1bd3fd3e47ff052 (patch)
tree5bfcbd23da6b313af1bcacae7b9c182600dabf18
parent2e413d3186455bf92ee9bae04304cb34cf1f2557 (diff)
parent391f2fc9b1954061169978c484c7c2fe7047209a (diff)
downloadNim-80ee72956af12b54853bfe05c1bd3fd3e47ff052.tar.gz
Merge pull request #3403 from tmm1/fix-test-failures
[WIP] Fix test failures in CI
-rw-r--r--.travis.yml19
-rw-r--r--lib/posix/posix.nim6
-rw-r--r--lib/pure/coro.nim2
-rw-r--r--lib/pure/coro.nimcfg1
-rw-r--r--lib/pure/math.nim2
-rw-r--r--lib/pure/nativesockets.nim1
-rw-r--r--lib/pure/ospaths.nim4
-rw-r--r--lib/pure/subexes.nim19
-rw-r--r--tests/enum/tenummix.nim4
-rw-r--r--tests/manyloc/keineschweine/lib/zlib_helpers.nim2
-rw-r--r--tests/manyloc/nake/nakefile.nim2
-rw-r--r--tests/method/tmapper.nim2
-rw-r--r--tests/misc/tnot.nim7
-rw-r--r--tests/objects/tillegal_recursion.nim2
-rw-r--r--tests/testament/categories.nim3
-rw-r--r--tests/testament/specs.nim8
-rw-r--r--tests/testament/tester.nim25
17 files changed, 75 insertions, 34 deletions
diff --git a/.travis.yml b/.travis.yml
index 486feb127..c027386f5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,14 +7,23 @@ addons:
     packages:
     - libcurl4-openssl-dev
     - libsdl1.2-dev
-script:
+before_script:
+  - set -e
+  - wget http://flatassembler.net/fasm-1.71.39.tgz
+  - tar xvf fasm-1.71.39.tgz
   - git clone --depth 1 https://github.com/nim-lang/csources.git
   - cd csources
   - sh build.sh
   - cd ..
-  - ./bin/nim c koch
+  - sed -i -e 's,cc = gcc,cc = clang,' config/nim.cfg
+  - export PATH=$(pwd)/bin:$(pwd)/fasm:$PATH
+script:
+  - nim c koch
   - ./koch boot
   - ./koch boot -d:release
-after_script:
-  - export PATH=$(pwd)/bin:$PATH
-  - ./koch test
+  - nim e install_nimble.nims
+  - nimble update
+  - nimble install zip
+  - nimble install opengl
+  - nimble install sdl1
+  - ./koch test all --pedantic
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index 8486fa04f..5f1dfcfcd 100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -1810,7 +1810,7 @@ proc ntohs*(a1: int16): int16 {.importc, header: "<arpa/inet.h>".}
 proc inet_addr*(a1: cstring): InAddrT {.importc, header: "<arpa/inet.h>".}
 proc inet_ntoa*(a1: InAddr): cstring {.importc, header: "<arpa/inet.h>".}
 proc inet_ntop*(a1: cint, a2: pointer, a3: cstring, a4: int32): cstring {.
-  importc, header: "<arpa/inet.h>".}
+  importc:"(char *)$1", header: "<arpa/inet.h>".}
 proc inet_pton*(a1: cint, a2: cstring, a3: pointer): cint {.
   importc, header: "<arpa/inet.h>".}
 
@@ -2381,7 +2381,7 @@ proc sched_setscheduler*(a1: Pid, a2: cint, a3: var Sched_param): cint {.
 proc sched_yield*(): cint {.importc, header: "<sched.h>".}
 
 proc strerror*(errnum: cint): cstring {.importc, header: "<string.h>".}
-proc hstrerror*(herrnum: cint): cstring {.importc, header: "<netdb.h>".}
+proc hstrerror*(herrnum: cint): cstring {.importc:"(char *)$1", header: "<netdb.h>".}
 
 proc FD_CLR*(a1: cint, a2: var TFdSet) {.importc, header: "<sys/select.h>".}
 proc FD_ISSET*(a1: cint | SocketHandle, a2: var TFdSet): cint {.
@@ -2565,7 +2565,7 @@ proc endprotoent*() {.importc, header: "<netdb.h>".}
 proc endservent*() {.importc, header: "<netdb.h>".}
 proc freeaddrinfo*(a1: ptr AddrInfo) {.importc, header: "<netdb.h>".}
 
-proc gai_strerror*(a1: cint): cstring {.importc, header: "<netdb.h>".}
+proc gai_strerror*(a1: cint): cstring {.importc:"(char *)$1", header: "<netdb.h>".}
 
 proc getaddrinfo*(a1, a2: cstring, a3: ptr AddrInfo,
                   a4: var ptr AddrInfo): cint {.importc, header: "<netdb.h>".}
diff --git a/lib/pure/coro.nim b/lib/pure/coro.nim
index 8fa529474..c5724f26f 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()
 
diff --git a/lib/pure/coro.nimcfg b/lib/pure/coro.nimcfg
new file mode 100644
index 000000000..b011bc585
--- /dev/null
+++ b/lib/pure/coro.nimcfg
@@ -0,0 +1 @@
+-d:nimCoroutines
diff --git a/lib/pure/math.nim b/lib/pure/math.nim
index 06a018d9f..391a880ae 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))
diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim
index b5661c4d3..c9e067a3e 100644
--- a/lib/pure/nativesockets.nim
+++ b/lib/pure/nativesockets.nim
@@ -349,7 +349,6 @@ proc getAddrString*(sockAddr: ptr SockAddr): string =
   elif sockAddr.sa_family == nativeAfInet6:
     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,
diff --git a/lib/pure/ospaths.nim b/lib/pure/ospaths.nim
index dcc710193..667ca82d7 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.}
diff --git a/lib/pure/subexes.nim b/lib/pure/subexes.nim
index 2d1adc0eb..5824ace81 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)"""
+    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"""
+        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"""
-
-
+          fieldNameD""")
diff --git a/tests/enum/tenummix.nim b/tests/enum/tenummix.nim
index 4352cdd81..c7db4e056 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/manyloc/keineschweine/lib/zlib_helpers.nim b/tests/manyloc/keineschweine/lib/zlib_helpers.nim
index 5241a77c0..076475964 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 6dc453e8d..2fe07ec17 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()
diff --git a/tests/method/tmapper.nim b/tests/method/tmapper.nim
index 0008d9033..75b36e69a 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
 """
 
diff --git a/tests/misc/tnot.nim b/tests/misc/tnot.nim
index 60d23c035..8c75c6bc0 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/objects/tillegal_recursion.nim b/tests/objects/tillegal_recursion.nim
index 171a04f87..222139101 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
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index afc4a616f..9de33acb1 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)
diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim
index 99640f22c..bab17d2cd 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
@@ -101,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)
@@ -116,6 +121,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 e52988682..636093a7f 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)
@@ -282,7 +303,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)