diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2020-04-29 00:07:15 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2020-04-29 00:07:15 -0500 |
| commit | 9a93417ae21ddd11037505f58ad793aebea8644a (patch) | |
| tree | 653272315531526f92d30e64cca4321db3e474ca | |
| parent | 492eba8f22c6fb0070274590490f2977e357de2a (diff) | |
| download | nimterop-9a93417ae21ddd11037505f58ad793aebea8644a.tar.gz nimterop-9a93417ae21ddd11037505f58ad793aebea8644a.zip | |
Fix timeit for legacy, reduce Windows test matrix
| -rw-r--r-- | nimterop.nimble | 6 | ||||
| -rw-r--r-- | nimterop/build.nim | 18 | ||||
| -rw-r--r-- | nimterop/cimport.nim | 2 | ||||
| -rw-r--r-- | nimterop/docs.nim | 4 | ||||
| -rw-r--r-- | nimterop/nimconf.nim | 2 | ||||
| -rw-r--r-- | nimterop/template.nim | 2 | ||||
| -rw-r--r-- | tests/getheader.nims | 10 | ||||
| -rw-r--r-- | tests/timeit.nim | 13 | ||||
| -rw-r--r-- | tests/tmath.nim | 2 | ||||
| -rw-r--r-- | tests/tnimterop_c.nim | 2 | ||||
| -rw-r--r-- | tests/tpcre.nim | 2 | ||||
| -rw-r--r-- | tests/zlib.nim | 2 |
12 files changed, 37 insertions, 28 deletions
diff --git a/nimterop.nimble b/nimterop.nimble index 8b6a756..579d315 100644 --- a/nimterop.nimble +++ b/nimterop.nimble @@ -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() diff --git a/nimterop/build.nim b/nimterop/build.nim index e11cd7b..5bfec76 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -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.]*" diff --git a/nimterop/cimport.nim b/nimterop/cimport.nim index 47dc0eb..4cb364d 100644 --- a/nimterop/cimport.nim +++ b/nimterop/cimport.nim @@ -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: diff --git a/nimterop/docs.nim b/nimterop/docs.nim index 6eb812b..d808535 100644 --- a/nimterop/docs.nim +++ b/nimterop/docs.nim @@ -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 diff --git a/nimterop/nimconf.nim b/nimterop/nimconf.nim index 664675e..144a7e0 100644 --- a/nimterop/nimconf.nim +++ b/nimterop/nimconf.nim @@ -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 = diff --git a/nimterop/template.nim b/nimterop/template.nim index f625280..c6e846f 100644 --- a/nimterop/template.nim +++ b/nimterop/template.nim @@ -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 diff --git a/tests/getheader.nims b/tests/getheader.nims index 72407f9..2e6530f 100644 --- a/tests/getheader.nims +++ b/tests/getheader.nims @@ -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) @@ -44,10 +49,5 @@ 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) diff --git a/tests/timeit.nim b/tests/timeit.nim index b52eae5..b448191 100644 --- a/tests/timeit.nim +++ b/tests/timeit.nim @@ -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: "" diff --git a/tests/tmath.nim b/tests/tmath.nim index b8477c1..6c7999a 100644 --- a/tests/tmath.nim +++ b/tests/tmath.nim @@ -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 diff --git a/tests/tnimterop_c.nim b/tests/tnimterop_c.nim index 0360225..8428489 100644 --- a/tests/tnimterop_c.nim +++ b/tests/tnimterop_c.nim @@ -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 diff --git a/tests/tpcre.nim b/tests/tpcre.nim index c8e8059..4a426c4 100644 --- a/tests/tpcre.nim +++ b/tests/tpcre.nim @@ -14,7 +14,7 @@ static: const dynpcre = - when defined(windows): + when defined(Windows): when defined(cpu64): "pcre64.dll" else: diff --git a/tests/zlib.nim b/tests/zlib.nim index ce26c9a..09a6df2 100644 --- a/tests/zlib.nim +++ b/tests/zlib.nim @@ -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") |
