gendeclarations: Extract get_declarations function
gendeclarations: Extract write_file function
build/test: Enable definition of test-only files

Modify the declaration header generator to include files guarded by an #ifdef
guard which is only defined in the nvim-test target.

Here's how it works:

- for each ${module}.c file under src/nvim, if a
  test/c-helpers/${module}.c file exists, it is merged with ${module}.c
- each *.mocks.h file under test/c-helpers is also included in every ${module}.c
  file, with the exception of ${module}.c.mocks.h

This opens the possibility for some useful test workflows:

- Wrap functions with "complex" prototypes for simplified testing through the
  ffi
- Test static functions through wrappers defined in
  test/c-helpers/${module}.c(since it's merged with the original
  module, it has full visibility of static functions)
- Mock functions(even system functions) using macros defined in header files
  under test/c-helpers and lua functions
os/shell: enable mocking `os_system`
ex_cmds2: Replace get_cmd_output by os_system in find_locales
ex_cmds2: Add a spec file and a find_locales test
message: enable mocking `emsg`
buffer_spec: Modify to collect messages during tests