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

Allow multiple input files #22

Merged
merged 4 commits into from
Oct 15, 2015
Merged

Allow multiple input files #22

merged 4 commits into from
Oct 15, 2015

Conversation

timkendrick
Copy link
Collaborator

This PR allows the jsctags executable to accept multiple input files, as follows:

jsctags index.js server.js
jsctags *.js -f

...it also removes the double line breaks in the -f ctags output mode.

I've also added the tagfile field to the JSON output (to avoid ambiguity if there are multiple source files).

Let me know if there's anything I can change to help get this merged!

@timkendrick
Copy link
Collaborator Author

I've also added a commit that sorts the ctag output lines alphabetically.

These two commits in combination should solve #13, allowing you to output a vim-compatible tags file for a whole project as follows:

jsctags `find . -name "*.js"` -f > tags

@faceleg
Copy link
Collaborator

faceleg commented Oct 14, 2015

This looks awesome!

One thing - could you please add a test?

@timkendrick
Copy link
Collaborator Author

I've taken a look at the test cases in the test/cases folder, and this change doesn't require a new case as such – rather it allows you to combine multiple cases into one operation.

I agree that it should be tested though. It seems that there was no automated testing set up in the test folder (only a script which outputs the results of a case, presumably for visual verification) so I've added a suite of tests:

  • Each test case in the test/cases directory now has accompanying .json and .tags files containing the expected output for that case
  • The test runner now asserts that the actual output for each file is the same as the expected output, for each of the following permutations:
    • JSON mode, input file passed as args
    • ctags mode, input file passed as args
    • JSON mode, input file piped into stdin
    • ctags mode, input file piped into stdin
  • Once the individual tests are complete, it runs tests that operate on the whole set of test cases at once (passed in as multiple args), and checks the output against the test/cases/_.json and test/cases/_.tags expected output. These are the tests that are most relevant for this PR.

A couple of points to note about the tests:

  • The output includes filenames, so it will vary according to which directory the tests are run from. To get around this, the sample output files can use a magic string named __DIR__, which is resolved to the test/cases folder path
  • I haven't added tests for the dir argument
  • I haven't added tests for omitting the file argument when piping input into stdin

I've also added a commit that enables ctags output when the input file is piped into stdin and the -f argument is specified.

Let me know if this all makes sense!

@faceleg
Copy link
Collaborator

faceleg commented Oct 15, 2015

Holy crap.

You sir, are a legend.

Only with powerful testing can a project attain perfection.

I am going to merge this in yesterday, and look at adding travis.ci.

faceleg added a commit that referenced this pull request Oct 15, 2015
@faceleg faceleg merged commit 2c31225 into sergioramos:master Oct 15, 2015
@faceleg
Copy link
Collaborator

faceleg commented Oct 15, 2015

I'm getting "ext must be a string" on line 64 of test/runner.js when doing npm test.

Looking into it

@faceleg
Copy link
Collaborator

faceleg commented Oct 15, 2015

OK fixed, pushing.

Thanks again! This is awesome! Now we can make actual progress towards making this the ultimate JS ctags tool 💃

@timkendrick
Copy link
Collaborator Author

Glad I could help out! I've been learning Vim over the last week and the overall JS support seems a bit rough around the edges – this project looks really promising for the ctags side of things though so I thought I'd pitch in.

One final thing to note is that the documentation examples are now slightly inaccurate due to the extra tagfile field, so I'm guessing you might want to regenerate those.

Good luck with the Travis integration – also happy to see semicolons have crept in there, that was driving me up the wall! ;)

@faceleg
Copy link
Collaborator

faceleg commented Oct 15, 2015

Hey, you put me in charge you get semicolons!

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.

2 participants