Skip to content

Commit

Permalink
Auto merge of #48913 - Mark-Simulacrum:rustbuild-test, r=alexcrichton
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 4, 2018
2 parents 5758c2d + 184d3bc commit 17fea66
Show file tree
Hide file tree
Showing 17 changed files with 1,211 additions and 470 deletions.
40 changes: 40 additions & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ serde_json = "1.0.2"
toml = "0.4"
lazy_static = "0.2"
time = "0.1"
petgraph = "0.4.12"

[dev-dependencies]
pretty_assertions = "0.5"
5 changes: 4 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def __init__(self):
self.build_dir = os.path.join(os.getcwd(), "build")
self.clean = False
self.config_toml = ''
self.rust_root = os.path.abspath(os.path.join(__file__, '../../..'))
self.rust_root = ''
self.use_locked_deps = ''
self.use_vendored_sources = ''
self.verbose = False
Expand Down Expand Up @@ -710,6 +710,7 @@ def bootstrap(help_triggered):
parser = argparse.ArgumentParser(description='Build rust')
parser.add_argument('--config')
parser.add_argument('--build')
parser.add_argument('--src')
parser.add_argument('--clean', action='store_true')
parser.add_argument('-v', '--verbose', action='count', default=0)

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

# Configure initial bootstrap
build = RustBuild()
build.rust_root = args.src or os.path.abspath(os.path.join(__file__, '../../..'))
build.verbose = args.verbose
build.clean = args.clean

Expand Down Expand Up @@ -788,6 +790,7 @@ def bootstrap(help_triggered):
env["SRC"] = build.rust_root
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
env["BOOTSTRAP_PYTHON"] = sys.executable
env["BUILD_DIR"] = build.build_dir
run(args, env=env, verbose=build.verbose)


Expand Down
Loading

0 comments on commit 17fea66

Please sign in to comment.