Fix timeit for legacy, reduce Windows test matrix
This commit is contained in:
parent
492eba8f22
commit
9a93417ae2
12 changed files with 37 additions and 28 deletions
|
|
@ -70,8 +70,10 @@ task test, "Test":
|
||||||
# getHeader tests
|
# getHeader tests
|
||||||
withDir("tests"):
|
withDir("tests"):
|
||||||
exec "nim e getheader.nims"
|
exec "nim e getheader.nims"
|
||||||
if not existsEnv("APPVEYOR"):
|
when not defined(Windows):
|
||||||
exec "nim e wrappers.nims"
|
# Skip on Windows since very slow
|
||||||
|
if not existsEnv("APPVEYOR"):
|
||||||
|
exec "nim e wrappers.nims"
|
||||||
|
|
||||||
docsTask()
|
docsTask()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ proc sleep*(milsecs: int) =
|
||||||
## Sleep at compile time
|
## Sleep at compile time
|
||||||
let
|
let
|
||||||
cmd =
|
cmd =
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
"cmd /c timeout "
|
"cmd /c timeout "
|
||||||
else:
|
else:
|
||||||
"sleep "
|
"sleep "
|
||||||
|
|
@ -110,7 +110,7 @@ proc findExe*(exe: string): string =
|
||||||
## at compile time
|
## at compile time
|
||||||
var
|
var
|
||||||
cmd =
|
cmd =
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
"where " & exe
|
"where " & exe
|
||||||
else:
|
else:
|
||||||
"which " & exe
|
"which " & exe
|
||||||
|
|
@ -354,7 +354,7 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex =
|
||||||
## `first`. Without it, the shortest match is returned.
|
## `first`. Without it, the shortest match is returned.
|
||||||
var
|
var
|
||||||
cmd =
|
cmd =
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
"nimgrep --filenames --oneline --nocolor $1 \"$2\" $3"
|
"nimgrep --filenames --oneline --nocolor $1 \"$2\" $3"
|
||||||
elif defined(linux):
|
elif defined(linux):
|
||||||
"find $3 $1 -regextype egrep -regex $2"
|
"find $3 $1 -regextype egrep -regex $2"
|
||||||
|
|
@ -364,10 +364,10 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex =
|
||||||
recursive = ""
|
recursive = ""
|
||||||
|
|
||||||
if recurse:
|
if recurse:
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
recursive = "--recursive"
|
recursive = "--recursive"
|
||||||
else:
|
else:
|
||||||
when not defined(windows):
|
when not defined(Windows):
|
||||||
recursive = "-maxdepth 1"
|
recursive = "-maxdepth 1"
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
@ -388,7 +388,7 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex =
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
for line in files.splitLines():
|
for line in files.splitLines():
|
||||||
let f =
|
let f =
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
if ": " in line:
|
if ": " in line:
|
||||||
line.split(": ", maxsplit = 1)[1]
|
line.split(": ", maxsplit = 1)[1]
|
||||||
else:
|
else:
|
||||||
|
|
@ -750,7 +750,7 @@ proc getLocalPath(header, outdir: string): string =
|
||||||
result = findFile(header, outdir)
|
result = findFile(header, outdir)
|
||||||
|
|
||||||
proc getNumProcs(): string =
|
proc getNumProcs(): string =
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
getEnv("NUMBER_OF_PROCESSORS").strip()
|
getEnv("NUMBER_OF_PROCESSORS").strip()
|
||||||
elif defined(linux):
|
elif defined(linux):
|
||||||
execAction("nproc").output.strip()
|
execAction("nproc").output.strip()
|
||||||
|
|
@ -778,7 +778,7 @@ proc buildLibrary(lname, outdir, conFlags, cmakeFlags, makeFlags: string): strin
|
||||||
if findExe("cmake").len != 0:
|
if findExe("cmake").len != 0:
|
||||||
var
|
var
|
||||||
gen = ""
|
gen = ""
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
if findExe("sh").len != 0:
|
if findExe("sh").len != 0:
|
||||||
let
|
let
|
||||||
uname = execAction("sh -c uname -a").output.toLowerAscii()
|
uname = execAction("sh -c uname -a").output.toLowerAscii()
|
||||||
|
|
@ -828,7 +828,7 @@ proc buildLibrary(lname, outdir, conFlags, cmakeFlags, makeFlags: string): strin
|
||||||
result = findFile(lname, outdir, regex = true)
|
result = findFile(lname, outdir, regex = true)
|
||||||
|
|
||||||
proc getDynlibExt(): string =
|
proc getDynlibExt(): string =
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
result = ".dll"
|
result = ".dll"
|
||||||
elif defined(linux) or defined(FreeBSD):
|
elif defined(linux) or defined(FreeBSD):
|
||||||
result = ".so[0-9.]*"
|
result = ".so[0-9.]*"
|
||||||
|
|
|
||||||
|
|
@ -623,7 +623,7 @@ macro cImport*(filename: static string, recurse: static bool = false, dynlib: st
|
||||||
##
|
##
|
||||||
## const
|
## const
|
||||||
## dynpcre =
|
## dynpcre =
|
||||||
## when defined(windows):
|
## when defined(Windows):
|
||||||
## when defined(cpu64):
|
## when defined(cpu64):
|
||||||
## "pcre64.dll"
|
## "pcre64.dll"
|
||||||
## else:
|
## else:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ proc getNimRootDir(): string =
|
||||||
fmt"{currentSourcePath}".parentDir.parentDir.parentDir
|
fmt"{currentSourcePath}".parentDir.parentDir.parentDir
|
||||||
|
|
||||||
const
|
const
|
||||||
DirSep = when defined(windows): '\\' else: '/'
|
DirSep = when defined(Windows): '\\' else: '/'
|
||||||
|
|
||||||
proc execAction(cmd: string): string =
|
proc execAction(cmd: string): string =
|
||||||
var
|
var
|
||||||
|
|
@ -53,7 +53,7 @@ proc buildDocs*(files: openArray[string], path: string, baseDir = getProjectPath
|
||||||
##
|
##
|
||||||
## NOTE: `buildDocs()` only works correctly on Windows with Nim 1.0+ since
|
## NOTE: `buildDocs()` only works correctly on Windows with Nim 1.0+ since
|
||||||
## https://github.com/nim-lang/Nim/pull/11814 is required.
|
## https://github.com/nim-lang/Nim/pull/11814 is required.
|
||||||
when defined(windows) and (NimMajor, NimMinor, NimPatch) < (1, 0, 0):
|
when defined(Windows) and (NimMajor, NimMinor, NimPatch) < (1, 0, 0):
|
||||||
echo "buildDocs() unsupported on Windows for Nim < 1.0 - requires PR #11814"
|
echo "buildDocs() unsupported on Windows for Nim < 1.0 - requires PR #11814"
|
||||||
else:
|
else:
|
||||||
let
|
let
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ proc getNimConfigFlags(cfg: Config): string =
|
||||||
for path in cfg.paths:
|
for path in cfg.paths:
|
||||||
result &= &"--path:\"{path}\"\n"
|
result &= &"--path:\"{path}\"\n"
|
||||||
|
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
result = result.replace("\\", "/")
|
result = result.replace("\\", "/")
|
||||||
|
|
||||||
proc getNimConfigFlags*(projectDir = ""): string =
|
proc getNimConfigFlags*(projectDir = ""): string =
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ cDefine("SYMBOL", "value")
|
||||||
cCompile(srcDir/"file.c")
|
cCompile(srcDir/"file.c")
|
||||||
|
|
||||||
# Perform OS specific tasks
|
# Perform OS specific tasks
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
# Windows specific symbols, options and files
|
# Windows specific symbols, options and files
|
||||||
|
|
||||||
# Dynamic library to link against
|
# Dynamic library to link against
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,11 @@ when defined(posix):
|
||||||
testCall(cmd & " -d:lzmaGit -d:lzmaSetVer=v5.2.0" & lrcmd, lexp & "5.2.0", 0)
|
testCall(cmd & " -d:lzmaGit -d:lzmaSetVer=v5.2.0" & lrcmd, lexp & "5.2.0", 0)
|
||||||
testCall(cmd & " -d:lzmaGit -d:lzmaStatic -d:lzmaSetVer=v5.2.0" & lrcmd, lexp & "5.2.0", 0, delete = false)
|
testCall(cmd & " -d:lzmaGit -d:lzmaStatic -d:lzmaSetVer=v5.2.0" & lrcmd, lexp & "5.2.0", 0, delete = false)
|
||||||
|
|
||||||
|
# dl - remove from Windows to save some time
|
||||||
|
testCall(cmd & " -d:lzmaDL" & lrcmd, "Need version", 1)
|
||||||
|
testCall(cmd & " -d:lzmaDL -d:lzmaSetVer=5.2.4" & lrcmd, lexp & "5.2.4", 0)
|
||||||
|
testCall(cmd & " -d:lzmaDL -d:lzmaStatic -d:lzmaSetVer=5.2.4" & lrcmd, lexp & "5.2.4", 0, delete = false)
|
||||||
|
|
||||||
# git
|
# git
|
||||||
testCall(cmd & " -d:envTest" & zrcmd, zexp, 0)
|
testCall(cmd & " -d:envTest" & zrcmd, zexp, 0)
|
||||||
testCall(cmd & " -d:envTestStatic" & zrcmd, zexp, 0, delete = false)
|
testCall(cmd & " -d:envTestStatic" & zrcmd, zexp, 0, delete = false)
|
||||||
|
|
@ -43,11 +48,6 @@ testCall(cmd & " -d:envTestStatic" & zrcmd, zexp, 0, delete = false)
|
||||||
testCall(cmd & " -d:zlibGit -d:zlibSetVer=v1.2.10" & zrcmd, zexp & "1.2.10", 0)
|
testCall(cmd & " -d:zlibGit -d:zlibSetVer=v1.2.10" & zrcmd, zexp & "1.2.10", 0)
|
||||||
testCall(cmd & " -d:zlibGit -d:zlibStatic -d:zlibSetVer=v1.2.10" & zrcmd, zexp & "1.2.10", 0, delete = false)
|
testCall(cmd & " -d:zlibGit -d:zlibStatic -d:zlibSetVer=v1.2.10" & zrcmd, zexp & "1.2.10", 0, delete = false)
|
||||||
|
|
||||||
# dl
|
|
||||||
testCall(cmd & " -d:lzmaDL" & lrcmd, "Need version", 1)
|
|
||||||
testCall(cmd & " -d:lzmaDL -d:lzmaSetVer=5.2.4" & lrcmd, lexp & "5.2.4", 0)
|
|
||||||
testCall(cmd & " -d:lzmaDL -d:lzmaStatic -d:lzmaSetVer=5.2.4" & lrcmd, lexp & "5.2.4", 0, delete = false)
|
|
||||||
|
|
||||||
# dl
|
# dl
|
||||||
testCall(cmd & " -d:zlibDL -d:zlibSetVer=1.2.11" & zrcmd, zexp & "1.2.11", 0)
|
testCall(cmd & " -d:zlibDL -d:zlibSetVer=1.2.11" & zrcmd, zexp & "1.2.11", 0)
|
||||||
testCall(cmd & " -d:zlibDL -d:zlibStatic -d:zlibSetVer=1.2.11" & zrcmd, zexp & "1.2.11", 0, delete = false)
|
testCall(cmd & " -d:zlibDL -d:zlibStatic -d:zlibSetVer=1.2.11" & zrcmd, zexp & "1.2.11", 0, delete = false)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,11 @@
|
||||||
import std/monotimes, os, osproc, sequtils, strformat, strutils, times
|
import os, osproc, sequtils, strformat, strutils, times
|
||||||
|
|
||||||
|
when (NimMajor, NimMinor) >= (1, 0):
|
||||||
|
import std/monotimes
|
||||||
|
|
||||||
|
template getTime(): MonoTime = getMonoTime()
|
||||||
|
else:
|
||||||
|
template getTime(): float = epochTime()
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var params = commandLineParams()
|
var params = commandLineParams()
|
||||||
|
|
@ -9,9 +16,9 @@ when isMainModule:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
start = getMonoTime()
|
start = getTime()
|
||||||
ret = execCmd(cmd)
|
ret = execCmd(cmd)
|
||||||
endt = getMonoTime()
|
endt = getTime()
|
||||||
|
|
||||||
outf = getAppDir() / "timeit.txt"
|
outf = getAppDir() / "timeit.txt"
|
||||||
outd = if fileExists(outf): readFile(outf) else: ""
|
outd = if fileExists(outf): readFile(outf) else: ""
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ cOverride:
|
||||||
mingw_ldbl_type_t = object
|
mingw_ldbl_type_t = object
|
||||||
mingw_dbl_type_t = object
|
mingw_dbl_type_t = object
|
||||||
|
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
cOverride:
|
cOverride:
|
||||||
type
|
type
|
||||||
complex = object
|
complex = object
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ check TEST_STR == "hello world"
|
||||||
|
|
||||||
when defined(osx):
|
when defined(osx):
|
||||||
check OSDEF == 10
|
check OSDEF == 10
|
||||||
elif defined(windows):
|
elif defined(Windows):
|
||||||
check OSDEF == 20
|
check OSDEF == 20
|
||||||
else:
|
else:
|
||||||
check OSDEF == 30
|
check OSDEF == 30
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ static:
|
||||||
|
|
||||||
const
|
const
|
||||||
dynpcre =
|
dynpcre =
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
when defined(cpu64):
|
when defined(cpu64):
|
||||||
"pcre64.dll"
|
"pcre64.dll"
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ proc zlibPreBuild(outdir, path: string) =
|
||||||
# Delete default Makefile
|
# Delete default Makefile
|
||||||
if mf.readFile().contains("configure first"):
|
if mf.readFile().contains("configure first"):
|
||||||
mf.rmFile()
|
mf.rmFile()
|
||||||
when defined(windows):
|
when defined(Windows):
|
||||||
# Fix static lib name on Windows
|
# Fix static lib name on Windows
|
||||||
setCmakeLibName(outdir, "zlibstatic", prefix = "lib", oname = "zlib", suffix = ".a")
|
setCmakeLibName(outdir, "zlibstatic", prefix = "lib", oname = "zlib", suffix = ".a")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue