mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-19 01:18:32 +00:00
Merge pull request #3403 from tmm1/fix-test-failures
[WIP] Fix test failures in CI
This commit is contained in:
19
.travis.yml
19
.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
|
||||
|
||||
@@ -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>".}
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
1
lib/pure/coro.nimcfg
Normal file
1
lib/pure/coro.nimcfg
Normal file
@@ -0,0 +1 @@
|
||||
-d:nimCoroutines
|
||||
@@ -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))
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.}
|
||||
|
||||
@@ -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""")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
file: "tenummix.nim"
|
||||
line: 11
|
||||
tfile: "tenummix.nim"
|
||||
tline: 11
|
||||
errormsg: "type mismatch"
|
||||
"""
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import zlib
|
||||
import zip/zlib
|
||||
|
||||
proc compress*(source: string): string =
|
||||
var
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import nake
|
||||
import httpclient, zipfiles, times, math
|
||||
import httpclient, zip/zipfiles, times, math
|
||||
nakeImports
|
||||
|
||||
randomize()
|
||||
|
||||
@@ -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
|
||||
"""
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
errormsg: "illegal recursion in type 'object'"
|
||||
errormsg: "inheritance only works with non-final objects"
|
||||
line: 7
|
||||
"""
|
||||
# bug #1691
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user