Commit Graph

70 Commits

Author SHA1 Message Date
Etan Kissling e96f321503
release `v0.2.2` (#42)
- Improve `teardown` flow to avoid generating a SIGSEGV on exceptions
2024-03-11 13:52:17 +00:00
tersec b5028a4471
use non-EOL macOS version for GitHub Actions CI (#40) 2024-02-16 17:06:04 +00:00
jangko bfe65b9fcb
Upgrade github actions to v4 2024-01-27 17:02:20 +07:00
andri lim e98a1ed79f
Fix allow break in test body regression (#38)
* Fix allow break in test body regression

* Silence UnnamedBreak warning

* Use push/pop pragma to silence UnnamedBreak warning
2024-01-22 18:59:23 +07:00
Etan Kissling 0fe665e509
only run `teardown` if `setup` completed (#36)
* only run `teardown` if `setup` completed

With #35, it is no longer possible in `teardown` to refer to variables
introduced in `setup`. To avoid having to rewrite tests, address the
issue in #35 by wrapping `body` with an additional exception catching
layer. This then allows to re-use the previous `teardown` semantics
where `teardown` only ran if `setup` fully completed and also has access
to the variables introduced in `setup`.

* workaround shadowing bug

* Add test

---------

Co-authored-by: jangko <jangko128@gmail.com>
2024-01-22 13:27:34 +07:00
andri lim 13bf4d444d
Add test for PR #35 (#37)
* Add test for PR #35
2024-01-22 10:45:02 +07:00
Ivan FB db67e2ad76
unittest2.nim: ensure the testTeardownIMPL is performed at the end (#35)
* unittest2.nim: ensure the testTeardownIMPL is performed at the end

This is important to prevent failing tests
to fail in an uncontrolled way and generating a SIGSEGV
(segmentation fault)

Particularly, when the test body raises an exception,
e.g. "assert false", what happened was that the "testTeardownIMPL"
was invoked before the exception handlging and that caused
errors like:

Traceback (most recent call last, using override)
/home/ivansete/workspace/status/nwaku/vendor/nim-unittest2/unittest2.nim(1154)
unittest2
/home/ivansete/workspace/status/nwaku/vendor/nim-unittest2/unittest2.nim(1086)
runDirect
/home/ivansete/workspace/status/nwaku/vendor/nim-unittest2/unittest2.nim(1111)
runTestX60gensym398
/home/ivansete/workspace/status/nwaku/vendor/nimbus-build-system/vendor/Nim/lib/system/excpt.nim(631)
signalHandler
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault (core dumped)
2024-01-12 17:17:30 +01:00
Jacek Sieka 262b697f38
add `dualTest` which tests both compile-time and runtime 2023-11-13 08:44:01 +01:00
Jacek Sieka 333e74fa2d
compile-time test support (#34)
This change brings 3 new items to `unittest2`:

* `-d:unittest2Static` compile-time flag that enables `test` to run both
at compile time and runtime
* `staticTest` that only run at compilet ime no matter the flag
* `runtimeTest` that only run at run time no matter the flag
2023-11-10 13:49:41 +01:00
Tanguy 91973dfa38
Add total running time (#33) 2023-09-16 08:51:29 +02:00
Jacek Sieka e1b7a9f418
cleanups (#32)
* emulate no-suite mode in no-collect mode
* add missing flush
* make tests threadvar too
2023-09-02 20:31:35 +02:00
Jacek Sieka 2300fa9924
Revamped output handling, cleanup and removal of thread mode (#31)
This PR introduces a facelift for `unittest2` bringing its UX into the 21st
century!

By default, a compact dot-based format is used to avoid spamming the console
on success - successes are normal and only minimal information is needed in
the vast majority of runs:

```
[  20/25] HTTP client testing suite                               ................s..... (14.2s)
[  21/25] Asynchronous process management test suite              ....................F. (14.5s)
===========================
  /home/arnetheduck/status/nimbus-eth2/vendor/nim-chronos/build/testall 'Asynchronous process management test suite::File descriptors leaks test'
---------------------------
    /home/arnetheduck/status/nimbus-eth2/vendor/nim-chronos/tests/testproc.nim(465, 27): Check failed: getCurrentFD() == markFD
    getCurrentFD() was 3
    markFD was 5

  [FAILED ] (  0.00s) File descriptors leaks test
```

For each line, we see a suite followed by single-character status markers -
mostly successes but also a skipped and a failed test.

Failures are printed verbosely after the suite is done so they don't get
lost in the success spam along with a simple copy-pasteable line showing
how to reproduce the failure.

The verbose mode has also received an upgrade:

```
  [  20/22]           terminateAndWaitForExit() timeout test
  [OK     ] (  2.00s) terminateAndWaitForExit() timeout test
  [  21/22]           File descriptors leaks test
===========================
  /home/arnetheduck/status/nimbus-eth2/vendor/nim-chronos/tests/testall 'Asynchronous process management test suite::File descriptors leaks test'
---------------------------
    /home/arnetheduck/status/nimbus-eth2/vendor/nim-chronos/tests/testproc.nim(465, 27): Check failed: getCurrentFD() == markFD
    getCurrentFD() was 3
    markFD was 5

  [FAILED ] (  0.00s) File descriptors leaks test
  [  22/22]           Leaks test
```

Here, we can see a "test started" marker so that it becomes clear which test
is currently running and so that any output the test itself prints has the
proper name attached to it.

At the end, there's a summary as well that reiterates the tests that failed so
they can be found in the success spam that the verbose mode generates:

```
[Summary ] 22 tests run: 21 OK, 1 FAILED, 0 SKIPPED
  [FAILED ] (  0.00s) File descriptors leaks test
```

As seen above, the new mode knows how many tests will run: this is thanks
to a new two-phase mode of test running: "collect" and "run"!

The "collection" phase is responsible for collecting test metadata which is
later used to run tests in smarter ways, for example in isolated processes.

Unfortunately, it is not fully backwards-compatible because the global setup
might expose order-dependency problems in test suites that previously would
not be visible - for this, we have acompile-time setting for a compatibilty
mode that runs things roughly in the same order as before but disables
some of the fancy functionality.

The changes also come with a bag of mixed stuff:

* the parallel mode is removed entirely - it was broken beyond fixing and
  needs to be rewritten from zero - deadlocks, GC violations and everything
  in between rendered it practically unusable and a source of CI failures
  above all
* an experimental process isolation mode where tests are run in a separate
  process - this is allows many features such as timeouts, output
  verification etc but it also breaks for similar reasons as above:
  "global" code gets executed out of order and repeatedly.
* random UX fixes and cleanups of things like env var reading and command
  line options
2023-09-01 12:23:01 +02:00
Jacek Sieka 299bc9a574
more lent iterators (#30)
* more lent iterators

* bump
2023-08-22 17:26:10 +02:00
Jacek Sieka 0b44f30d9b
avoid potential capture of lent iterator var (#29)
also avoid `quote do` for better line numbers in error messages
2023-08-22 06:50:19 +02:00
jangko 21ed62449d
remove nim 1.2 and 1.4 support 2023-07-28 10:53:13 +07:00
Jacek Sieka b178f47527
v0.0.7 2023-06-06 10:36:56 +02:00
Jacek Sieka 4d5dbb569a
fix stackTrace symbol usage 2023-06-05 23:34:42 +02:00
tersec 5ed05c90fb
use Nim 2.0 in CI (#26) 2023-05-10 10:16:24 +00:00
Tanguy 883c7a50ad
Fix `expect` & nim 1.6 regressions (#24) 2023-02-17 15:23:16 +01:00
jangko 0e18d15d3e
reduce compiler warnings about cannot raise defect 2023-02-14 13:13:26 +07:00
jangko 3f5065b6fd
bump github actions to v3 2023-02-14 12:23:48 +07:00
narimiran 2e7f2040fe switch CI to the supported version of macos
See https://github.com/actions/runner-images/issues/5583
2023-02-14 12:20:56 +07:00
jangko 828310e512
workaround for nim 1.2 backward compatibility: exception in terminal.nim 2023-02-14 11:13:53 +07:00
jangko bed1d50a45
workaround for nim devel in ci 2023-02-14 10:32:06 +07:00
Tanguy fe3650ceea
fix for 1.6 2023-02-10 11:13:45 +01:00
Tanguy 39ed5a784e
Bump version 2023-01-04 15:52:46 +01:00
Tanguy c445f0e489
cleaner 2023-01-04 15:49:22 +01:00
Tanguy fa59d48f2c
Fix warnings 2023-01-04 15:48:30 +01:00
diegomrsantos da8398c45c
Bump the version (#20) 2022-11-07 18:05:13 +01:00
diegomrsantos 297711ddaa
Fix compilation on devel (#19) 2022-11-07 14:27:25 +01:00
Miran bdb5eca353
move -d:nimRawSetjmp to nim.cfg (#14)
Refs https://github.com/status-im/nimbus-build-system/issues/44
2022-07-25 22:06:27 +03:00
Ivan Yonchovski a78e6eb8bc
Update gitignore (#15) 2022-07-12 23:31:12 +03:00
Tanguy f180f596c8
Fix for strict exceptions 2022-06-16 13:28:28 +02:00
Tanguy 26f31488a8
Add -d:unittestPrintTime to show test duration in console (#12)
* Add -d:unittestPrintTime to show test duration in console
* Add environment variable option NIMTEST_TIMING
* Bump version to 0.0.4
2022-05-31 17:12:44 +02:00
Tanguy 9d23c0bebe
Generate documentation in CI (#13)
* Also removes docs from master
2022-05-12 18:23:28 +03:00
Ștefan Talpalaru 24eb5e829e
CI: test with Nim-1.6 and C++ (#11) 2022-01-14 04:15:45 +01:00
Tanguy 4e2893eacb
bump nimble version 2021-12-17 09:09:12 +01:00
Ștefan Talpalaru 02c49b8a99
fix URL 2021-11-22 01:20:30 +01:00
Ștefan Talpalaru 7a32cb7717
try to trigger GitHub Pages 2021-11-22 01:18:09 +01:00
Ștefan Talpalaru 66420a7d93
regenerate HTML docs 2021-11-22 01:08:32 +01:00
Jacek Sieka f1d70dbb8c
better error message on unexpected exception (#10) 2021-08-17 15:45:12 +02:00
Jacek Sieka 4c2ce01e34
reorder code (#9)
declare checkpoint/fail before use to avoid random compile errors
2021-08-16 15:10:04 +02:00
Ștefan Talpalaru 91d4eaa4cc
Nim-1.4 fix (#8)
* Nim-1.4 fix

* CI: use MSYS2
2021-05-22 18:00:55 +02:00
Ștefan Talpalaru b9b61cfe4a
change define prefix and update docs (#7) 2021-04-29 14:20:03 +02:00
Jacek Sieka c847fc3ec7
Merge pull request #5 from status-im/xml-report
write junit test reports as a command line option
2021-04-28 13:44:05 +02:00
Jacek Sieka 60855d9432
add option to disable command line parsing 2021-04-28 10:19:23 +02:00
Jacek Sieka 133d86a58e
compat fixes
evaluate name once only
2021-04-27 20:29:59 +02:00
Jacek Sieka 0bff52a779
fix time, run test in block 2021-04-27 17:41:56 +02:00
Jacek Sieka d070a24fd0
write junit test reports as a command line option
* add counters to xml reports
* add command line args to write xml report
* fix initialization being performed once for each test
* use monotonic timer for duration measurements
2021-04-27 16:34:39 +02:00
Jacek Sieka e788deab3d
Merge pull request #4 from status-im/failfix
fix stand-alone "check" for <Nim-1.4.0
2021-03-22 20:44:58 +01:00