Closed Bug 772186 Opened 12 years ago Closed 12 years ago

Support return values from pymake native commands

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla16

People

(Reporter: gps, Assigned: rain1)

References

Details

Attachments

(1 file, 1 obsolete file)

This is an offshoot of bug 770702 to have pymake native commands support return values.

I think we want to interpret int return values as exit codes and all other values as whatever behavior we do today.
Attached patch patch (obsolete) — Splinter Review
I also added tests for failing sys.exit and return calls.
Assignee: nobody → sagarwal
Status: NEW → ASSIGNED
Attachment #640988 - Flags: review?(khuey)
Blocks: 680636
Comment on attachment 640988 [details] [diff] [review]
patch

Review of attachment 640988 [details] [diff] [review]:
-----------------------------------------------------------------

After further review, we might also consider following what Python does for sys.exit:
http://docs.python.org/library/sys.html#sys.exit
"The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object."
"If another type of object is passed, None is equivalent to passing zero, and any other object is printed to stderr and results in an exit code of 1."

::: pymake/process.py
@@ +214,5 @@
> +            if isinstance(rv, int) and rv != 0:
> +                print >>sys.stderr, (
> +                    "Native command '%s %s' returned value '%s'" %
> +                    (self.module, self.method, rv))
> +                return -127

Do we want to propogate the return code here? If you look at PopenJob.run, we return the value of .wait() for actual shell commands.
(In reply to Ted Mielczarek [:ted] from comment #2)
> Comment on attachment 640988 [details] [diff] [review]
> patch
> 
> Review of attachment 640988 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> After further review, we might also consider following what Python does for
> sys.exit:
> http://docs.python.org/library/sys.html#sys.exit
> "The optional argument arg can be an integer giving the exit status
> (defaulting to zero), or another type of object."
> "If another type of object is passed, None is equivalent to passing zero,
> and any other object is printed to stderr and results in an exit code of 1."

That is pretty much what I originally wanted to do, but gcp thought we might run into trouble with functions that already exist and return objects even on success. On the other hand, I don't think finding and fixing such cases is going to be an issue.
I prefer this one (plus going in and fixing any native commands that need to be fixed), but I'm going to leave both up and let you decide.
Attachment #641023 - Flags: review?(khuey)
I just did a full pymake build using the second patch (attachment 641023 [details] [diff] [review]) and had no issues. I think we should go with that.
Comment on attachment 640988 [details] [diff] [review]
patch

I'm assuming the other patch supersedes this one.
Attachment #640988 - Flags: review?(khuey)
(In reply to Siddharth Agarwal [:sid0] from comment #3)
> (In reply to Ted Mielczarek [:ted] from comment #2)
> > Comment on attachment 640988 [details] [diff] [review]
> > patch
> > 
> > Review of attachment 640988 [details] [diff] [review]:
> > -----------------------------------------------------------------
> > 
> > After further review, we might also consider following what Python does for
> > sys.exit:
> > http://docs.python.org/library/sys.html#sys.exit
> > "The optional argument arg can be an integer giving the exit status
> > (defaulting to zero), or another type of object."
> > "If another type of object is passed, None is equivalent to passing zero,
> > and any other object is printed to stderr and results in an exit code of 1."
> 
> That is pretty much what I originally wanted to do, but gcp thought we might
> run into trouble with functions that already exist and return objects even
> on success. On the other hand, I don't think finding and fixing such cases
> is going to be an issue.

I didn't realize sys.exit's behavior was what it is. I think we should copy that behavior.
Attachment #640988 - Attachment is obsolete: true
(Sorry for getting your nick wrong, gps. Gah, two three-letter nicks with two letters common :( )
https://hg.mozilla.org/mozilla-central/rev/e60f929e7d6b
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla16
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: