Skip to content

Commit 17fea66

Browse files
committed
Auto merge of #48913 - Mark-Simulacrum:rustbuild-test, r=alexcrichton
Add tests to rustbuild In order to run tests, we cfg out various parts of rustbuild. Generally speaking, these are filesystem and process-spawning operations. Then, rustbuild is run "as normal" and the various steps that where run are retrieved from the cache and checked against the expected results. Note that this means that the current implementation primarily tests "what" we build, but doesn't actually test that what we build *will* build. In other words, it doesn't do any form of dependency verification for any crate. This is possible to implement, but is considered future work. This implementation strives to cfg out as little code as possible; it also does not currently test anywhere near all of rustbuild. The current tests are also not checked for "correctness," rather, they simply represent what we do as of this commit, which may be wrong. Test cases are drawn from the old implementation of rustbuild, though the expected results may vary. r? @alexcrichton
2 parents 5758c2d + 184d3bc commit 17fea66

17 files changed

+1211
-470
lines changed

Diff for: src/Cargo.lock

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/bootstrap/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ serde_json = "1.0.2"
4242
toml = "0.4"
4343
lazy_static = "0.2"
4444
time = "0.1"
45+
petgraph = "0.4.12"
46+
47+
[dev-dependencies]
48+
pretty_assertions = "0.5"

Diff for: src/bootstrap/bootstrap.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def __init__(self):
314314
self.build_dir = os.path.join(os.getcwd(), "build")
315315
self.clean = False
316316
self.config_toml = ''
317-
self.rust_root = os.path.abspath(os.path.join(__file__, '../../..'))
317+
self.rust_root = ''
318318
self.use_locked_deps = ''
319319
self.use_vendored_sources = ''
320320
self.verbose = False
@@ -710,6 +710,7 @@ def bootstrap(help_triggered):
710710
parser = argparse.ArgumentParser(description='Build rust')
711711
parser.add_argument('--config')
712712
parser.add_argument('--build')
713+
parser.add_argument('--src')
713714
parser.add_argument('--clean', action='store_true')
714715
parser.add_argument('-v', '--verbose', action='count', default=0)
715716

@@ -718,6 +719,7 @@ def bootstrap(help_triggered):
718719

719720
# Configure initial bootstrap
720721
build = RustBuild()
722+
build.rust_root = args.src or os.path.abspath(os.path.join(__file__, '../../..'))
721723
build.verbose = args.verbose
722724
build.clean = args.clean
723725

@@ -788,6 +790,7 @@ def bootstrap(help_triggered):
788790
env["SRC"] = build.rust_root
789791
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
790792
env["BOOTSTRAP_PYTHON"] = sys.executable
793+
env["BUILD_DIR"] = build.build_dir
791794
run(args, env=env, verbose=build.verbose)
792795

793796

0 commit comments

Comments
 (0)