Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] hlsearch/incsearch screen tests + convert test 63 #1930

Merged
merged 3 commits into from Mar 19, 2015

Conversation

bfredl
Copy link
Member

@bfredl bfredl commented Feb 2, 2015

work in progress. Should also test matchadd/pos/ as its implementation is quite entangled with search_hl (ref #1841 )

@marvim marvim added the WIP label Feb 2, 2015
@bfredl bfredl changed the title [WIP] hlsearch/incsearch screen tests [WIP] hlsearch/incsearch/matchaddpos screen tests + convert test 63 Feb 12, 2015
@bfredl
Copy link
Member Author

bfredl commented Feb 12, 2015

also converting test 63 as it is a bit related, but there is some issues. Apparently a vimscript function can both throw an error and at the same time (as if nothing happened) return an ordinary value, and I don't know how to check that using vim_eval (which must either return an error or a value, but not both) or similar.

@justinmk
Copy link
Member

Apparently a vimscript function can both throw an error and at the same time (as if nothing happened) return an ordinary value

Yes, I believe that's true, @ZyX-I mentioned it before.

I think the lua vim_eval should multi-return a (result, error) pair. In most tests the error value will just be ignored. Any tests that were looking for the error message will need to be updated.

@elmart
Copy link
Contributor

elmart commented Feb 12, 2015

Apparently a vimscript function can both throw an error and at the same time (as if nothing happened) return an ordinary value

Didn't know that. But... then, what would the control flow be? I mean, how are you supposed to manage such a thing?

@bfredl
Copy link
Member Author

bfredl commented Feb 12, 2015

@elmart That, exactly, is the question. apparently :echo matchdelete(51) + 10 evals to 9 (and also prints the error), so an error doesn't interrupt expression evaluation. Now what happens if you assign this to a let (or sideeffecty function) inside a try? I don't see any "intuitive" answer.

@bfredl
Copy link
Member Author

bfredl commented Feb 12, 2015

@justinmk I think vim_eval still does the "sensible" default (if there is an error, the result is typically -1 or something else boring), but there should be a vim_try_eval or something which doesn't turn eval errors into msgpack errors and returns a tuple as you suggested (but perhaps, still turns syntax errors into msgpack errors)

@justinmk
Copy link
Member

Not sure if I'm missing something but if vim_eval returns a (result, error) pair, the error part can be ignored on assignment:

result = helpers.vim_eval(...)

Why would we need a separate vim_try_eval method?

@bfredl
Copy link
Member Author

bfredl commented Feb 12, 2015

No i meant vim_eval should still throw an error (i e signal an msgpack
error) while vim_try_eval would return the error (which can be igored as
you say) I dont think just igoring errors (and manually have to check for
errors) would be a sensible default in most situations
Den 12 feb 2015 23:06 skrev "Justin M. Keyes" notifications@github.com:

Not sure if I'm missing something but if vim_eval returns a (result,
error) pair, the error part can be ignored on assignment:

result = helpers.vim_eval(...)

Why would we need a separate vim_try_eval method?


Reply to this email directly or view it on GitHub
#1930 (comment).

@justinmk
Copy link
Member

Oh, good point.

@bfredl
Copy link
Member Author

bfredl commented Feb 14, 2015

More trouble on the same theme: the following causes the test to just freeze

local helpers = require('test.functional.helpers')
local eval, clear, execute, expect = helpers.eval, helpers.clear, helpers.execute
local expect, eq, neq = helpers.expect, helpers.eq, helpers.neq

describe('test the tests', function()
  setup(clear)

  it('is working', function()
    execute("let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])")
    eq(0, eval("r1")) -- freezes

    -- more tests follow
  end)
end)

The freeze is actually on the eq line, as if r1 somehow got "poisoned"; remove it and it will just continue with the rest of the test (in the same nvim instance)

@bfredl
Copy link
Member Author

bfredl commented Feb 14, 2015

Problem was a "Press ENTER to continue" that blocked the event loop. (weird, as the same problem ought to have been at execute("let r2 = matchdelete(42)"); eq(-1, eval('r2')) above)
I suppose one could just use nvim_command for commands that expect to fail, but it would have been nice if execute was able to detect this condition somehow (instead of just waiting indefinitely)

@bfredl bfredl force-pushed the searchhltest branch 2 times, most recently from 23b7df1 to 8e9d729 Compare February 21, 2015 21:37
@bfredl bfredl changed the title [WIP] hlsearch/incsearch/matchaddpos screen tests + convert test 63 [RFC] hlsearch/incsearch screen tests + convert test 63 Feb 21, 2015
@bfredl
Copy link
Member Author

bfredl commented Feb 21, 2015

Now it it working, but those feed('<cr>') look like an indeterminacy waiting to happen. Is there some reliable way to just turn off Press Enter or press key to continue ? (or should it considered a bug that this condition freezes event processing ? ) I can't use pcall(function() command(...)) as it interrupts evaluation. Or perhaps it is ok to leave it a TODO until vim_try_eval or similar is implemented?

@justinmk
Copy link
Member

Is there some reliable way to just turn off Press Enter or press key to continue ?

No. But if there were, the tests would not simulate the user experience...

@bfredl
Copy link
Member Author

bfredl commented Feb 21, 2015

Good point. But do you know if execute('...'); feed('<cr>') where the <cr> dissmisses a message caused by the execute (a single call) is potentially indeterministic or not? (i e one could rely on the <cr> not being consumed before the prompt is shown)

@bfredl
Copy link
Member Author

bfredl commented Feb 21, 2015

When I think of it more, nothing should potentially consume input between the final <cr> of the execute and the error prompt, but it would be good if someone could confirm it...

@justinmk
Copy link
Member

I haven't seen any flakiness related to that in the 30 tests I have been working on. But I do not know for sure.

@bfredl
Copy link
Member Author

bfredl commented Feb 23, 2015

Ok, removed the TODOs as the current implementation is closest to the legacy test (and probably to realistic user experience). Marked RFC, but marvim didn't seem to notice...

@bfredl
Copy link
Member Author

bfredl commented Feb 25, 2015

I added a small cleanup to screen_basic_test I forgot to do when working on #1883

@bfredl
Copy link
Member Author

bfredl commented Mar 2, 2015

Rebased and fixed some whitespace.

@bfredl
Copy link
Member Author

bfredl commented Mar 9, 2015

Rebased after #2101 . ping @tarruda

@tarruda
Copy link
Member

tarruda commented Mar 11, 2015

👍 LGTM

I'm not sure if you are aware, but test hangs can be debugged more easily if you attach the pygtk UI by adding a Screen.debug() statement at the beginning of the test(or anywhere before the hang happens)

@bfredl
Copy link
Member Author

bfredl commented Mar 11, 2015

@tarruda Thanks, I think I saw it in the code but I have not tested it yet.

It would be good if events are processed in the "press ENTER" state later on, but until then, I think feed('<cr>') is the simplest solution.

@bfredl
Copy link
Member Author

bfredl commented Mar 11, 2015

And given constant screen size it should be deterministic which error messages require this prompt, so this should be safe.

@tarruda
Copy link
Member

tarruda commented Mar 11, 2015

It would be good if events are processed in the "press ENTER" state later on, but until then, I think feed('') is the simplest solution.

That probably is the main reason I want to eventually refactor the user dialog/message interface to use the terminal abstraction being implemented in #2076. If we remove most "block the world' prompt code, then nvim will always be in a state where it can process vimscript and consequently there will be no need for this distinction between deferred and non deferred events.

@bfredl
Copy link
Member Author

bfredl commented Mar 19, 2015

@tarruda Bump. Something missing here, or could this be merged?

@justinmk
Copy link
Member

looking now

@justinmk justinmk added the test label Mar 19, 2015
@justinmk justinmk merged commit cf88f33 into neovim:master Mar 19, 2015
@justinmk justinmk removed the RFC label Mar 19, 2015
lucc added a commit to lucc/neovim that referenced this pull request Jul 18, 2015
Remove legacy tests from the old makefile that were forgotten after the test
migration.  The tests are:

- test 26 migrated in da3ade6 merged in neovim#1420
- test 27 migrated in ac52d84 merged in neovim#1328
- test 43 migrated in c915958 merged in neovim#1420
- test 46 migrated in 5ea94e1 merged in neovim#1428
- test 63 migrated in a040aa9 merged in neovim#1930

Additionally the tests 71 and 72 where removed in
85338fe together with the +cryptv feature.
ghost pushed a commit that referenced this pull request Jul 19, 2015
Remove legacy tests from the old makefile that were forgotten after the test
migration.  The tests are:

- test 26 migrated in da3ade6 merged in #1420
- test 27 migrated in ac52d84 merged in #1328
- test 43 migrated in c915958 merged in #1420
- test 46 migrated in 5ea94e1 merged in #1328
- test 63 migrated in a040aa9 merged in #1930

Additionally the tests 71 and 72 where removed in
85338fe together with the +cryptv feature.
mgraczyk pushed a commit to mgraczyk/neovim that referenced this pull request Aug 10, 2015
Remove legacy tests from the old makefile that were forgotten after the test
migration.  The tests are:

- test 26 migrated in da3ade6 merged in neovim#1420
- test 27 migrated in ac52d84 merged in neovim#1328
- test 43 migrated in c915958 merged in neovim#1420
- test 46 migrated in 5ea94e1 merged in neovim#1328
- test 63 migrated in a040aa9 merged in neovim#1930

Additionally the tests 71 and 72 where removed in
85338fe together with the +cryptv feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants