summary refs log tree commit diff stats
path: root/tests/stdlib
Commit message (Collapse)AuthorAgeFilesLines
* asyncdispatch, asyncnet: add inheritance control (#14362)alaviss2020-05-201-5/+31
| | | | | * asyncdispatch, asyncnet: add inheritance control * asyncnet, asyncdispatch: cleanup
* trunner was not actually being tested in non-CTFFI mode; minor testament ↵Timothee Cour2020-05-192-3/+2
| | | | | | | | | | cleanups (#14377) * use check * trunner now works with cpp * cleanup: move compiler/unittest_light => stdtest/unittest_light * fix tests/readme.md * remove deadcode references to rodfiles * fix for windows
* `osproc.execCmdEx` now takes an optional `input` for stdin, `env`, ↵Timothee Cour2020-05-131-1/+14
| | | | | | | workingDir (#14211) * `osproc.execCmdEx` now takes an optional `input` for stdin * execCmdEx now also takes an optional ``workingDir` and `env`
* fix a critical bug in windows.osproc leading to resource leaks and blocking ↵Timothee Cour2020-05-111-0/+26
| | | | IO [backport] (#14296)
* Added bitslice operations for bitops (#14016)awr12020-05-061-1/+70
| | | | | | | | | | | | | | | | | | | | * added bit operations based on bit slices, clarified documentation, made non-mutating versions of mask ops * Added since annotations, some runnable examples * Added mask()/masked() functions, changed internal workings of mask ops to use new bit* funcs * Changelog updated for new bitops improvements * Reorganization, added runnable examples * Documentation adjustments * Add incltrl for since annotation * Fix masked() impl * Fix mask() return type * Don't call toUnsigned on already unsigned types * Remove improper `var T` for flipMasked() * Fix return types for flipMasked() * Slight syntactic cleanup for *masked ops * Added tests for bitslice operations, new mask() operation, non-mutating mask ops * Fix setmasked() var T issue * More comprehensive tests * Fix runnable example for bitsliced() * Fix runnable example for mask()
* Make the fields of `times.DateTime` private (#14197)Oscar Nihlgård2020-05-061-9/+20
| | | | | * Make the fields of `times.DateTime` private * PR fixes
* move since from inclrtl to std/private/since (#14188)hlaaftana2020-05-021-6/+6
| | | | * move since from inclrtl to std/private/since * move since import in system below for HCR
* fixes #14054 [backport:1.2] (#14061)Andreas Rumpf2020-04-301-0/+31
| | | | | | | | | * fixes #14054 * make tests green again * more tests are green * maybe now
* parseEnum_regression (#14150)cooldome2020-04-281-2/+2
| | | Co-authored-by: cooldome <ariabushenko@bk.ru>
* Error -> Defect for defects (#13908)Jacek Sieka2020-04-289-13/+13
| | | | | | | | | | | | | | * Error -> Defect for defects The distinction between Error and Defect is subjective, context-dependent and somewhat arbitrary, so when looking at an exception, it's hard to guess what it is - this happens often when looking at a `raises` list _without_ opening the corresponding definition and digging through layers of inheritance. With the help of a little consistency in naming, it's at least possible to start disentangling the two error types and the standard lib can set a good example here.
* StringStream & more stdlib modules support for JS/NimScript (#14095)hlaaftana2020-04-285-41/+53
| | | | | * StringStream & more stdlib modules support for JS/NimScript * change back pegs test in line with #14134
* since now takes an optional patch, eg: `since: (1, 3, 1)` (#14124)Timothee Cour2020-04-261-0/+32
| | | add tests for tinclrtl
* fixes #14112, tests for #12892, #12671, #11697 (#14125)hlaaftana2020-04-261-0/+2
|
* fix nim CI; fix local testament (#14102)Timothee Cour2020-04-241-1/+4
|
* Fix #14091 and #14093 - test failures on NetBSD (#14096)Euan2020-04-241-1/+1
|
* base `parseEnum` on a case statement, fixes #14030 (#14046)Vindaar2020-04-221-0/+87
| | | | | | | | | | | | | | | | | | | | * base `parseEnum` on a case statement, fixes #14030 * apply simplifactions / clean up, remove `norm` node, use strVal * export `normalize` in json.nim * cmp using nimIdentNormalize, error at CT if ambiguous enum found `nimIdentNormalize` provided by @cooldome. We track all names of the branches we have created so far and error if a duplicate is found. Dummy change to make github react... * fix docstring of `nimIdentNormalize` * make `typ` arg `typedesc`, add lineinfo, call norm. only once
* fix #13222: make relativePath more robust and flexible (#13451)Timothee Cour2020-04-211-0/+3
| | | | | | | | | * * relativePath(foo) now works * relativePath(rel, abs) and relativePath(abs, rel) now work (fixes #13222) * relativePath, absolutePath, getCurrentDir now available in more targets (eg: vm, nodejs etc) * fix bug: isAbsolutePath now works with -d:js; add tests * workaround https://github.com/nim-lang/Nim/issues/13469 * remove `relativePath(path)` overload for now * add back changelog after rebase
* #12103 - CI for OpenBSD (#12105)Euan2020-04-213-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Working on OpenBSD CI * Condense steps into 2 steps to make output easier to follow. * Move up one directory after csources build. * Remove FreeBSD build manifest and add OpenBSD test ignores for coroutines and hot code reloading. * If runCI fails, run the test results script. * Add email trigger for build failure * Remove .git from repository URL * Disable SFML test on OpenBSD * Disable tgetaddrinfo on OpenBSD as only UDP and TCP protocols are supported. * Remove getFilePermissions as it causes CI test failures with NimScript. * Set clang as cc in nim.cfg and use gmake to build csources. * Add getCurrentDir to nimscript. * Remove duplicate getCurrentDir and check for not weirdTarget. * Add CI badge for OpenBSD. * Disable tests which allocate lots of memory for OpenBSD. * Use `CORO_BACKEND_SETJMP` on OpenBSD rather than ucontext. * Simplify building of koch * Disable t8657 on OpenBSD. See issue #13760. * Fix #12142 - tarray_of_channels fails on OpenBSD * Disable thhtpclient_ssl and tosprocterminate on OpenBSD. These tests can be enabled at a later date after fixing them. * Install libffi. * Set path to libc for openbsd. * Disable tevalffi for now. * Remove tevalffi.nim. * Use ncpuonline sysctl rather than ncpu. * Disable tacceptcloserace and tasynchttpserver on OpenBSD. * Enable tacceptcloserace and tasynchttpserver. * Fix #13775 as suggested by @alaviss - use /bin/cat on OpenBSD rather than /bin/sh. * Enable test on OpenBSD. * Disable tflowvar on OpenBSD.
* Make file descriptors from stdlib non-inheritable by default (#13201)alaviss2020-04-201-0/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * io: make file descriptors non-inheritable by default This prevents file descriptors/handles leakage to child processes that might cause issues like running out of file descriptors, or potential security issues like leaking a file descriptor to a restricted file. While this breaks backward compatibility, I'm rather certain that not many programs (if any) actually make use of this implementation detail. A new API `setInheritable` is provided for the few that actually want to use this functionality. * io: disable inheritance at file creation time for supported platforms Some platforms provide extension to fopen-family of functions to allow for disabling descriptor inheritance atomically during File creation. This guards against possible leaks when a child process is spawned before we managed to disable the file descriptor inheritance (ie. in a multi-threaded program). * net, nativesockets: make sockets non inheritable by default With this commit, sockets will no longer leak to child processes when you don't want it to. Should solves a lot of "address in use" that might occur when your server has just restarted. All APIs that create sockets in these modules now expose a `inheritable` flag that allow users to toggle inheritance for the resulting sockets. An implementation of `setInheritance()` is also provided for SocketHandle. While atomically disabling inheritance at creation time is supported on Windows, it's only implemented by native winsock2, which is too much for now. This support can be implemented in a future patch. * posix: add F_DUPFD_CLOEXEC This command duplicates file descriptor with close-on-exec flag set. Defined in POSIX.1-2008. * ioselectors_kqueue: don't leak file descriptors File descriptors internally used by ioselectors on BSD/OSX are now shielded from leakage. * posix: add O_CLOEXEC This flag allows file descriptors to be open() with close-on-exec flag set atomically. This flag is specified in POSIX.1-2008 * tfdleak: test for selectors leakage Also simplified the test by using handle-type agnostic APIs to test for validity. * ioselectors_epoll: mark all fd created close-on-exec File descriptors from ioselectors should no longer leaks on Linux. * tfdleak: don't check for selector leakage on Windows The getFd proc for ioselectors_select returns a hardcoded -1 * io: add NoInheritFlag at compile time * io: add support for ioctl-based close-on-exec This allows for the flag to be set/unset in one syscall. While the performance gains might be negliable, we have one less failure point to deal with. * tfdleak: add a test for setInheritable * stdlib: add nimInheritHandles to restore old behaviors * memfiles: make file handle not inheritable by default for posix * io: setInheritable now operates on OS file handle On Windows, the native handle is the only thing that's inheritable, thus we can assume that users of this function will already have the handle available to them. This also allows users to pass down file descriptors from memfiles on Windows with ease, should that be desired. With this, nativesockets.setInheritable can be made much simpler. * changelog: clarify * nativesockets: document setInheritable return value * posix_utils: atomically disable fd inheritance for mkstemp
* Make bitand, bitor, bitxor varargs-friendly (#13985)awr12020-04-201-0/+8
| | | | | | | | * made bitand, bitor, bitxor varargs friendly * changed new bitops to macros * changed macro signature for consistency (this technically doesn't matter) * added tests * removed redundant assert * fix literal
* fix https://github.com/nim-lang/RFCs/issues/211: `var a: DateTime` compiles ↵Timothee Cour2020-04-181-0/+15
| | | | | | | and is usable (#14002) [backport:1.2] * fix https://github.com/nim-lang/RFCs/issues/211: `var a: DateTime` works * assertValidDate checks for sentinel month
* Add `hashWangYi1` (#13823)c-blake2020-04-151-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Unwind just the "pseudorandom probing" (whole hash-code-keyed variable stride double hashing) part of recent sets & tables changes (which has still been causing bugs over a month later (e.g., two days ago https://github.com/nim-lang/Nim/issues/13794) as well as still having several "figure this out" implementation question comments in them (see just diffs of this PR). This topic has been discussed in many places: https://github.com/nim-lang/Nim/issues/13393 https://github.com/nim-lang/Nim/pull/13418 https://github.com/nim-lang/Nim/pull/13440 https://github.com/nim-lang/Nim/issues/13794 Alternative/non-mandatory stronger integer hashes (or vice-versa opt-in identity hashes) are a better solution that is more general (no illusion of one hard-coded sequence solving all problems) while retaining the virtues of linear probing such as cache obliviousness and age-less tables under delete-heavy workloads (still untested after a month of this change). The only real solution for truly adversarial keys is a hash keyed off of data unobservable to attackers. That all fits better with a few families of user-pluggable/define-switchable hashes which can be provided in a separate PR more about `hashes.nim`. This PR carefully preserves the better (but still hard coded!) probing of the `intsets` and other recent fixes like `move` annotations, hash order invariant tests, `intsets.missingOrExcl` fixing, and the move of `rightSize` into `hashcommon.nim`. * Fix `data.len` -> `dataLen` problem. * This is an alternate resolution to https://github.com/nim-lang/Nim/issues/13393 (which arguably could be resolved outside the stdlib). Add version1 of Wang Yi's hash specialized to 8 byte integers. This gives simple help to users having trouble with overly colliding hash(key)s. I.e., A) `import hashes; proc hash(x: myInt): Hash = hashWangYi1(int(x))` in the instantiation context of a `HashSet` or `Table` or B) more globally, compile with `nim c -d:hashWangYi1`. No hash can be all things to all use cases, but this one is A) vetted to scramble well by the SMHasher test suite (a necessarily limited but far more thorough test than prior proposals here), B) only a few ALU ops on many common CPUs, and C) possesses an easy via "grade school multi-digit multiplication" fall back for weaker deployment contexts. Some people might want to stampede ahead unbridled, but my view is that a good plan is to A) include this in the stdlib for a release or three to let people try it on various key sets nim-core could realistically never access/test (maybe mentioning it in the changelog so people actually try it out), B) have them report problems (if any), C) if all seems good, make the stdlib more novice friendly by adding `hashIdentity(x)=x` and changing the default `hash() = hashWangYi1` with some `when defined` rearranging so users can `-d:hashIdentity` if they want the old behavior back. This plan is compatible with any number of competing integer hashes if people want to add them. I would strongly recommend they all *at least* pass the SMHasher suite since the idea here is to become more friendly to novices who do not generally understand hashing failure modes. * Re-organize to work around `when nimvm` limitations; Add some tests; Add a changelog.md entry. * Add less than 64-bit CPU when fork. * Fix decl instead of call typo. * First attempt at fixing range error on 32-bit platforms; Still do the arithmetic in doubled up 64-bit, but truncate the hash to the lower 32-bits, but then still return `uint64` to be the same. So, type correct but truncated hash value. Update `thashes.nim` as well. * A second try at making 32-bit mode CI work. * Use a more systematic identifier convention than Wang Yi's code. * Fix test that was wrong for as long as `toHashSet` used `rightSize` (a very long time, I think). `$a`/`$b` depend on iteration order which varies with table range reduced hash order which varies with range for some `hash()`. With 3 elements, 3!=6 is small and we've just gotten lucky with past experimental `hash()` changes. An alternate fix here would be to not stringify but use the HashSet operators, but it is not clear that doesn't alter the "spirit" of the test. * Fix another stringified test depending upon hash order. * Oops - revert the string-keyed test. * Fix another stringify test depending on hash order. * Add a better than always zero `defined(js)` branch. * It turns out to be easy to just work all in `BigInt` inside JS and thus guarantee the same low order bits of output hashes (for `isSafeInteger` input numbers). Since `hashWangYi1` output bits are equally random in all their bits, this means that tables will be safely scrambled for table sizes up to 2**32 or 4 gigaentries which is probably fine, as long as the integer keys are all < 2**53 (also likely fine). (I'm unsure why the infidelity with C/C++ back ends cut off is 32, not 53 bits.) Since HashSet & Table only use the low order bits, a quick corollary of this is that `$` on most int-keyed sets/tables will be the same in all the various back ends which seems a nice-to-have trait. * These string hash tests fail for me locally. Maybe this is what causes the CI hang for testament pcat collections? * Oops. That failure was from me manually patching string hash in hashes. Revert. * Import more test improvements from https://github.com/nim-lang/Nim/pull/13410 * Fix bug where I swapped order when reverting the test. Ack. * Oh, just accept either order like more and more hash tests. * Iterate in the same order. * `return` inside `emit` made us skip `popFrame` causing weird troubles. * Oops - do Windows branch also. * `nimV1hash` -> multiply-mnemonic, type-scoped `nimIntHash1` (mnemonic resolutions are "1 == identity", 1 for Nim Version 1, 1 for first/simplest/fastest in a series of possibilities. Should be very easy to remember.) * Re-organize `when nimvm` logic to be a strict `when`-`else`. * Merge other changes. * Lift constants to a common area. * Fall back to identity hash when `BigInt` is unavailable. * Increase timeout slightly (probably just real-time perturbation of CI system performance).
* Make unused code into actual test, replace echo with doassert (#13952)Juan Carlos2020-04-111-0/+84
|
* osproc: added a better version of waitForExit for Haiku (#13938)alaviss2020-04-101-6/+22
| | | Also modified tosprocterminate to verify waitForExit implementations.
* Add barebones asynchttpserver tests (#13883)supakeen2020-04-051-0/+119
| | | | | | | * Add isNil check to custom Content-Length. Related to #13866. * Setup barebones asynchttpserver tests.
* std/byaddr => std/decls (#13847)Timothee Cour2020-04-031-1/+1
|
* renamed new std/pragmas.nim to std/byaddr.nim (#13844)Andreas Rumpf2020-04-021-1/+1
| | | | | * renamed new std/pragmas.nim to std/byaddr.nim * minor code cleanup
* stacktraces can now show custom runtime msgs per frame (#13351)Timothee Cour2020-03-302-0/+72
| | | | | | | | * stacktraces can now show custom runtime msgs * improve tests/stdlib/tstackframes.nim * fix test for --gc:arc * test --stacktraceMsgs:on and --stacktraceMsgs:off * --stacktracemsgs:off by default
* faster CIs (#13803)Miran2020-03-309-252/+187
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ttables: smaller table, 5x speedup * thavlak: less iterations, less loops; 30% speedup * tasyncclosestall: shorter timeout; 35% speedup * gcleak4: less iterations, 2x speedup * ttimes: remove deprecated stuff * tdangerisrelease: remove cpp backend, 3x speedup * tfrexp1: smaller range, 2x speedup * trtree: fix warnings, less iterations, 6x speedup * tasyncawait_cyclebreaker: smaller swarm size; 2x speedup * trealloc: smaller number of iterations; 10x speedup * towned_binary_tree: less iterations, 4x speedup * tclosure: remove unused code, less iterations; 2x speedup * twaitany: less durations; 1.4x speedup * tasync_misc: less iterations, 2x speedup * t8535: smaller sleep, 1.5x speedup * tmanyjoin: smaller sleep, 2x speedup * t12221: shorter sleeps, removed two slower tests; 1.6x speedup * tfuturestream: smaller sleep; 1.5x speedup * growobjcrash: less iterations; 2x speedup * ttryrecv: smaller sleep; 1.5x speedup * treusetvar: less threads; 2x speedup * delete tthreadanalysis2, basically a duplicate of tthreadanalysis * t7758: less iterations, 1.5x speedup * tasyncawait: smaller swarm, less messages; 1.5x speedup * tjsandnativeasync: smaller sleep, 1.5x speedup * tpendingcheck: smaller sleep, 1.5x speedup * remove rodfiles test category * move tseq from its own category to 'collections' category * remove unneeded tests and helpers from 'assert' category * stdlib: merge tbitops2 into tbitops * remove 'trepr2' from 'stdlib' cat * merge 'tstreams' into one file * remove 'tinefficient_const_table' from 'ccbugs' cat * merge 'tcollections_to_string' into 'tcollections' * tblocking_channel: smaller sleep, small speedup * tconvexhull: less iterartions; 1.2x speedup * merge 'tdeepcopy2' into 'tdeepcopy' * merge 'tdisjoint_slice2' into 'tdisjoint_slice1' * tmissing_deepcopy: smaller sequence * tsendtwice: smaller arrays; 5x speedup * remove 'tindexerrorformatbounds' * disable multimethod tests * remove 'gc:none' and 'refc' without 'd:useRealtimeGC' from gc tests * koch.nim: bootstrap just with '-d:release', no need for 'csource' * add github workflow for documentation * testament: no need for 8 sub-second decimals
* fix deprecations and other warnings (#13748)Miran2020-03-255-17/+17
|
* fixes #13722 (#13729)Andreas Rumpf2020-03-231-3/+6
| | | | | * fixes #13722 * better fix
* new syntax for lvalue references: `var b {.byaddr.} = expr` (#13508)Timothee Cour2020-03-231-0/+70
| | | | | | | | * new syntax for lvalue references: `var b {.byaddr.} = expr` * on type mismatch, `???(0, 0)` not shown anymore * * compiler now lowers `var a: {.foo.}: MyType = expr` to foo(a, MyType, expr) * new pragmas.byaddr defined in pure library code exploiting this lowering * skip `template foo() {.pragma.}`
* SSL certificate verify GitHub action (#13697)Federico Ceratto2020-03-203-0/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement SSL/TLS certificate checking #782 * SSL: Add nimDisableCertificateValidation Remove NIM_SSL_CERT_VALIDATION env var tests/untestable/thttpclient_ssl.nim ran successfully on Linux with libssl 1.1.1d * SSL: update integ test to skip flapping tests * Revert .travis.yml change * nimDisableCertificateValidation disable imports Prevent loading symbols that are not defined on older SSL libs * SSL: disable verification in net.nim ..when nimDisableCertificateValidation is set * Update changelog * Fix peername type * Add define check for windows * Disable test on windows * Add exprimental GitHub action CI for SSL * Test nimDisableCertificateValidation
* [RFC] 'walkDir' now has a new 'checkDir' flag, to mimic behaviour of other ↵Timothee Cour2020-03-201-7/+13
| | | | | languages (#13642) Co-authored-by: narimiran
* Add Base64 safe (#13672)Juan Carlos2020-03-201-0/+15
| | | | * Implement RFC-4648 Section-7 * https://github.com/nim-lang/Nim/pull/13672#issuecomment-600993466
* Fix #13573 and #13574 (#13575)Andrea Ferretti2020-03-061-1/+6
| | | | | * Fix https://github.com/nim-lang/Nim/issues/13573 and https://github.com/nim-lang/Nim/issues/13574 * Restored asynchttpserver
* fix #13579 joinPath("/foo/", "../a") is now /a (#13586)Andreas Rumpf2020-03-051-0/+13
|
* fix #13531 by adding a test (#13581)Miran2020-03-041-0/+31
|
* fixes #13543 and added times.isLeapDay (#13547)Timothee Cour2020-03-011-3/+7
|
* tables/sharedtables/intsets/etc: fix #13496, #13504, #13505; add lots of ↵Timothee Cour2020-02-262-6/+145
| | | | | | | | | | | tests (#13498) [backport] * fix #13496 handle tombstones * add test * more tests * fix #13504; add SharedTable tests * fix #https://github.com/nim-lang/Nim/issues/13505 intsets.missingOrExcl silently gave wrong results sometimes * add test for tintsets
* fix #13455 ; joinPath(a,b) now honors trailing slashes in b (or a if b = "") ↵Timothee Cour2020-02-261-3/+26
| | | | | | | (#13467) * fix #13455 ; joinPath(a,b) now honors trailing slashes in b (or a if b = "") * fix test windows
* make devel green again: tnetdial still doesn't work on Travisnarimiran2020-02-251-0/+1
|
* fix 3 minor bugs in joinPath (see #13455) (#13462) [backport]Andrey Makarov2020-02-231-0/+4
|
* relativePath("foo", "foo") is now ".", not "" (#13452)Timothee Cour2020-02-221-4/+8
|
* fix several bugs with `repr` (#13386)Timothee Cour2020-02-111-2/+2
|
* fix #6736: templates in unittest now show actual value (#13354)Miran2020-02-071-0/+25
|
* fix #13132 tnetdial (#13318)Timothee Cour2020-02-041-2/+2
|
* fix lots of bugs with parentDir, refs #8734 (#13236)Timothee Cour2020-01-231-5/+5
|
* new os.isRelativeTo (#13212)Timothee Cour2020-01-231-0/+12
|
* fix #13211 relativePath("foo", ".") (#13213)Timothee Cour2020-01-211-0/+4
|