Open Bug 2087020 Opened 21 days ago

Fix the detach failure warning in mozperftest's macOS layer

Categories

(Testing :: mozperftest, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: mferreiro, Unassigned, Mentored)

Details

(Keywords: good-first-bug)

Filing as a good first bug to learn workflows.

When mozperftest mounts a DMG on macOS, MacosDevice.extract_app in python/mozperftest/mozperftest/system/macos.py logs a warning if detaching the image fails. That warning never shows the actual error:

except subprocess.CalledProcessError as e:  # noqa
    self.warning("Detach failed {e.stdout}")

There are two problems:

  1. The string is missing its f prefix, so the log literally says "Detach failed {e.stdout}" instead of interpolating the error.
  2. Even with the prefix, e.stdout is the wrong field: hdiutil and diskutil report their errors on stderr, and MacosDevice._run_process stores it in the stderr attribute of the CalledProcessError it raises.

The "# noqa" comment only silences the linter warning about e being unused, which was a hint of this bug.

Desired code:

except subprocess.CalledProcessError as e:
    self.warning(f"Detach failed {e.stderr}")

Link to the code:
https://searchfox.org/firefox-main/rev/b0625683b9b8cd108f6b3fa9eedbcd4aa0066d6e/python/mozperftest/mozperftest/system/macos.py#79

To verify the fix:

./mach lint python/mozperftest/mozperftest/system/macos.py
./mach perftest-test python/mozperftest/mozperftest/tests/test_macos.py

The behavior doesn't change (detach failures are intentionally ignored, see test_detach_fails), but the warning will now explain why detaching failed.

Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html

Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.

You need to log in before you can comment on or make changes to this bug.