This is an archive of the discontinued LLVM Phabricator instance.

[lldbsuite] Fix the mac version decorator to work on non-mac platforms
ClosedPublic

Authored by stella.stamenova on Oct 12 2018, 10:50 AM.

Details

Summary

On non-mac platforms, mac_ver returns an empty string which when converted to LooseVersion has no "version" property. This causes a failure when the decorator executes. Instead, check whether the value returned from mac_ver is an empty string and avoid the LooseVersion comparison.

Diff Detail

Repository
rLLDB LLDB

Event Timeline

shafik added inline comments.Oct 12 2018, 2:04 PM
packages/Python/lldbsuite/test/decorators.py
194

If I am reading the following code correctly this will default to skipping when platform.mac_ver()[0] == "" shouldn't it be the other way around?

packages/Python/lldbsuite/test/decorators.py
194

Yes, you are reading it correctly. I can see either as being "right" - the question is how the decorator is supposed to be used.

Usually, it is paired with a skipUnlessDarwin (or similar), so skipping if it is not mac is "right".

On the other hand, for the test you added, I think you wanted it to run on other platforms and on mac only if the version requirement was met, so we should not skip if the platform is not Darwin. Was that your goal?

We do compose the decorators in a bunch of places (like Shafik's usage here). That will work more naturally if the categories that the decorators assert are as decoupled as possible. So the statement about macos version should only skip the test if the os is macos, and make no comment about other os's. That decouples the macos_version test from the oslist test, and allows something like the construct in the tests that Shafik wrote, which seems a pretty natural way to express "if on macOS, it has to be version > x, otherwise it has to be clang > y".

We do compose the decorators in a bunch of places (like Shafik's usage here). That will work more naturally if the categories that the decorators assert are as decoupled as possible. So the statement about macos version should only skip the test if the os is macos, and make no comment about other os's. That decouples the macos_version test from the oslist test, and allows something like the construct in the tests that Shafik wrote, which seems a pretty natural way to express "if on macOS, it has to be version > x, otherwise it has to be clang > y".

I updated the change to support that. Could you have a look?

jingham accepted this revision.Oct 15 2018, 5:45 PM

That seems more convenient to me, it makes the mac version only relevant if you are on a mac.

This revision is now accepted and ready to land.Oct 15 2018, 5:45 PM
This revision was automatically updated to reflect the committed changes.