Fix mb_unittest.py for Windows

The tests in mb_unittest.py carefully mock the file system entirely, and
then do Linux and Windows tests on both platforms. That's all great, but
somehow when run on Windows we were getting various errors including
this one:

    KeyError: '/fake_src/out/Default/C:\\src\\temp\\mb_test/task.json'

That path does not look good. The root cause is that crrev.com/c/2378273
added a TempDir function and that function did this:

    tmp_dir = os.path.join(tempfile.gettempdir(), 'mb_test')

That is, it used OS functions to get the temporary directory and to do
path joining. When testing the Linux functionality on Windows the
_AbsPath would look at 'C:\\src\\temp\\mb_test' and determine that it
was not a relative directory so it would prepend the current working
directory, and the world falls apart.

The fix is to mock the temporary directory as well. It's anticlimactic
really.

The fact that these tests worked on Linux was just luck (good or bad,
you decide). With this fixed the presubmits only have one minor
Windows-specific failure remaining.

Bug: 1309977
Change-Id: I4988b6d1b56e2da50196dfc3f339c4e12b80045c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3659032
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1006200}
NOKEYCHECK=True
GitOrigin-RevId: 5d8d1585b8af955b4866b1f7c88a32a8959b5e9f
1 file changed
tree: dd355a31bca1f242e2b730d350e8f94a462bba5a
  1. docs/
  2. lib/
  3. mb_config_expectations/
  4. __init__.py
  5. DIR_METADATA
  6. mb
  7. mb.bat
  8. mb.py
  9. mb_config.pyl
  10. mb_unittest.py
  11. mb_validation_unittest.py
  12. OWNERS
  13. PRESUBMIT.py
  14. PRESUBMIT_test.py
  15. README.md
  16. rts_banned_suites.json
README.md

MB - The Meta-Build wrapper

MB is a simple wrapper around the GN build tool.

It was originally written as part of the GYP->GN migration, in order to provide a uniform interface to either GYP or GN, such that users and bots can call one script and not need to worry about whether a given bot was meant to use GN or GYP.

It eventually grew additional functionality and is now still used even though everything is GN-only.

It supports two main functions:

  1. “gen” - the main gn gen invocation that generates the Ninja files needed for the build.

  2. “analyze” - the step that takes a list of modified files and a list of desired targets and reports which targets will need to be rebuilt.

We also use MB as a forcing function to collect all of the different build configurations that we actually support for Chromium builds into one place, in //tools/mb/mb_config.pyl.

For more information, see: