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

Code before:
      'Xargf_file1',
      'Xargf_file2',
      'Xargf_sep1',
      'Xargf_sep2',
    }) do
      os.remove(f)
    end
  end)

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

  it('stores full path of file args', 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 p =
      n.spawn_wait('--cmd', 'echo v:argf', '-c', 'qall', file1, file2, 'https://example.com')

    eq(0, p.status)
    matches(pesc(abs1), p.stderr)
    matches(pesc(abs2), p.stderr)
  end)

  it('handles -- separator correctly', function()
    local file1, file2 = 'Xargf_sep1', 'Xargf_sep2'
    write_file(file1, '')
    write_file(file2, '')
    files = { file1, file2 }

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

    local p = n.spawn_wait('--cmd', 'echo v:argf', '-c', 'qall', '--', file1, file2)

    eq(0, p.status)
    matches(pesc(abs1), p.stderr)
    matches(pesc(abs2), p.stderr)
  end)

  it('is read-only', function()
    matches('E46', t.pcall_err(command, "let v:argf = ['foo']"))
  end)

Review comment (suggestion):
also test that `:argadd` doesn't affect `v:argf` : 

```suggestion
      n.spawn_wait('--cmd', 'argadd extrafile.txt', '--cmd', 'echo v:argf', '-c', 'qall', file1, file2, 'https://example.com')
```

Code after:
    write_file(plugin_file_path, [[table.insert(_G.lista, "unos")]])
    write_file(plugin_after_file_path, [[table.insert(_G.lista, "dos")]])

    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/.