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] Screen conceal highlight tests #2055

Closed
wants to merge 1 commit into from
Closed

[RFC] Screen conceal highlight tests #2055

wants to merge 1 commit into from

Conversation

McKizzle
Copy link

Deleted the previous pull request (https://github.com/neovim/neovim/pull/2044)[https://github.com/neovim/neovim/pull/2044], added changes, created a feature branch, and fixed the commit message. Removed the search highlighting tests since (https://github.com/neovim/neovim/pull/1930)[https://github.com/neovim/neovim/pull/1930] already has several in place. @bfredl once your pull request is accepted I could add the extra highlighting tests into test/functional/ui/searchhl_spec.lua #1930 later.

@marvim marvim added the RFC label Feb 24, 2015
@bfredl
Copy link
Member

bfredl commented Feb 25, 2015

Nice work! Have you also considered testing e.g. concealends ?

@McKizzle
Copy link
Author

Thanks, I'll clean that up. I've never used concealends before in Vim. I'll add tests for it after I learn how it works.

@bfredl
Copy link
Member

bfredl commented Feb 25, 2015

Hmm, it looks like you rebased master commits into your feature branch, you probably want to the opposite (rebase your feature branch on top of master)
(Btw, not saying that that you need to test concealends as part of this PR, just pointing out that there are more options related to conceal that could be tested)

@McKizzle
Copy link
Author

Sorry about that, this is my first time contributing to such a large repository. So you are saying that I should rebase my branch onto master and then rebase master onto the feature branch? Also, once a pull request is created is it recommended to keep it in sync with upstream?

@bfredl
Copy link
Member

bfredl commented Feb 25, 2015

I am by no means a git expert, but I usually don't involve my local master branch at all when working on a feature branch, I do (on the feature branch)

git fetch origin
git rebase -i origin/master
make test #and/or test manually
git push # with -f if necessary

(where origin is the remote that refers to neovim/neovim )
There is usually no need to rebase a PR to master more frequently than when actual work is being done on the PR itself, (and usually not even then, unless the feature work is related to the changes on master, but it doesn't hurt to do it).

@McKizzle
Copy link
Author

I'll do that. So I should probably recreate this pull request so that there are no side-effects?

Thanks!

@bfredl
Copy link
Member

bfredl commented Feb 25, 2015

You can just force-push to the same branch (git push -f) and this PR will get updated, no need to create a new one.

@McKizzle
Copy link
Author

That worked like a charm! 👍

:syn match dAmpersand '[&][&]' conceal cchar=∧ |
]], {[1] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray}})
end)
it('&& Move Cursor Up', function()
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a extra line above the it statement.

@bfredl
Copy link
Member

bfredl commented Mar 9, 2015

Hmm, it seems like it is failing due to an actual redraw error (I can reproduce locally with my vimrc, but not with -u NONE )

@bfredl
Copy link
Member

bfredl commented Mar 9, 2015

Actually nvim -u NONE and
:syntax on
:set conceallevel=1
6O&&<esc>
:syn match testmatch '[&][&]' conceal cchar=x
is enough to reproduce. (first x is not shown)

@bfredl
Copy link
Member

bfredl commented Mar 21, 2015

seems issue in latest hg vim -u NONE -N as well, I will check/post to vim-dev

@bfredl
Copy link
Member

bfredl commented Mar 22, 2015

@McKizzle Nice work with testing all the different options ! Please rebase on master when you have time, it should fix some incorrect failures on travis. Also the test needs to be updated as the character under the cursor is no longer hidden in the screen expectations, i e ^& is now ^&&.

@justinmk justinmk added the test label Mar 22, 2015
@McKizzle
Copy link
Author

Thanks! I'll get around to this later and update the tests to reflect the new screen expectations.

@McKizzle
Copy link
Author

@bfredl changes have been pushed. I'll look around and see if there are any additional UI tests that I can add.


describe("Match", function()

describe("Multiple", function()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two describes could be joined. Perhaps a more descriptive header like describe("supports multiple matches", ?

@bfredl
Copy link
Member

bfredl commented Mar 26, 2015

While tests are nice, the titles could be a bit more descriptive. Note that busted will concatenate the titles of nested describe/it block, so you could have (as an example)

describe("concealing", ...
  describe("supports multiple matches", ...
    it("and moving the cursor up", ...
  ...
  describe("handles conceallevel", ...
    it("2", ....

and busted will mention the individual test as "concealing supports multiple matches and moving the cursor up" and "concealing handles conceallevel 2" and so on.

@McKizzle
Copy link
Author

@bfredl it would look cleaner that way. I'll combine those describes. Is there a testing style guide available on the wiki or in the docs? I did a search, but didn't find any.

@bfredl
Copy link
Member

bfredl commented Mar 28, 2015

No, I have mostly followed earlier tests myself, as well as looking a bit in busted documentation, but perhaps a few lines should be added to the wiki somewhere (there is https://github.com/neovim/neovim/wiki/Unit-tests but it is about the "contents" of the tests and not the style)

@McKizzle
Copy link
Author

OK.

@bfredl bfredl self-assigned this Apr 10, 2015
@McKizzle
Copy link
Author

Hello @bfredl. Sorry for the absence. Was in the process of getting a new job and moving to a new location. Is there a way to make busted print out the tests verbosely instead of as green dots? I noticed that busted lets you register your own output types, but I'm not sure how I would go about passing that in into TEST_FILE=test/functional/ui/syntax_conceal_spec.lua make unittest. That would make it easier to test the grammar.

@bfredl
Copy link
Member

bfredl commented Apr 19, 2015

No hurry :) The simplest way, seems to be changing the line in CMakeLists.txt
set(BUSTED_OUTPUT_TYPE "utfTerminal")
to
set(BUSTED_OUTPUT_TYPE "gtest")
and rerun make test
anyway passing it as an environment variable directly to make test doesn't work, one have to invoke the busted command manually for that it seems.

@bfredl
Copy link
Member

bfredl commented Apr 19, 2015

This also works (when standing in neovim, and already ran make test)
PATH=$PWD/.deps/usr/bin/:$PATH NVIM_PROG=build/bin/nvim ./.deps/usr/bin/busted -o gtest -v --lpath=build/\?.lua test/functional/ui/syntax_conceal_spec.lua

@McKizzle
Copy link
Author

Thanks, I'll give that a try. That information is quite useful, I could add that to the Unit tests wiki page. Unless the Building Neovim page is a better location.

@McKizzle
Copy link
Author

Using the other tests as a point of reference the new output looks like this.

Screen match and conceal multiple double ampersands
Screen match and conceal multiple double ampersands and move the cursor one line up.
Screen match and conceal multiple double ampersands and move the cursor to the beginning of the file.
Screen match and conceal multiple double ampersands and move the cursor to the second line in the file.
Screen match and conceal multiple double ampersands and then move the cursor to the beginning of the file and back to the end of the file.
Screen match and conceal keyword instances in initially in the document.
Screen match and conceal regions in the document initially and conceal it.
Screen match and conceal regions in the document initially and conceal its start tag and end tag.
Screen match and conceal regions in the document that are nested and conceal the nested region's start and end tags.
Screen match and conceal a region of text and turn on implicit concealing
Screen match and conceal a region of text and then turn on, then off, and then back on implicit concealing.
Screen let the conceal level be 0. No concealing.
Screen let the conceal level be 1. Conceal using cchar or reference listchars.
Screen let the conceal level be 2. Hidden unless cchar is set.
Screen let the conceal level be 3. Hide all concealed text.


describe("a region of text", function()
local syn_region_i_text = "syn region iText start='<i>' end='</i>' cchar=*"
local conceal_on = "syntax conceal on"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these, at least conceal_on and conceal_off, should be eliminated and the full command just put inside execute(). It is clearer if the command is just entered where it actually is used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do that then.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep it consistent and remove the syn_region_i_text variable also.

@bfredl
Copy link
Member

bfredl commented Apr 20, 2015

Nice! some additional comments, otherwise LGTM. 👍

If you want to do more screen tests (after this PR), it might be good to know that you can pass a screen size to Screen.new, like Screen.new(40, 10), to not get a bigger screen than actually needed. But there is no need to change this now in this PR (If you feel like it, a tip is to keep the width as 53 (default) and lower the lines from 14 to say, 10, and just delete 4 of the repeated lines in each except. But if there is some trouble just leave it like it is)

@McKizzle
Copy link
Author

Thanks! Being able to modify the screen dimensions is helpful. I'll go through and minimize the height of the screens (they were making the file to large) and tidy up the code some more.

@bfredl
Copy link
Member

bfredl commented May 8, 2015

Sorry, I was a bit busy with other stuff and forgot about this PR. Please rebase and squash.

@McKizzle
Copy link
Author

McKizzle commented May 9, 2015

No problem! Rebased and squashed the branch.

bfredl pushed a commit that referenced this pull request May 9, 2015
@bfredl
Copy link
Member

bfredl commented May 9, 2015

Merged, thanks!

@McKizzle
Copy link
Author

McKizzle commented May 9, 2015

Yay! Should I close this branch now?

@bfredl
Copy link
Member

bfredl commented May 9, 2015

Yes, you can delete the branch.
Den 9 maj 2015 5:41 em skrev "Clinton McKay" notifications@github.com:

Yay! Should I close this branch now?


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

@ghost ghost closed this May 9, 2015
@jszakmeister jszakmeister removed the RFC label May 9, 2015
mbainter pushed a commit to mbainter/neovim that referenced this pull request May 9, 2015
Shougo pushed a commit to Shougo/neovim that referenced this pull request May 21, 2015
Shougo pushed a commit to Shougo/neovim that referenced this pull request May 21, 2015
This pull request was closed.
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

6 participants