Fix timeit for legacy, reduce Windows test matrix

This commit is contained in:
Ganesh Viswanathan 2020-04-29 00:07:15 -05:00
commit 9a93417ae2
12 changed files with 37 additions and 28 deletions

View file

@ -70,8 +70,10 @@ task test, "Test":
# getHeader tests
withDir("tests"):
exec "nim e getheader.nims"
if not existsEnv("APPVEYOR"):
exec "nim e wrappers.nims"
when not defined(Windows):
# Skip on Windows since very slow
if not existsEnv("APPVEYOR"):
exec "nim e wrappers.nims"
docsTask()

View file

@ -34,7 +34,7 @@ proc sleep*(milsecs: int) =
## Sleep at compile time
let
cmd =
when defined(windows):
when defined(Windows):
"cmd /c timeout "
else:
"sleep "
@ -110,7 +110,7 @@ proc findExe*(exe: string): string =
## at compile time
var
cmd =
when defined(windows):
when defined(Windows):
"where " & exe
else:
"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.
var
cmd =
when defined(windows):
when defined(Windows):
"nimgrep --filenames --oneline --nocolor $1 \"$2\" $3"
elif defined(linux):
"find $3 $1 -regextype egrep -regex $2"
@ -364,10 +364,10 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex =
recursive = ""
if recurse:
when defined(windows):
when defined(Windows):
recursive = "--recursive"
else:
when not defined(windows):
when not defined(Windows):
recursive = "-maxdepth 1"
var
@ -388,7 +388,7 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex =
if ret == 0:
for line in files.splitLines():
let f =
when defined(windows):
when defined(Windows):
if ": " in line:
line.split(": ", maxsplit = 1)[1]
else:
@ -750,7 +750,7 @@ proc getLocalPath(header, outdir: string): string =
result = findFile(header, outdir)
proc getNumProcs(): string =
when defined(windows):
when defined(Windows):
getEnv("NUMBER_OF_PROCESSORS").strip()
elif defined(linux):
execAction("nproc").output.strip()
@ -778,7 +778,7 @@ proc buildLibrary(lname, outdir, conFlags, cmakeFlags, makeFlags: string): strin
if findExe("cmake").len != 0:
var
gen = ""
when defined(windows):
when defined(Windows):
if findExe("sh").len != 0:
let
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)
proc getDynlibExt(): string =
when defined(windows):
when defined(Windows):
result = ".dll"
elif defined(linux) or defined(FreeBSD):
result = ".so[0-9.]*"

View file

@ -623,7 +623,7 @@ macro cImport*(filename: static string, recurse: static bool = false, dynlib: st
##
## const
## dynpcre =
## when defined(windows):
## when defined(Windows):
## when defined(cpu64):
## "pcre64.dll"
## else:

View file

@ -19,7 +19,7 @@ proc getNimRootDir(): string =
fmt"{currentSourcePath}".parentDir.parentDir.parentDir
const
DirSep = when defined(windows): '\\' else: '/'
DirSep = when defined(Windows): '\\' else: '/'
proc execAction(cmd: string): string =
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
## 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"
else:
let

View file

@ -187,7 +187,7 @@ proc getNimConfigFlags(cfg: Config): string =
for path in cfg.paths:
result &= &"--path:\"{path}\"\n"
when defined(windows):
when defined(Windows):
result = result.replace("\\", "/")
proc getNimConfigFlags*(projectDir = ""): string =

View file

@ -70,7 +70,7 @@ cDefine("SYMBOL", "value")
cCompile(srcDir/"file.c")
# Perform OS specific tasks
when defined(windows):
when defined(Windows):
# Windows specific symbols, options and files
# Dynamic library to link against

View file

@ -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: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
testCall(cmd & " -d:envTest" & zrcmd, zexp, 0)
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: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
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)

View file

@ -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:
var params = commandLineParams()
@ -9,9 +16,9 @@ when isMainModule:
let
start = getMonoTime()
start = getTime()
ret = execCmd(cmd)
endt = getMonoTime()
endt = getTime()
outf = getAppDir() / "timeit.txt"
outd = if fileExists(outf): readFile(outf) else: ""

View file

@ -7,7 +7,7 @@ cOverride:
mingw_ldbl_type_t = object
mingw_dbl_type_t = object
when defined(windows):
when defined(Windows):
cOverride:
type
complex = object

View file

@ -45,7 +45,7 @@ check TEST_STR == "hello world"
when defined(osx):
check OSDEF == 10
elif defined(windows):
elif defined(Windows):
check OSDEF == 20
else:
check OSDEF == 30

View file

@ -14,7 +14,7 @@ static:
const
dynpcre =
when defined(windows):
when defined(Windows):
when defined(cpu64):
"pcre64.dll"
else:

View file

@ -15,7 +15,7 @@ proc zlibPreBuild(outdir, path: string) =
# Delete default Makefile
if mf.readFile().contains("configure first"):
mf.rmFile()
when defined(windows):
when defined(Windows):
# Fix static lib name on Windows
setCmakeLibName(outdir, "zlibstatic", prefix = "lib", oname = "zlib", suffix = ".a")