Merge pull request #3428 from tmm1/appveyor

[WIP] Add AppVeyor config to run tests on win32
This commit is contained in:
Andreas Rumpf 2015-10-14 13:40:58 +02:00
commit 5a02230bf9
7 changed files with 68 additions and 7 deletions

View file

@ -26,4 +26,5 @@ script:
- nimble install zip - nimble install zip
- nimble install opengl - nimble install opengl
- nimble install sdl1 - nimble install sdl1
- ./koch test all --pedantic - nim c --taintMode:on tests/testament/tester
- tests/testament/tester --pedantic all

36
appveyor.yml Normal file
View file

@ -0,0 +1,36 @@
clone_depth: 5
artifacts:
- path: bin\nim.exe
platform:
- x64
before_build:
- git log -1
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S zlib-devel"
- appveyor DownloadFile http://nim-lang.org/download/dlls.zip
- 7z e dlls.zip -odlls
- del dlls\libcurl.dll
- appveyor DownloadFile http://flatassembler.net/fasmw17139.zip
- 7z e fasmw17139.zip -obin fasm.exe
build_script:
- SET PATH=C:\msys64\mingw64\bin;dlls;bin;%PATH%
- gcc -v
- git clone -q --depth 1 https://github.com/nim-lang/csources
- cd csources
- build64.bat
- cd ..
- nim c koch
- koch boot
- koch boot -d:release
before_test:
- nim e install_nimble.nims
- nimble update
- nimble install zip
test_script:
- nim c --taintMode:on tests/testament/tester
- tests\testament\tester --pedantic all

View file

@ -342,6 +342,7 @@ proc tests(args: string) =
exec "nim c --lib:lib -d:release --opt:speed compiler/nim.nim" exec "nim c --lib:lib -d:release --opt:speed compiler/nim.nim"
let tester = quoteShell(getCurrentDir() / "tests/testament/tester".exe) let tester = quoteShell(getCurrentDir() / "tests/testament/tester".exe)
let success = tryExec tester & " " & (args|"all") let success = tryExec tester & " " & (args|"all")
if not existsEnv("TRAVIS") and not existsEnv("APPVEYOR"):
exec tester & " html" exec tester & " html"
if not success: if not success:
quit("tests failed", QuitFailure) quit("tests failed", QuitFailure)

View file

@ -3,8 +3,8 @@ discard """
""" """
{.emit: """ {.emit: """
long sum(long* a, long len) { NI sum(NI* a, NI len) {
long i, result = 0; NI i, result = 0;
for (i = 0; i < len; ++i) result += a[i]; for (i = 0; i < len; ++i) result += a[i];
return result; return result;
} }

View file

@ -112,7 +112,8 @@ proc writeTestResult*(name, category, target,
thisCommit, thisMachine) thisCommit, thisMachine)
proc open*() = proc open*() =
db = open(connection="testament.db", user="testament", password="", let dbFile = if existsEnv("TRAVIS") or existsEnv("APPVEYOR"): ":memory:" else: "testament.db"
db = open(connection=dbFile, user="testament", password="",
database="testament") database="testament")
createDb() createDb()
thisMachine = getMachine(db) thisMachine = getMachine(db)

View file

@ -82,6 +82,8 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) =
when defined(Windows): when defined(Windows):
# windows looks in the dir of the exe (yay!): # windows looks in the dir of the exe (yay!):
var serverDll = DynlibFormat % "server"
safeCopyFile("lib" / serverDll, "tests/dll" / serverDll)
var nimrtlDll = DynlibFormat % "nimrtl" var nimrtlDll = DynlibFormat % "nimrtl"
safeCopyFile("lib" / nimrtlDll, "tests/dll" / nimrtlDll) safeCopyFile("lib" / nimrtlDll, "tests/dll" / nimrtlDll)
else: else:

View file

@ -12,7 +12,7 @@
import import
parseutils, strutils, pegs, os, osproc, streams, parsecfg, json, parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
marshal, backend, parseopt, specs, htmlgen, browsers, terminal, marshal, backend, parseopt, specs, htmlgen, browsers, terminal,
algorithm, compiler/nodejs, re algorithm, compiler/nodejs, re, times
const const
resultsFile = "testresults.html" resultsFile = "testresults.html"
@ -47,6 +47,7 @@ type
options: string options: string
target: TTarget target: TTarget
action: TTestAction action: TTestAction
startTime: float
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
@ -104,6 +105,12 @@ proc callCompiler(cmdTemplate, filename, options: string,
elif suc =~ pegSuccess: elif suc =~ pegSuccess:
result.err = reSuccess result.err = reSuccess
if result.err == reNimcCrash and
("Your platform is not supported" in result.msg or
"cannot open 'sdl'" in result.msg or
"cannot open 'opengl'" in result.msg):
result.err = reIgnored
proc callCCompiler(cmdTemplate, filename, options: string, proc callCCompiler(cmdTemplate, filename, options: string,
target: TTarget): TSpec = target: TTarget): TSpec =
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target], let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
@ -143,6 +150,7 @@ proc `$`(x: TResults): string =
proc addResult(r: var TResults, test: TTest, proc addResult(r: var TResults, test: TTest,
expected, given: string, success: TResultEnum) = expected, given: string, success: TResultEnum) =
let name = test.name.extractFilename & test.options let name = test.name.extractFilename & test.options
let duration = epochTime() - test.startTime
backend.writeTestResult(name = name, backend.writeTestResult(name = name,
category = test.cat.string, category = test.cat.string,
target = $test.target, target = $test.target,
@ -164,6 +172,18 @@ proc addResult(r: var TResults, test: TTest,
styledEcho fgYellow, "Gotten:" styledEcho fgYellow, "Gotten:"
styledEcho styleBright, given, "\n" styledEcho styleBright, given, "\n"
if existsEnv("APPVEYOR"):
let (outcome, msg) =
if success == reSuccess:
("Passed", "")
elif success == reIgnored:
("Skipped", "")
else:
("Failed", "Failure: " & $success & "\nExpected:\n" & expected & "\n\n" & "Gotten:\n" & given)
var p = startProcess("appveyor", args=["AddTest", test.name.replace("\\", "/") & test.options, "-Framework", "nim-testament", "-FileName", test.cat.string, "-Outcome", outcome, "-ErrorMessage", msg, "-Duration", $(duration*1000).int], options={poStdErrToStdOut, poUsePath, poParentStreams})
discard waitForExit(p)
close(p)
proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) = proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
if strip(expected.msg) notin strip(given.msg): if strip(expected.msg) notin strip(given.msg):
r.addResult(test, expected.msg, given.msg, reMsgsDiffer) r.addResult(test, expected.msg, given.msg, reMsgsDiffer)
@ -356,7 +376,7 @@ proc makeTest(test, options: string, cat: Category, action = actionCompile,
target = targetC, env: string = ""): TTest = target = targetC, env: string = ""): TTest =
# start with 'actionCompile', will be overwritten in the spec: # start with 'actionCompile', will be overwritten in the spec:
result = TTest(cat: cat, name: test, options: options, result = TTest(cat: cat, name: test, options: options,
target: target, action: action) target: target, action: action, startTime: epochTime())
include categories include categories