Closed Bug 832750 Opened 8 years ago Closed 7 years ago

Improve python 3 compat in js/src/tests/

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: Ms2ger, Assigned: Ms2ger)

References

Details

Attachments

(1 file)

Attached patch Patch v1Splinter Review
Particularly, print as a function and the new except syntax. Also removed some unused imports as reported by pyflakes.
Attachment #704325 - Flags: review?(terrence)
Comment on attachment 704325 [details] [diff] [review]
Patch v1

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

Thanks for doing this!

::: js/src/tests/lib/manifest.py
@@ +170,5 @@
>          elif parts[pos] == 'pref(javascript.options.xml.content,true)':
>              testcase.options += ['-e', 'options("allow_xml");']
>              pos += 1
>          else:
> +            print('warning: invalid manifest line element "%s"'%parts[pos])

Please switch this to .format().

::: js/src/tests/lib/results.py
@@ +126,5 @@
>                  self.pb.beginline()
>  
>              if show:
>                  if self.options.show_output:
> +                    print('## %s: rc = %d, run time = %f' % (output.test.path, output.rc, output.dt), file=self.fp)

Ditto.

@@ +198,2 @@
>              for path in paths:
> +                print('    %s' % path)

Just use |print('    ' + path)| here: it's faster than entering the string formatter.

::: js/src/tests/lib/tasks_win.py
@@ +70,5 @@
>      def log(self, msg):
>          if self.verbose:
>              dd = datetime.now() - self.t0
>              dt = dd.seconds + 1e-6 * dd.microseconds
> +            print('[W%d %.3f] %s' % (self.id, dt, msg))

Switch to format.

::: js/src/tests/parsemark.py
@@ +80,5 @@
>      sigma = stddev(milliseconds, mean)
>      if not stfu:
> +        print('Runs:', [int(ms) for ms in milliseconds])
> +        print('Mean:', mean)
> +        print('Stddev: %.2f (%.2f%% of mean)' % (sigma, sigma / mean * 100))

I didn't even know about parsemark. You don't need to bother with reworking all of these prints to use .format(), if you don't want: they are more complicated and lower value.
Attachment #704325 - Flags: review?(terrence) → review+
Ms2ger: did you forget to land this r+'d patch from January 2013? :)
Flags: needinfo?(Ms2ger)
Seems like it's green now. I'll land later.
Flags: needinfo?(Ms2ger)
https://hg.mozilla.org/mozilla-central/rev/b987f3903eb9
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in before you can comment on or make changes to this bug.