nvim-orgmode / nvim-orgmode/orgmode

Inconsistent test failure in indent_spec.lua → test_full_reindent ('with "indent", "0gg=G" reindents the whole file')

Open
#889 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Lua
Stars
3.9k
Forks
190
Avg merge
2d 13h
Merged PRs (30d)
7

Description

Describe the bug

I unfortunately don't have time to dig into this, but I wanted to at least document it. There are some spurious test failures that only occur randomly and AFAICT they always occur in the same file. I assume there's some sort of race condition/cache invalidation going on in indent.lua.

Steps to reproduce
$ FILE=tests/plenary/org/indent_spec.lua make test
Expected behavior

Tests pass

Emacs functionality

N/A

Minimal init.lua

tests/minimal_init.lua

Screenshots and recordings

Full error output:

Fail    ||      with "indent", "0gg=G" reindents the whole file 
            ...s/nvim-plugins/orgmode/tests/plenary/org/indent_spec.lua:6: Expected objects to be the same.
            Passed in:
            (table: 0x7f2a7e8cecc8) {
              [1] = '* TODO First task'
              [2] = 'SCHEDULED: <1970-01-01 Thu>'
              [3] = ''
              [4] = '1. Ordered list'
              [5] = '   a) nested list'
              [6] = '      over-indented'
              [7] = '      over-indented'
              [8] = '   b) nested list'
              [9] = '      under-indented'
              [10] = '2. Ordered list'
              [11] = 'Not part of the list'
              [12] = ''
              [13] = '** Second task'
              [14] = 'DEADLINE: <1970-01-01 Thu>'
              [15] = ''
              [16] = '- Unordered list'
              [17] = '  + nested list'
              [18] = '    over-indented'
              [19] = '    over-indented'
              [20] = '  + nested list'
              [21] = '    under-indented'
              [22] = '- unordered list'
              [23] = '  + nested list'
              [24] = '    * triple nested list'
              [25] = '      continuation'
              [26] = '  part of the first-level list'
              [27] = 'Not part of the list'
              [28] = ''
              [29] = '*** Incorrectly indented block'
              [30] = '#+BEGIN_SRC json'
              [31] = '{'
              [32] = '  "key": "value",'
              [33] = '  "another key": "another value"'
              [34] = '}'
              [35] = '#+END_SRC'
              [36] = ''
              [37] = '- Correctly reindents to list indentation level'
              [38] = '  #+BEGIN_SRC json'
              [39] = '  {'
              [40] = '    "key": "value",'
              [41] = '    "another key": "another value"'
              [42] = '  }'
              [43] = '  #+END_SRC'
              [44] = '- Correctly reindents when entire block overindented'
              [45] = '  #+BEGIN_SRC json'
              [46] = '  {'
              [47] = '    "key": "value",'
              [48] = '    "another key": "another value"'
              [49] = '  }'
              [50] = '  #+END_SRC'
              [51] = '- Correctly maintains indentation when single line is at the same level as header and rest is overindented'
              [52] = '  #+BEGIN_SRC json'
              [53] = '  {'
              [54] = '       "key": "value",'
              [55] = '       "another key": "another value"'
              [56] = '           }'
              [57] = '  #+END_SRC'
              [58] = '- Correctly ignores blank lines for calculating indentation'
              [59] = '  #+BEGIN_SRC json'
              [60] = ''
              [61] = '  {'
             *[62] = '  "key": "value",'
              [63] = ''
              [64] = '  "another key": "another value"'
              [65] = '  }'
              [66] = ''
              [67] = '  #+END_SRC' }
            Expected:
            (table: 0x7f2a7e8cd1b8) {
              [1] = '* TODO First task'
              [2] = 'SCHEDULED: <1970-01-01 Thu>'
              [3] = ''
              [4] = '1. Ordered list'
              [5] = '   a) nested list'
              [6] = '      over-indented'
              [7] = '      over-indented'
              [8] = '   b) nested list'
              [9] = '      under-indented'
              [10] = '2. Ordered list'
              [11] = 'Not part of the list'
              [12] = ''
              [13] = '** Second task'
              [14] = 'DEADLINE: <1970-01-01 Thu>'
              [15] = ''
              [16] = '- Unordered list'
              [17] = '  + nested list'
              [18] = '    over-indented'
              [19] = '    over-indented'
              [20] = '  + nested list'
              [21] = '    under-indented'
              [22] = '- unordered list'
              [23] = '  + nested list'
              [24] = '    * triple nested list'
              [25] = '      continuation'
              [26] = '  part of the first-level list'
              [27] = 'Not part of the list'
              [28] = ''
              [29] = '*** Incorrectly indented block'
              [30] = '#+BEGIN_SRC json'
              [31] = '{'
              [32] = '  "key": "value",'
              [33] = '  "another key": "another value"'
              [34] = '}'
              [35] = '#+END_SRC'
              [36] = ''
              [37] = '- Correctly reindents to list indentation level'
              [38] = '  #+BEGIN_SRC json'
              [39] = '  {'
              [40] = '    "key": "value",'
              [41] = '    "another key": "another value"'
              [42] = '  }'
              [43] = '  #+END_SRC'
              [44] = '- Correctly reindents when entire block overindented'
              [45] = '  #+BEGIN_SRC json'
              [46] = '  {'
              [47] = '    "key": "value",'
              [48] = '    "another key": "another value"'
              [49] = '  }'
              [50] = '  #+END_SRC'
              [51] = '- Correctly maintains indentation when single line is at the same level as header and rest is overindented'
              [52] = '  #+BEGIN_SRC json'
              [53] = '  {'
              [54] = '       "key": "value",'
              [55] = '       "another key": "another value"'
              [56] = '           }'
              [57] = '  #+END_SRC'
              [58] = '- Correctly ignores blank lines for calculating indentation'
              [59] = '  #+BEGIN_SRC json'
              [60] = ''
              [61] = '  {'
             *[62] = '    "key": "value",'
              [63] = ''
              [64] = '    "another key": "another value"'
              [65] = '  }'
              [66] = ''
              [67] = '  #+END_SRC' }
            
            stack traceback:
                ...s/nvim-plugins/orgmode/tests/plenary/org/indent_spec.lua:6: in function 'expect_whole_buffer'
                ...s/nvim-plugins/orgmode/tests/plenary/org/indent_spec.lua:227: in function 'test_full_reindent'
                ...s/nvim-plugins/orgmode/tests/plenary/org/indent_spec.lua:278: in function <...s/nvim-plugins/orgmode/tests/plenary/org/indent_spec.lua:277>
OS / Distro

Fedora Silverblue 41

Neovim version/commit

0.10.3

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running FILE=tests/plenary/org/indent_spec.lua make test and inspect tests/plenary/org/indent_spec.lua, especially test_full_reindent and expect_whole_buffer. Compare the intermittent line-62 indentation mismatch with indent.lua and the setup in tests/minimal_init.lua; done means the test passes consistently without spurious failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.