mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	unittests: Replace two environment variables with one TRACE_LEVEL
This commit is contained in:
		| @@ -27,8 +27,8 @@ groups by the semantic component they are testing. | |||||||
|  |  | ||||||
| Test behaviour is affected by environment variables. Currently supported  | Test behaviour is affected by environment variables. Currently supported  | ||||||
| (Functional, Unit, Benchmarks) (when Defined; when set to _1_; when defined,  | (Functional, Unit, Benchmarks) (when Defined; when set to _1_; when defined,  | ||||||
| treated as Integer; when defined, treated as String; !must be defined to  | treated as Integer; when defined, treated as String; when defined, treated as  | ||||||
| function properly): | Number; !must be defined to function properly): | ||||||
|  |  | ||||||
| `GDB` (F) (D): makes nvim instances to be run under `gdbserver`. It will be  | `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  | 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`  | `NVIM_TEST_RUN_TESTTEST` (U) (1): allows running `test/unit/testtest_spec.lua`  | ||||||
| used to check how testing infrastructure works. | used to check how testing infrastructure works. | ||||||
|  |  | ||||||
| `NVIM_TEST_NO_TRACE` (U) (1): omits getting traces from tests. This means that  | `NVIM_TEST_TRACE_LEVEL` (U) (N): specifies unit tests tracing level: `0`  | ||||||
| if tests crashed without core dump you will have no clues regarding where, but  | disables tracing (the fastest, but you get no data if tests crash and there was  | ||||||
| this makes tests run a lot faster. Combine with `NVIM_TEST_MAIN_CDEFS` for  | no core dump generated), `1` or empty/undefined leaves only C function cals and  | ||||||
| maximal speed. | returns in the trace (faster then recording everything), `2` records all  | ||||||
|  | function calls, returns and lua source lines exuecuted. | ||||||
| `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. |  | ||||||
|   | |||||||
| @@ -539,10 +539,16 @@ local tracehelp = dedent([[ | |||||||
| ]]) | ]]) | ||||||
|  |  | ||||||
| local function child_sethook(wr) | 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 |     return | ||||||
|   end |   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 function hook(reason, lnum) | ||||||
|     local info = nil |     local info = nil | ||||||
|     if reason ~= 'tail return' then  -- tail return |     if reason ~= 'tail return' then  -- tail return | ||||||
| @@ -651,9 +657,14 @@ local function check_child_err(rd) | |||||||
|   end |   end | ||||||
|   local res = sc.read(rd, 2) |   local res = sc.read(rd, 2) | ||||||
|   if #res ~= 2 then |   if #res ~= 2 then | ||||||
|     local error = '\nTest crashed, trace:\n' .. tracehelp |     local error | ||||||
|     for i = 1, #trace do |     if #trace == 0 then | ||||||
|       error = error .. trace[i] |       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 |     end | ||||||
|     assert.just_fail(error) |     assert.just_fail(error) | ||||||
|   end |   end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ZyX
					ZyX