Repository: neovim
Issue: test/helpers.c: module.check_cores() destroys test env on segfault
Labels: bug,test

### Neovim version (nvim -v)

v0.7.0-dev+1047-g800c7f017

### Vim (not Nvim) behaves the same?

no

### Operating system/version

openSUSE

### Terminal name/version

konsole

### $TERM environment variable

screen-256color

### Installation

Built from source

### How to reproduce the issue

```
pushd third_party
mkdir build
pushd build
cmake -DUSE_BUNDLED_GPERF=OFF -DUSE_BUNDLED_LUA=ON ..
make
popd
popd

mkdir build
cmake -DCMAKE_BUILD_TYPE=Debug -DBUSTED_OUTPUT_TYPE=nvim -DDEPS_PREFIX=$(pwd)/../third-party/build/usr -DMIN_LOG_LEVEL=3 -DPREFER_LUA=ON -DCI_BUILD=ON ..

TEST_FILE=test/functional/terminal/buffer_spec.lua make functionaltest
```


### Expected behavior

Do not delete files with core in name if it isn't a coredump! Use https://github.com/mah0x211/lua-libmagic to check if it is a core?

### Actual behavior

If a test fails, then module.check_cores() kicks in and starts to search for `/core*` ([line 379](https://github.com/neovim/neovim/blob/master/test/helpers.lua#L379)).

```
==== Core file ./third-party/obj/usr/share/lua/5.1/luacheck/core_utils.lua ====                                                                                             
"/home/asn/workspace/projects/neovim/./third-party/obj/usr/share/lua/5.1/luacheck/core_utils.lua" is not a core dump: file format not recognized                            
                                                                                                                                                                            
                                                                                                                                                                            
======== Core file ./third-party/obj/usr/share/lua/5.1/busted/core.lua ========                                                                                             
"/home/asn/workspace/projects/neovim/./third-party/obj/usr/share/lua/5.1/busted/core.lua" is not a core dump: file format not recognized                                    
                                                                                                                                                                            
                                                                                                                                                                            
=== Core file ./third-party/obj/usr/share/lua/5.1/luassert/matchers/core.lua ===                                                                                            
"/home/asn/workspace/projects/neovim/./third-party/obj/usr/share/lua/5.1/luassert/matchers/core.lua" is not a core dump: file format not recognized                         
                                                                                                                                                                            
                                                                                                                                                                            
======== Core file ./third-party/obj/usr/share/lua/5.1/cliargs/core.lua ========                                                                                            
"/home/asn/workspace/projects/neovim/./third-party/obj/usr/share/lua/5.1/cliargs/core.lua" is not a core dump: file format not recognized                                   
                                                                                                                                                                            
                                                                                                                                                                            
=========== Core file ./third-party/obj/usr/lib/lua/5.1/term/core.so ===========                                                                                            
"/home/asn/workspace/projects/neovim/./third-party/obj/usr/lib/lua/5.1/term/core.so" is not a core dump: file format not recognized                                         
                                                                                                                                                                            
                                                                                                                                                                            
========== Core file ./third-party/obj/usr/lib/lua/5.1/system/core.so ==========
"/home/asn/workspace/projects/neovim/./third-party/obj/usr/lib/lua/5.1/system/core.so" is not a core dump: file format not recognized


========== Core file ./third-party/obj/build/src/libuv/src/win/core.c ==========
"/home/asn/workspace/projects/neovim/./third-party/obj/build/src/libuv/src/win/core.c" is not a core dump: file format not recognized


========= Core file ./third-party/obj/build/src/libuv/src/unix/core.c =========
"/home/asn/workspace/projects/neovim/./third-party/obj/build/src/libuv/src/unix/core.c" is not a core dump: file format not recognized
```

All those file are then deleted in line module.check_cores() [line 401](https://github.com/neovim/neovim/blob/master/test/helpers.lua#L401)!