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

Xcode 5 automatically adds -NSDocumentRevisionsDebugMode YES to end of args, which screws up the Catch arg parser #230

Closed
sjmills opened this issue Dec 13, 2013 · 15 comments

Comments

@sjmills
Copy link

sjmills commented Dec 13, 2013

It keeps parsing through "NSDocumentRevisionsDebugMode" until it gets to 'o', which it thinks is the -o argument, then complains that 'c' isn't a valid argument or something like that. The user can temporarily work around this by turning off "Allow debugging when using document Versions Browser" in the Edit Scheme dialog.

@philsquared
Copy link
Collaborator

I'm not seeing any args being automatically added - are you sure you've not specified that in your scheme?

As for it parsing into -NSDo and finding -o I was able to reproduce that by explicitly passing -NSDocumentRevisionsDebugMode. I'll have a look into that one. Thanks.

@sjmills
Copy link
Author

sjmills commented Dec 15, 2013

You probably need to use a project that is an OS X Cocoa app that uses documents, and in the scheme editor, have the "Allow debugging when using document Versions Browser" turned on. The arguments I specify in the scheme are "-b -d yes --out %stderr".

@philsquared
Copy link
Collaborator

Re: "project that is an OS X Cocoa app that uses documents" etc - fair enough.
I've looked into this a bit more and I can see what the problem is now. Unfortunately it's working pretty much as designed!
The command line syntax that Catch follows treats "-" prefixed strings as single-character short options. A string of characters is interpreted a sequence of single short options (e.g. -eb is the same as -e -b).

So -NSDocumentRevisionsDebugMode is being interpreted as -N, -S, -D, -o etc.

Now the underlying issue is probably obfuscated a bit by something I can change. Unrecognised options are stored until the end of the parse (as what to do with them is decided externally). So the N, S and D are skipped over for now. Then it comes to -o, which it recognises as a Catch option (for specifying the output filename). But -o then expects an argument - which will be the next command line argument that doesn't begin with - (in my case it says there is no argument - perhaps in your case it's finding something else).

So:

  1. Catch cannot handle being passed -NSDocumentRevisionsDebugMode. If there's no way, in general, to avoid being passed it (assuming your workaround is not satisfactory), then all I can suggest is to write your own main() and filter it out before passing on to Catch (I can give more info on how to do that if you like).
  2. I'll see if I can make some changes so the error you get is actually that it doesn't recognise -N, which might make it more obvious what's happening. It doesn't help your immediate situation but it might help the next person.

@philsquared
Copy link
Collaborator

I've committed build 22 which has the changes I proposed in (2), above

@sjmills
Copy link
Author

sjmills commented Dec 21, 2013

Cool. I'm on vacation for the rest of the year, so I'll take a look when I get back to it.

We don't use the document revisions feature of Cocoa at this point, but certainly might in the future, in which case it might be necessary to use -NSDocumentRevisionsDebugMode. We should be able to filter out -NSDocumentRevisionsDebugMode at that time, but others might run into this same problem. It'd be nice if the parser could notice that the current token after the '-' (NSDocumentRevisionsDebugMode in this case) is not a collection of valid Catch options and just ignore it the entire thing.

@Kosta-Github
Copy link
Contributor

Can't you just use something like '--' or so and after that ignore all following arguments? E.g.:
unit_test -eb -- -NSDocumentRevisionsDebugMode ...

@philsquared
Copy link
Collaborator

That's a good suggestion - and, now you mention it, I think I've seen similar in other libraries

@martinmoene
Copy link
Collaborator

See e.g. Guideline 10 in POSIX.1-2008 Section 12.2 Utility Syntax Guidelines.

@philsquared
Copy link
Collaborator

... and was only a one line change - I've now committed it as build 23

@martinmoene
Copy link
Collaborator

It's also not uncommon to use '-' (dash) to designate standard input. This could be used with option -f, --input-file to load test names to run from a file or stdin. However, this remark doesn't really belong here ;-)

@sjmills
Copy link
Author

sjmills commented Jan 2, 2014

I got the latest version to try, but had to make a bunch of changes to our project and some source files to build with C++0x turned on. Some std::string things are crashing when I do this, so I can't get far enough along to try your parsing changes. Just an FYI about using C++0x.

@Kosta-Github
Copy link
Contributor

I think this could be closed now...

@philsquared
Copy link
Collaborator

Thanks @Kosta-Github. However I'd somehow missed @sjmills last comment until now.

  • are you still having issues there?
    What sort of changes did you have to make (sorry, I know it was a while ago now).

@sjmills
Copy link
Author

sjmills commented Feb 11, 2014

I haven't gotten back to looking at the C++11 problems because more important things always get in the way. But when I did check, I was able to use -- and have Catch ignore everything after that. So yeah, the original issue is closed.

@sjmills sjmills closed this as completed Feb 11, 2014
@philsquared
Copy link
Collaborator

Thanks @sjmills.
If you come across C++11 issues again please raise another ticket.

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

No branches or pull requests

4 participants