Skip to content

Commit

Permalink
Allow passing arguments to bootstrap_test.py
Browse files Browse the repository at this point in the history
Previous, it used the built-in test runner, which doesn't support options unless they're manually passed in the script.
  • Loading branch information
jyn514 committed Jun 24, 2023
1 parent 7d2373e commit 3508cde
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
16 changes: 3 additions & 13 deletions src/bootstrap/bootstrap_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Bootstrap tests"""
"""Bootstrap tests
Run these with `x test bootstrap`, or `python -m unittest bootstrap_test.py`."""

from __future__ import absolute_import, division, print_function
import os
Expand Down Expand Up @@ -120,15 +122,3 @@ def test_set_codegen_backends(self):
build = self.serialize_and_parse(["--enable-full-tools"])
self.assertNotEqual(build.config_toml.find("codegen-backends = ['llvm']"), -1)

if __name__ == '__main__':
SUITE = unittest.TestSuite()
TEST_LOADER = unittest.TestLoader()
SUITE.addTest(doctest.DocTestSuite(bootstrap))
SUITE.addTests([
TEST_LOADER.loadTestsFromTestCase(VerifyTestCase),
TEST_LOADER.loadTestsFromTestCase(GenerateAndParseConfig),
TEST_LOADER.loadTestsFromTestCase(ProgramOutOfDate)])

RUNNER = unittest.TextTestRunner(stream=sys.stdout, verbosity=2)
result = RUNNER.run(SUITE)
sys.exit(0 if result.wasSuccessful() else 1)
7 changes: 6 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2664,7 +2664,12 @@ impl Step for Bootstrap {
/// Tests the build system itself.
fn run(self, builder: &Builder<'_>) {
let mut check_bootstrap = Command::new(&builder.python());
check_bootstrap.arg("bootstrap_test.py").current_dir(builder.src.join("src/bootstrap/"));
check_bootstrap
.arg("-m")
.arg("unittest")
.arg("bootstrap_test.py")
.current_dir(builder.src.join("src/bootstrap/"))
.args(builder.config.test_args());
try_run(builder, &mut check_bootstrap).unwrap();

let host = builder.config.build;
Expand Down

0 comments on commit 3508cde

Please sign in to comment.