diff options
author | ZyX <kp-pav@yandex.ru> | 2017-04-01 20:57:23 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-04-01 20:57:23 +0300 |
commit | ac22238b6af1d37fab09fc2173d5ed2019652c41 (patch) | |
tree | 0d4001334de81c2a72a99a39b6417999a9e61f76 | |
parent | 2d158dde025fc7752c9f52def8384a2fbb698652 (diff) | |
download | rneovim-ac22238b6af1d37fab09fc2173d5ed2019652c41.tar.gz rneovim-ac22238b6af1d37fab09fc2173d5ed2019652c41.tar.bz2 rneovim-ac22238b6af1d37fab09fc2173d5ed2019652c41.zip |
unittests: Replace two environment variables with one TRACE_LEVEL
-rw-r--r-- | test/README.md | 17 | ||||
-rw-r--r-- | test/unit/helpers.lua | 21 |
2 files changed, 23 insertions, 15 deletions
diff --git a/test/README.md b/test/README.md index d0871711a8..2857cc0ecf 100644 --- a/test/README.md +++ b/test/README.md @@ -27,8 +27,8 @@ groups by the semantic component they are testing. Test behaviour is affected by environment variables. Currently supported (Functional, Unit, Benchmarks) (when Defined; when set to _1_; when defined, -treated as Integer; when defined, treated as String; !must be defined to -function properly): +treated as Integer; when defined, treated as String; when defined, treated as +Number; !must be defined to function properly): `GDB` (F) (D): makes nvim instances to be run under `gdbserver`. It will be accessible on `localhost:7777`: use `gdb build/bin/nvim`, type `target remote @@ -103,11 +103,8 @@ defined and this variable is not) cores are checked for after each test. `NVIM_TEST_RUN_TESTTEST` (U) (1): allows running `test/unit/testtest_spec.lua` used to check how testing infrastructure works. -`NVIM_TEST_NO_TRACE` (U) (1): omits getting traces from tests. This means that -if tests crashed without core dump you will have no clues regarding where, but -this makes tests run a lot faster. Combine with `NVIM_TEST_MAIN_CDEFS` for -maximal speed. - -`NVIM_TEST_TRACE_EVERYTHING` (U) (1): by default unit test only record C calls -which is faster then recording everything. Set this variable to 1 if you want to -see all traces. +`NVIM_TEST_TRACE_LEVEL` (U) (N): specifies unit tests tracing level: `0` +disables tracing (the fastest, but you get no data if tests crash and there was +no core dump generated), `1` or empty/undefined leaves only C function cals and +returns in the trace (faster then recording everything), `2` records all +function calls, returns and lua source lines exuecuted. diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index 2cea88c8c0..93e1e91173 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -539,10 +539,16 @@ local tracehelp = dedent([[ ]]) local function child_sethook(wr) - if os.getenv('NVIM_TEST_NO_TRACE') == '1' then + local trace_level = os.getenv('NVIM_TEST_TRACE_LEVEL') + if not trace_level or trace_level == '' then + trace_level = 1 + else + trace_level = tonumber(trace_level) + end + if trace_level <= 0 then return end - local trace_only_c = (os.getenv('NVIM_TEST_TRACE_EVERYTHING') ~= '1') + local trace_only_c = trace_level <= 1 local function hook(reason, lnum) local info = nil if reason ~= 'tail return' then -- tail return @@ -651,9 +657,14 @@ local function check_child_err(rd) end local res = sc.read(rd, 2) if #res ~= 2 then - local error = '\nTest crashed, trace:\n' .. tracehelp - for i = 1, #trace do - error = error .. trace[i] + local error + if #trace == 0 then + error = '\nTest crashed, no trace available\n' + else + error = '\nTest crashed, trace:\n' .. tracehelp + for i = 1, #trace do + error = error .. trace[i] + end end assert.just_fail(error) end |