Bug 271200 - [webkitpy] Move the majority of tests to using pyfakefs
Summary: [webkitpy] Move the majority of tests to using pyfakefs
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Sneddon [:gsnedders]
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2024-03-18 16:47 PDT by Sam Sneddon [:gsnedders]
Modified: 2024-03-25 16:48 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Sneddon [:gsnedders] 2024-03-18 16:47:33 PDT
Our use of MockFileSystem in webkitpy is in many ways a nuisance; it requires us implement our own fake implementation of every Python API we want to use, while being significantly more limited in scope and ability (without a significant rewrite) than filesystems actually are.

Other projects like pyfakefs exist, and we should further leverage these rather than maintain our own fake implementation. This also means we'd be using our actual FileSystem object when running tests.

One significant advantage (and downside!) of pyfakefs is it mimics the actual system: this means on Windows we'll be running tests in a Windows-like environment, which will almost certainly cause (pre-existing) issues to become apparent.

It also allows us to emulate other systems when running tests, which allows us to test Windows-like behaviour on other OSes.

The one place we have some limited usage of pyfakefs today is in the LayoutTestFinder unit tests: when rewriting the LayoutTestFinder, having the ability to emulate Windows was a significant win, as it's almost certainly how we managed to land that without dramatically breaking Windows.

The biggest downside of pyfakefs is you cannot run subprocesses while it is active, which we currently do in a few places (some of this is likely needless—like creating real Host() objects, which ultimately invokes `sw_vers` on macOS), though arguably such things are bugs in the first place (as it's hard to define what running a subprocess actually means within a fake filesystem, because it'll always have access to the real one!).
Comment 1 Sam Sneddon [:gsnedders] 2024-03-18 17:00:23 PDT
Pull request: https://github.com/WebKit/WebKit/pull/26089
Comment 2 Radar WebKit Bug Importer 2024-03-25 16:48:13 PDT
<rdar://problem/125381024>