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

Add test file #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

janEbert
Copy link
Contributor

Correspondingly, add the generated "tags" file to .gitignore.
I tried to add "actual code" and have too many tests rather than only
complex ones.
Surely, some cases are not covered. For example, using multiple macros
for a definition.

@oxinabox
Copy link
Member

Do you think we can construct some actual tests that run on CI?
They would need to be written in Bash, I guess.
Or in Julia using run(`ctag ...`)
which could be fine

@janEbert
Copy link
Contributor Author

Sure, I'd love to look into that! Though I have never set up CI.
The tests would fail though as with the simple regexes, edge cases are simply not covered:

#=
const old_zero = 0
=#

... would be parsed as an identifier.

That is also why I think a proper parser would be more useful. I have thought about writing one for Universal Ctags that would be more sophisticated than the current one but it would take some time. Guess the tests failing would be the exact thing we want until then. :)

@oxinabox
Copy link
Member

I think easiest would be to setup CI for julia and write the tests in julia,
after doing readlines on the genated file.

Then you could do @test_broken for the edge cases that fail.

You can copy the .travisci from any julia project to do that.

@oxinabox
Copy link
Member

oxinabox commented Jul 29, 2019

If you write the tests, so you can run them locally
I will make it work with Travis CI

@janEbert
Copy link
Contributor Author

janEbert commented Jul 29, 2019

How would you go about using the external Universal Ctags? They don't have release tags and the binary name may be hard to find due to name overlaps with Exuberant Ctags or Etags.

Or should I just write, try and see using ctags as the executable?

If you write the tests, I will make it work with Travis CI

Thanks, but I'd actually be glad to learn by doing!

@oxinabox
Copy link
Member

Can't we just use Exuberant Ctags ?
Or are we using new features? (if so that needs to go in the readme)

@janEbert
Copy link
Contributor Author

janEbert commented Jul 29, 2019

You are absolutely right and I see why naming is no problem.
We do not use new features, everything is still vanilla. :)

I added the tests and Travis CI, hope you are content with the code.
I tried to make local testing easy as well by trying different binaries.

Broken features are marked depending on the identifier name or the "kind" (function, variable, struct, ...).

The tests will fail now because I based them on the updated ctags file (#4).

Project.toml Outdated Show resolved Hide resolved
@janEbert
Copy link
Contributor Author

Hey, the build keeps being stuck on "Resolving package versions..." when testing. I couldn't find any other reports via searching and have checked out other Project.tomls and runtest.jls, however, nothing seems different.
Do you have an idea what could be wrong?

test/runtests.jl Outdated Show resolved Hide resolved
@oxinabox
Copy link
Member

Do your tests work fine locally?

@janEbert
Copy link
Contributor Author

janEbert commented Jul 30, 2019

Yes, I tested just now with:

$ JULIA_LOAD_PATH=$PWD julia
julia> ]
(julia-ctags) pkg> test

And it worked fine. Though as I mentioned, if the tests ran in Travis, they would fail because I based them on the new ctags file in #4.

Edit:
I also just tested using the same command Travis uses (plus the --project flag) and it did not hang up.

@janEbert
Copy link
Contributor Author

Sorry to spam; after trying a lot, I still haven't figured out how to remove those duplicate commits from master. I will fix it later, though.

@karlwessel
Copy link

Hey, the build keeps being stuck on "Resolving package versions..." when testing. I couldn't find any other reports via searching and have checked out other Project.tomls and runtest.jls, however, nothing seems different.
Do you have an idea what could be wrong?

I tried your PR at my own machine and it gets stuck in an endless loop because none of the predefined ctags executables worked. The same probably happens to Travis.

You probably should make sure that trygeneratetags and the tests exit gracefully if no ctags executable is found and maybe add ctags to the list of ctags executables in ctagsbins.

@m-wells
Copy link
Contributor

m-wells commented Oct 17, 2019

I'm not sure how much packaging you want to do with this but you could always provide a ctags build if one wasn't found either with BinaryProvider.jl or with the Anaconda Ctags package using Conda.jl.

If you go this route you would probably want to make this into a proper julia package.

@oxinabox
Copy link
Member

If you go this route you would probably want to make this into a proper julia package.

That wouldn't really make sense.
This file needs to go into your ctags config

@m-wells
Copy link
Contributor

m-wells commented Oct 17, 2019

If you go this route you would probably want to make this into a proper julia package.

That wouldn't really make sense.
This file needs to go into your ctags config

Not really. It can be passed in as an option to the ctags command via --options=pathname

@oxinabox
Copy link
Member

When you do Pkg.add or even use Artifacts stuff the files endup in an arbitrary location.
Not somewhere you can reliably find them.

@m-wells
Copy link
Contributor

m-wells commented Oct 18, 2019

@oxinabox I created a pull request #6 to package julia-ctags into JuliaCtags (to stick with the Julia package naming conventions). It isn't much but it provides a method to copy the ctags config file into the current directory (naming the new file julia_ctags by default). If a ctags install was shipped with this package (see my comment in the pull request) other methods could be implemented that allow users to generate tags files using the package.

In addition, optionally providing a ctags install also means testing this package becomes much easier on Travis (or any other CI platform).

@janEbert
Copy link
Contributor Author

Hey Karl, thank you so much for finding that. I actually hadn't forgotten this PR but due to the CI failing and me being so ashamed of the test code (it doesn't seem "right" at all), I never cared finishing it... Sorry! 😅

I will fix it later so #6 can be merged as well. By the way, I also wrote an Etags file for use with the Emacs-internal tags engine. Do you want it in the repo as well?

Correspondingly, add the generated "tags" file to .gitignore.
I tried to add "actual code" and have too many tests rather than only
complex ones.
Surely, some cases are not covered. For example, using multiple macros
for a definition.
Many tests are still marked as broken.
The test/testtags file contains the desired tags to obtain. Some need
only a little work, some need a more complete parser than the current
argument-regex-based approach.

We could possibly use the master of Universal Ctags for MacOS but that
would introduce another error surface.
@janEbert
Copy link
Contributor Author

janEbert commented Oct 24, 2019

Sorry it took so long. I also remembered why I didn't add the ctags executable in the first place. It was to avoid incompatibilities in case etags, often mapped to ctags, was found. Of course, due to the possibility of simply ordering the binaries, that didn't make sense. Also, that while-loop was pretty embarrassing, oh man... Good it's gone now. :)

Copy link

@karlwessel karlwessel left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to write those tests! I added a few comments on the current commit.


"Ctags binaries to sequentially try to call if one is not found."
const ctagsbins = (
"uctags",

Choose a reason for hiding this comment

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

You should change the order of the possible tag command in such a way that the tag command available at your own system is last in the list. This way your make sure that you test the error case of the trygeneratetags method.

It would probably also be a good idea to only add those tag binaries to the list for which you can actually execute the tests. It is better to have a short but testes list of binaries then a complete but untested list.

People using binaries not in the list can then add their binary to the list them self, see if the test work and create an according PR or issue if necessary.

return generatetags(testfile, ctagsbinary)
catch e
# For compatibility accept either exception type.
if !(err isa LoadError || err isa ErrorException

Choose a reason for hiding this comment

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

For uctags the generatetags method failed with a Base.IOError instead of a LoadError (although from the printed error message it looked like a LoadError), so you should add that one to the list of 'acceptable' error.

I'm not sure if adding LoadError to the list of acceptable Exceptions is necessary. At least for my setup none of the failing tag binaries did throw an actual LoadError.

Copy link
Member

Choose a reason for hiding this comment

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

I expected ProcessFailedException

Copy link
Contributor Author

@janEbert janEbert Nov 1, 2019

Choose a reason for hiding this comment

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

Sorry, I was busy when pushing and didn't test. I'll be sure to fix it, thanks again, Karl!
I actually can't remember why I included the LoadError (should have documented that one) but I'm sure it's there for a reason. Maybe I can replicate it again. But yeah if the IOError looked like a LoadError that may be the reason.

Hey Lyndon, that one's listed one line below, you can't see it in the diff.

Copy link
Member

Choose a reason for hiding this comment

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

ah cool cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants