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

Code before:
    it('exrc from parent directories', function()
      setup_exrc_file('.nvim.lua')
      setup_exrc_file('../.exrc')
      clear { args_rm = { '-u' }, env = xstateenv }
      local screen = Screen.new(50, 8)
      screen._default_attr_ids = nil
      fn.jobstart({ nvim_prog }, {
        term = true,
        env = {
          VIMRUNTIME = os.getenv('VIMRUNTIME'),
        },
      })
      -- current directory exrc is found first
      screen:expect({ any = '.nvim.lua' })
      screen:expect({ any = pesc('[i]gnore, (v)iew, (d)eny:'), unchanged = true })
      feed('iv')

      -- after that the exrc in the parent directory
      screen:expect({ any = '.exrc', unchanged = true })
      screen:expect({ any = pesc('[i]gnore, (v)iew, (d)eny:'), unchanged = true })
      feed('v')

      -- trust .exrc
      feed(':trust<CR>')
      screen:expect({ any = 'Allowed' })
      screen:expect({ any = '.exrc', unchanged = true })
      feed(':q<CR>')
      -- trust .nvim.lua
      feed(':trust<CR>')
      screen:expect({ any = 'Allowed', unchanged = true })
      screen:expect({ any = '.nvim.lua', unchanged = true })
      feed(':q<CR>')
      -- no exrc file is exeecuted
      feed(':echo g:exrc_count<CR>')
      screen:expect({ any = 'E121: Undefined variable: g:exrc_count' })

      -- restart nvim
      feed(':restart<CR>')
      screen:expect([[
        ^                                                  |
        ~                                                 |*4
        [No Name]                       0,0-1          All|
                                                          |
        -- TERMINAL --                                    |
      ]])

      -- a total of 2 exrc files are executed
      feed(':echo g:exrc_count<CR>')
      screen:expect({ any = '2' })
    end)
  end)

Review comment (suggestion):
this is the same screen, isn't it? just use a multiline pattern to match the contents of 1 screen, instead of multiple expect() with `unchanged=true`.

same for the other cases below.

```suggestion
      screen:expect({ any = 'Allowed.*\n.exrc' })
```

Code after:
    it('exrc from parent directories', function()
      setup_exrc_file('.nvim.lua')
      setup_exrc_file('../.exrc')
      clear { args_rm = { '-u' }, env = xstateenv }
      -- use a screen wide width to avoid wrapping the word `.exrc`, `.nvim.lua` below.
      local screen = Screen.new(500, 8)
      screen._default_attr_ids = nil
      fn.jobstart({ nvim_prog }, {
        term = true,
        env = {
          VIMRUNTIME = os.getenv('VIMRUNTIME'),
        },
      })
      -- current directory exrc is found first
      screen:expect({ any = '.nvim.lua' })
      screen:expect({ any = pesc('[i]gnore, (v)iew, (d)eny:'), unchanged = true })
      feed('iv')

      -- after that the exrc in the parent directory
      screen:expect({ any = '.exrc', unchanged = true })
      screen:expect({ any = pesc('[i]gnore, (v)iew, (d)eny:'), unchanged = true })
      feed('v')

      -- trust .exrc
      feed(':trust<CR>')
      screen:expect({ any = 'Allowed ".*' .. pathsep .. '%.exrc" in trust database.' })
      feed(':q<CR>')
      -- trust .nvim.lua
      feed(':trust<CR>')
      screen:expect({ any = 'Allowed ".*' .. pathsep .. '%.nvim%.lua" in trust database.' })
      feed(':q<CR>')
      -- no exrc file is executed
      feed(':echo g:exrc_count<CR>')
      screen:expect({ any = 'E121: Undefined variable: g:exrc_count' })

      -- restart nvim
      feed(':restart<CR>')
      screen:expect([[
        ^{MATCH: +}|
        ~{MATCH: +}|*4
        [No Name]{MATCH: +}0,0-1{MATCH: +}All|
        {MATCH: +}|
        -- TERMINAL --{MATCH: +}|
      ]])

      -- a total of 2 exrc files are executed
      feed(':echo g:exrc_count<CR>')
      screen:expect({ any = '2' })
    end)
  end)