2022-11-23 05:54:10 +00:00
|
|
|
mode = ScriptMode.Verbose
|
|
|
|
|
2019-02-06 14:49:11 +00:00
|
|
|
packageName = "chronos"
|
2024-08-21 23:53:48 +00:00
|
|
|
version = "4.0.3"
|
2018-05-16 08:22:34 +00:00
|
|
|
author = "Status Research & Development GmbH"
|
2022-11-23 05:54:10 +00:00
|
|
|
description = "Networking framework with async/await support"
|
|
|
|
license = "MIT or Apache License 2.0"
|
2019-02-06 15:24:57 +00:00
|
|
|
skipDirs = @["tests"]
|
2018-05-16 08:22:34 +00:00
|
|
|
|
2024-01-24 17:33:13 +00:00
|
|
|
requires "nim >= 1.6.16",
|
2023-11-13 09:56:19 +00:00
|
|
|
"results",
|
2020-07-12 16:22:47 +00:00
|
|
|
"stew",
|
2024-07-18 17:59:03 +00:00
|
|
|
"bearssl >= 0.2.5",
|
exception tracking (#166)
* exception tracking
This PR adds minimal exception tracking to chronos, moving the goalpost
one step further.
In particular, it becomes invalid to raise exceptions from `callSoon`
callbacks: this is critical for writing correct error handling because
there's no reasonable way that a user of chronos can possibly _reason_
about exceptions coming out of there: the event loop will be in an
indeterminite state when the loop is executing an _random_ callback.
As expected, there are several issues in the error handling of chronos:
in particular, it will end up in an inconsistent internal state whenever
the selector loop operations fail, because the internal state update
functions are not written in an exception-safe way. This PR turns this
into a Defect, which probably is not the optimal way of handling things
- expect more work to be done here.
Some API have no way of reporting back errors to callers - for example,
when something fails in the accept loop, there's not much it can do, and
no way to report it back to the user of the API - this has been fixed
with the new accept flow - the old one should be deprecated.
Finally, there is information loss in the API: in composite operations
like `poll` and `waitFor` there's no way to differentiate internal
errors from user-level errors originating from callbacks.
* store `CatchableError` in future
* annotate proc's with correct raises information
* `selectors2` to avoid non-CatchableError IOSelectorsException
* `$` should never raise
* remove unnecessary gcsafe annotations
* fix exceptions leaking out of timer waits
* fix some imports
* functions must signal raising the union of all exceptions across all
platforms to enable cross-platform code
* switch to unittest2
* add `selectors2` which supercedes the std library version and fixes
several exception handling issues in there
* fixes
* docs, platform-independent eh specifiers for some functions
* add feature flag for strict exception mode
also bump version to 3.0.0 - _most_ existing code should be compatible
with this version of exception handling but some things might need
fixing - callbacks, existing raises specifications etc.
* fix AsyncCheck for non-void T
2021-03-24 09:08:33 +00:00
|
|
|
"httputils",
|
2022-06-29 14:22:57 +00:00
|
|
|
"unittest2"
|
2018-05-16 08:22:34 +00:00
|
|
|
|
2023-11-15 08:06:37 +00:00
|
|
|
import os, strutils
|
2023-11-08 15:14:33 +00:00
|
|
|
|
2022-11-23 05:54:10 +00:00
|
|
|
let nimc = getEnv("NIMC", "nim") # Which nim compiler to use
|
|
|
|
let lang = getEnv("NIMLANG", "c") # Which backend (c/cpp/js)
|
|
|
|
let flags = getEnv("NIMFLAGS", "") # Extra flags for the compiler
|
|
|
|
let verbose = getEnv("V", "") notin ["", "0"]
|
2024-03-19 16:28:52 +00:00
|
|
|
let platform = getEnv("PLATFORM", "")
|
2023-08-01 09:56:08 +00:00
|
|
|
let testArguments =
|
|
|
|
when defined(windows):
|
|
|
|
[
|
|
|
|
"-d:debug -d:chronosDebug -d:useSysAssert -d:useGcAssert",
|
|
|
|
"-d:release",
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
[
|
|
|
|
"-d:debug -d:chronosDebug -d:useSysAssert -d:useGcAssert",
|
|
|
|
"-d:debug -d:chronosDebug -d:chronosEventEngine=poll -d:useSysAssert -d:useGcAssert",
|
|
|
|
"-d:release",
|
|
|
|
]
|
2021-11-08 17:09:06 +00:00
|
|
|
|
2022-11-23 05:54:10 +00:00
|
|
|
let cfg =
|
2023-11-13 09:54:37 +00:00
|
|
|
" --styleCheck:usages --styleCheck:error" &
|
2022-11-23 05:54:10 +00:00
|
|
|
(if verbose: "" else: " --verbosity:0 --hints:off") &
|
2023-11-13 09:54:37 +00:00
|
|
|
" --skipParentCfg --skipUserCfg --outdir:build " &
|
|
|
|
quoteShell("--nimcache:build/nimcache/$projectName")
|
2021-03-03 18:04:09 +00:00
|
|
|
|
2022-11-23 05:54:10 +00:00
|
|
|
proc build(args, path: string) =
|
|
|
|
exec nimc & " " & lang & " " & cfg & " " & flags & " " & args & " " & path
|
|
|
|
|
|
|
|
proc run(args, path: string) =
|
2023-11-08 15:14:33 +00:00
|
|
|
build args, path
|
|
|
|
exec "build/" & path.splitPath[1]
|
2022-11-23 05:54:10 +00:00
|
|
|
|
2023-11-15 08:06:37 +00:00
|
|
|
task examples, "Build examples":
|
|
|
|
# Build book examples
|
|
|
|
for file in listFiles("docs/examples"):
|
|
|
|
if file.endsWith(".nim"):
|
2024-02-14 07:27:09 +00:00
|
|
|
build "--threads:on", file
|
2023-11-15 08:06:37 +00:00
|
|
|
|
2022-11-23 05:54:10 +00:00
|
|
|
task test, "Run all tests":
|
2023-08-01 09:56:08 +00:00
|
|
|
for args in testArguments:
|
2024-07-03 10:57:58 +00:00
|
|
|
# First run tests with `refc` memory manager.
|
|
|
|
run args & " --mm:refc", "tests/testall"
|
2023-06-04 07:51:02 +00:00
|
|
|
if (NimMajor, NimMinor) > (1, 6):
|
2024-07-03 10:57:58 +00:00
|
|
|
run args & " --mm:orc", "tests/testall"
|
2023-11-15 08:06:37 +00:00
|
|
|
|
2024-06-10 08:18:42 +00:00
|
|
|
task test_v3_compat, "Run all tests in v3 compatibility mode":
|
|
|
|
for args in testArguments:
|
|
|
|
if (NimMajor, NimMinor) > (1, 6):
|
|
|
|
# First run tests with `refc` memory manager.
|
|
|
|
run args & " --mm:refc -d:chronosHandleException", "tests/testall"
|
|
|
|
|
|
|
|
run args & " -d:chronosHandleException", "tests/testall"
|
|
|
|
|
2021-11-08 17:09:06 +00:00
|
|
|
task test_libbacktrace, "test with libbacktrace":
|
2024-03-19 16:28:52 +00:00
|
|
|
if platform != "x86":
|
|
|
|
let allArgs = @[
|
|
|
|
"-d:release --debugger:native -d:chronosStackTrace -d:nimStackTraceOverride --import:libbacktrace",
|
|
|
|
]
|
2021-11-08 17:09:06 +00:00
|
|
|
|
2024-03-19 16:28:52 +00:00
|
|
|
for args in allArgs:
|
2024-07-03 10:57:58 +00:00
|
|
|
# First run tests with `refc` memory manager.
|
|
|
|
run args & " --mm:refc", "tests/testall"
|
2024-03-19 16:28:52 +00:00
|
|
|
if (NimMajor, NimMinor) > (1, 6):
|
2024-07-03 10:57:58 +00:00
|
|
|
run args & " --mm:orc", "tests/testall"
|
2023-11-15 08:06:37 +00:00
|
|
|
|
|
|
|
task docs, "Generate API documentation":
|
|
|
|
exec "mdbook build docs"
|
|
|
|
exec nimc & " doc " & "--git.url:https://github.com/status-im/nim-chronos --git.commit:master --outdir:docs/book/api --project chronos"
|