orgmode icon indicating copy to clipboard operation
orgmode copied to clipboard

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

Open broken-pen opened this issue 10 months ago • 1 comments

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

broken-pen avatar Feb 04 '25 09:02 broken-pen

Thanks for documenting it. I also noticed this from time to time but didn't manage to figure out what's the issue. It's probably a race condition.

kristijanhusak avatar Feb 04 '25 10:02 kristijanhusak