|
1 | 1 | """Bootstrap tests
|
2 | 2 |
|
3 |
| -Run these with `x test bootstrap`, or `python -m unittest bootstrap_test.py`.""" |
| 3 | +Run these with `x test bootstrap`, or `python -m unittest src/bootstrap/bootstrap_test.py`.""" |
4 | 4 |
|
5 | 5 | from __future__ import absolute_import, division, print_function
|
6 | 6 | import os
|
|
12 | 12 |
|
13 | 13 | from shutil import rmtree
|
14 | 14 |
|
| 15 | +# Allow running this from the top-level directory. |
| 16 | +bootstrap_dir = os.path.dirname(os.path.abspath(__file__)) |
| 17 | +# For the import below, have Python search in src/bootstrap first. |
| 18 | +sys.path.insert(0, bootstrap_dir) |
15 | 19 | import bootstrap
|
16 | 20 | import configure
|
17 | 21 |
|
@@ -131,8 +135,13 @@ def build_args(self, configure_args=[], args=[], env={}):
|
131 | 135 |
|
132 | 136 | parsed = bootstrap.parse_args(args)
|
133 | 137 | build = serialize_and_parse(configure_args, parsed)
|
134 |
| - build.build_dir = os.environ["BUILD_DIR"] |
135 |
| - build.build = os.environ["BUILD_PLATFORM"] |
| 138 | + # Make these optional so that `python -m unittest` works when run manually. |
| 139 | + build_dir = os.environ.get("BUILD_DIR") |
| 140 | + if build_dir is not None: |
| 141 | + build.build_dir = build_dir |
| 142 | + build_platform = os.environ.get("BUILD_PLATFORM") |
| 143 | + if build_platform is not None: |
| 144 | + build.build = build_platform |
136 | 145 | return build.build_bootstrap_cmd(env), env
|
137 | 146 |
|
138 | 147 | def test_cargoflags(self):
|
|
0 commit comments