Repository: neovim/neovim
File: test/functional/core/startup_spec.lua (Lua)

Code before:
    }) do
      os.remove(f)
    end
  end)

  after_each(function()
    for _, f in ipairs(files) do
      os.remove(f)
    end
  end)

  it('contains absolute paths for startup files', function()
    local file1, file2 = 'Xargf_file1', 'Xargf_file2'
    write_file(file1, '')
    write_file(file2, '')
    files = { file1, file2 }

    local abs1 = fn.fnamemodify(file1, ':p')
    local abs2 = fn.fnamemodify(file2, ':p')

    local out = fn.system({
      nvim_prog,
      '--headless',
      '-u', 'NONE',
      '-i', 'NONE',
      '--cmd', 'echo v:argf',
      file1,
      file2,
      '-c', 'qall',
    })

    matches(pesc(abs1), out)
    matches(pesc(abs2), out)
  end)

  it('retains absolute paths after :cd', function()
    local file1 = 'Xargf_persist'
    write_file(file1, '')
    files = { file1 }

    local abs = fn.fnamemodify(file1, ':p')

    local out = fn.system({
      nvim_prog,
      '--headless',
      '-u', 'NONE',
      '--cmd', 'cd /',
      '--cmd', 'echo v:argf',
      file1,
      '-c', 'qall',
    })

Review comment (suggestion):
use `n.spawn_wait()` . that avoids needing all the `-u ... -i`, it does that automatically. https://github.com/neovim/neovim/blob/28157738e3de7675a7527f6e4e3fb01e6d30e1bf/test/functional/core/main_spec.lua#L58-L65

Code after:
    clear { args_rm = { '-u' }, args = { '--cmd', 'lua _G.lista = {}' }, env = xenv }

    eq({ 'unos', 'dos' }, exec_lua 'return _G.lista')
  end)

  it('no crash setting &rtp in plugins with :packloadall called before #18315', function()
    local plugin_folder_path = table.concat({ xconfig, 'nvim', 'plugin' }, pathsep)
    mkdir_p(plugin_folder_path)
    finally(function()
      rmdir(plugin_folder_path)
    end)

    write_file(
      table.concat({ plugin_folder_path, 'plugin.vim' }, pathsep),
      [[
        let &runtimepath = &runtimepath
        let g:vim_plugin = 1
      ]]
    )
    write_file(
      table.concat({ plugin_folder_path, 'plugin.lua' }, pathsep),
      [[
        vim.o.runtimepath = vim.o.runtimepath
        vim.g.lua_plugin = 1
      ]]
    )

    clear { args_rm = { '-u' }, args = { '--cmd', 'packloadall' }, env = xenv }

    eq(1, eval('g:vim_plugin'))
    eq(1, eval('g:lua_plugin'))
  end)

  it("loads ftdetect/*.{vim,lua} respecting 'rtp' order", function()
    local rtp_folder = table.concat({ xconfig, 'nvim' }, pathsep)
    local after_rtp_folder = table.concat({ rtp_folder, 'after' }, pathsep)
    local ftdetect_folder = table.concat({ rtp_folder, 'ftdetect' }, pathsep)
    local after_ftdetect_folder = table.concat({ after_rtp_folder, 'ftdetect' }, pathsep)
    mkdir_p(ftdetect_folder)
    mkdir_p(after_ftdetect_folder)
    finally(function()
      rmdir(ftdetect_folder)
      rmdir(after_ftdetect_folder)
    end)
    write_file(table.concat({ rtp_folder, 'scripts.vim' }, pathsep), [[let g:aseq ..= 'S']])
    write_file(table.concat({ after_rtp_folder, 'scripts.vim' }, pathsep), [[let g:aseq ..= 's']])
    -- A .lua file is loaded after a .vim file if they only differ in extension.
    -- All files in after/ftdetect/ are loaded after all files in ftdetect/.
    write_file(
      table.concat({ ftdetect_folder, 'new-ft.vim' }, pathsep),
      [[