NEW 81560
webkitpy: platforminfo should replace direct checks for sys.platform wherever possible
https://bugs.webkit.org/show_bug.cgi?id=81560
Summary webkitpy: platforminfo should replace direct checks for sys.platform wherever...
Raphael Kubo da Costa (:rakuco)
Reported 2012-03-19 14:02:07 PDT
Even though platforminfo already replaces sys.platform in a lot of cases, the platform definitions which currently exist are sometimes too coarse-grained: for example, most of the places which still access sys.platform directly need to differentiate between cygwin and win32 because we only provide PlatformInfo.is_win(). Moving to a model where we specify capabilities of each platform should make it easier to port sys.platform uses to platforminfo, as well as make it less painful to add support for new platforms.
Attachments
Dirk Pranke
Comment 1 2012-05-02 13:50:25 PDT
This is a fair observation, but I'm not sure how this will really pan out in practice. Do you have specific examples in mind where we can do feature testing rather than platform testing?
Raphael Kubo da Costa (:rakuco)
Comment 2 2012-05-02 14:04:30 PDT
Not right now, really. What I've been doing these days is: 1. Try to clean up some uses of sys.platform 2. Convert checks for "darwin" to PlatformInfo.is_mac(), then do the same for PlatformInfo.is_win() 3. Add is_win32() and is_cygwin() to PlatformInfo and make is_win() return `self.is_win32() or self.is_cygwin()'. After that comes the tricky part of replacing the pieces of code which only check for "cygwin" or "win32" -- I'm not sure how to approach this, but when we talked on IRC about this issue (it all started because I'd like webkitpy to support FreeBSD and the current approach in bug 81467 is too intrusive) we thought of adding some kind of "is_unix" or "is_nix" to PlatformInfo. Right now I'm considering making this method just return something like `is_linux() or is_foo() or is_bar()', but this is where feature checks would come handy as well.
Basuke Suzuki
Comment 3 2017-12-14 12:13:04 PST
I agree with this separation. Let's do it. ... OMG this one is five years old bug :( I see many similar platform check on Executive so I tried to replace them using PlatformInfo, but I couldn't because PlatformInfo is dependent on executive and it requires executive on its __init__(). This kind of situation also should be solved.
Note You need to log in before you can comment on or make changes to this bug.