Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #42339] [CAGE] Test Valid and Invalid Parrot Flags

2 views
Skip to first unread message

Chromatic

unread,
Apr 8, 2007, 3:07:13 AM4/8/07
to bugs-bi...@rt.perl.org
# New Ticket Created by chromatic
# Please include the string: [perl #42339]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42339 >


When Parrot processes its command-line arguments, it detects valid and invalid
flags and reports invalid flags, then exits with an exit code of 1.

I could find no tests for this feature. They would be lovely to have.

See the parseflags() function in compilers/imcc/main.c (and possibly
src/main.c in the near future) for the source of the error message and
parrot -h for a list of valid flags and options.

-- c

James Keenan via RT

unread,
Apr 8, 2007, 9:37:58 AM4/8/07
to perl6-i...@perl.org
On Sun Apr 08 00:07:13 2007, chro...@wgz.org wrote:
> When Parrot processes its command-line arguments, it detects valid and
> invalid
> flags and reports invalid flags, then exits with an exit code of 1.
>
> I could find no tests for this feature. They would be lovely to have.
>

A week ago I submitted a patch which extracted the CL argument processing functionality
from Configure.pl and placed it in lib/Parrot/Configure/Options.pm. The purpose of the
patch was specifically to improve the testability of the functionality in Configure.pl. The
patch also included a test file, t/configure/01-options.t, which, among other things, included
a test for an invalid option.

Having heard no objection, I applied that patch to trunk this past Wednesday, so if you've
been configuring and building Parrot in the past 4 days, you've been building with this
version of Configure.pl. And if you've been running 'make test', the test I contributed has
been the very first test to run.

Prompted by your post, I added one additional test to that file this morning. Are there
additional tests of the CL argument processing functionality you'd like to see? If so, patch
away!

Thank you very much.

kid51

Chromatic

unread,
Apr 8, 2007, 5:10:37 PM4/8/07
to parrotbug...@parrotcode.org
On Sunday 08 April 2007 06:37, James Keenan via RT wrote:

> On Sun Apr 08 00:07:13 2007, chro...@wgz.org wrote:

> > When Parrot processes its command-line arguments, it detects valid and
> > invalid flags and reports invalid flags, then exits with an exit code of
> > 1.

> > I could find no tests for this feature. They would be lovely to have.
>
> A week ago I submitted a patch which extracted the CL argument processing
> functionality from Configure.pl and placed it in
> lib/Parrot/Configure/Options.pm. The purpose of the patch was specifically
> to improve the testability of the functionality in Configure.pl. The patch
> also included a test file, t/configure/01-options.t, which, among other
> things, included a test for an invalid option.

I mean the command-line arguments to the parrot executable, not Configure.pl.

-- c

James Keenan via RT

unread,
Jun 12, 2008, 9:39:05 PM6/12/08
to perl6-i...@perl.org
The attached is very crude -- but is it at all what you were looking for?
options.t

Chromatic

unread,
Jun 13, 2008, 1:38:40 AM6/13/08
to parrot-...@perl.org, parrotbug...@parrotcode.org
On Thursday 12 June 2008 18:39:04 James Keenan via RT wrote:

> The attached is very crude -- but is it at all what you were looking for?

It's a good start. See parrot -h for a list of known options. I'm sure you
could make a nice little data-driven test with what you have here now.

-- c

James Keenan via RT

unread,
Jun 13, 2008, 8:19:29 AM6/13/08
to perl6-i...@perl.org
I notice that the *actual* exit code I'm getting is 256. Has that
changed since the OP or is there some bit-shifting going on here?

I also notice that the same exit code is generated regardless of whether
the option is valid or not. Is that the behavior we desire?


a...@ippimail.com

unread,
Jun 13, 2008, 11:05:32 AM6/13/08
to parrotbug...@parrotcode.org
> I notice that the *actual* exit code I'm getting is 256. Has that
> changed since the OP or is there some bit-shifting going on here?
>

If you are testing the return from a system call, "To get the actual exit
value, divide by 256. (The lower eight bits are set if the process died
from a signal.)" Thus spake "Perl in a Nutshell", 2nd Ed. p139.

--

Email and shopping with the feelgood factor!
55% of income to good causes. http://www.ippimail.com

Will Coleda

unread,
Jun 13, 2008, 1:53:45 PM6/13/08
to parrotbug...@parrotcode.org, perl6-i...@perl.org

Taking ajr's email into account, here's what I'm seeing for exit codes
at the shell:

$ ./parrot -BLORG
Option -B not known
parrot -[abcCEfgGhjprStvVwy.] [-d [FLAGS]] [-D [FLAGS]][-O [level]]
[-o FILE] <file>
$ echo $?
1
$ ./parrot
parrot -[abcCEfgGhjprStvVwy.] [-d [FLAGS]] [-D [FLAGS]][-O [level]]
[-o FILE] <file>
$ echo $?
0

--
Will "Coke" Coleda

0 new messages