Closed Bug 463746 Opened 16 years ago Closed 16 years ago

js/tests/jsDriver.pl: eliminate CPAN dependency

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: jorendorff)

Details

Attachments

(1 file, 1 obsolete file)

igor tried to fix this in bug 418304 by switching from Getopt::Mixed to some standard module that ships with perl.  Didn't work out.

My plan is to reimplement the bits of the LongOpts module that we actually use.  This being Perl, it only takes about 20 lines, but we may need to revise it once or twice to catch corner cases.  It's worth it.  Patch coming Monday.
Attached patch v1 (obsolete) — Splinter Review
This patch covers all *my* use cases.  If you're a jsDriver.pl user, please test-drive this!

bc, I'm happy to keep chipping away at whatever incompatibilities it's got, but feel free to just take this bug and finish it if that's more convenient.
Assignee: general → jorendorff
Attachment #347281 - Flags: review?(bclary)
On first glance and test it seems ok to me as long as others are ok with having to write repeated option/value pairs instead of option/value list, e.g.

before -L lc2 lc3 was ok, but with this patch -L lc2 -L lc3 would be required. That seems quite reasonable to me. Other opinions?

I'll look at it in more depth later.
(In reply to comment #2)
> On first glance and test it seems ok to me as long as others are ok with having
> to write repeated option/value pairs instead of option/value list, e.g.

I have few jsDriver-related scripts that relies on -L/-l support. Also I use usage like -L exclusions-*.txt. So I am not OK with that.
Attached patch v2Splinter Review
Igor, please try this one.  It supports multiple arguments to -l/-L.
Attachment #347281 - Attachment is obsolete: true
Attachment #347351 - Flags: review?(bclary)
Attachment #347281 - Flags: review?(bclary)
Severity: normal → enhancement
Comment on attachment 347351 [details] [diff] [review]
v2

tested with -l js1_7 js1_8, -l js1_7 -l js1_8, --list js1_7 js1_8, --list js1_7 --list js1_8,
-l js1_7 --list js1_8, --list js1_7 -l js1_8

>+
>+    if ($key =~ /\w+/ and $options =~ /\b$key>(\w+)/g) {
>+        $key = $1;
>+    }

I'm not exactly sure why, but with the global option g, this fails to match the second long option, e.g.

-l js1_7 -l js1_8 works, bug --list js1_7 --list js1_8 doesn't. 

r+ with that change and an explanation why?
Attachment #347351 - Flags: review?(bclary) → review+
Hmm.  Well, given two similar enough regexp searches using the g flag, the second search picks up where the first one left off.

If this were JS, I think the second search here wouldn't be similar enough to the first to trigger that behavior (because they happen in two separate calls to the function).  In Perl, I guess they are.  Same regexp in the Perl source code; same regexp pattern after substituting in $key; same string being searched.

Fix is to remove the g flag.

http://hg.mozilla.org/tracemonkey/rev/b8d60efef2e8
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
> (because they happen in two separate calls to the function)

To clarify, in JS the expression /whatever/g creates a new RegExp each time it's evaluated.

Thus `while ("abc".match(/a/g)) { print("ok"); }` is an infinite loop in JS.  In Perl, substituting =~ for the .match() method, it prints "ok" just once, so Perl must be using different "similar enough" rules.
Flags: in-testsuite-
Flags: in-litmus-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: