Bug 81560

Summary: webkitpy: platforminfo should replace direct checks for sys.platform wherever possible
Product: WebKit Reporter: Raphael Kubo da Costa (:rakuco) <rakuco>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: abarth, basuke, dpranke, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 85407, 180827    
Bug Blocks:    

Description Raphael Kubo da Costa (:rakuco) 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.
Comment 1 Dirk Pranke 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?
Comment 2 Raphael Kubo da Costa (:rakuco) 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.
Comment 3 Basuke Suzuki 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.